Compare commits

...

4240 Commits
6.9 ... dev

Author SHA1 Message Date
Marc Mutz
532400a722 tst_QPointer: make capture compatible between C++17..23
Clang 19 -std=c++23 complained that ITERATIONS_PER_THREAD was
captured, but not used, so 668d81f73a5c2f4ec14764d1892f2eaf6494c0f1
dropped it, after making the variable constexpr.

Picking that change back to older branches, we found that MSVC
(14.29?) complains that it's _not_ captured anymore:

   tst_qpointer.cpp(491): error C3493: 'ITERATIONS_PER_THREAD' cannot be implicitly captured because no default capture mode has been specified

To appease both compilers, and cover the maximum range of C++ standard
editions, use implicit [&] capture, which should work everywhere.

Not picking to 6.5, because the cherry-pick of
668d81f73a5c2f4ec14764d1892f2eaf6494c0f1 already had to make that
change in order to pass CI.

Pick-to: 6.10 6.9 6.8
Change-Id: Iacbd53d3904608e8c9cd73edf31ba7924fd508e6
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-06-15 16:37:14 +00:00
Marc Mutz
6600a332c6 QScopeGuard: only include what you need
... not all of qglobal.h.

[ChangeLog][Potentially Source-Incompatible Changes][QtCore] The
qscopeguard.h header no longer includes qglobal.h, but only what it
itself needs. A backwards-compatible fix is to not depend on
transitive includes and include all you need explicitly.

Pick-to: 6.10
Change-Id: I257ae4cbd36d331e2fbda7fa238dcbc26a75647c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-15 16:37:06 +00:00
Frédéric Lefebvre
00750cd8ba Refactor tst_QScroller::overshoot
tst_QScroller::overshoot was initially a boilerplate, making it
difficult to understand what was actually being tested.

Refactor this test to be data-driven. Additionally, create a new test
function, overshoot_segments, which was part of
tst_QScroller::overshoot and should be tested independently.

Transfer the blacklisted platform of overshoot to overshoot_segments.

Change-Id: I59d89dfab4bb09c41fce99ad4f40163736c6ef78
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-06-15 17:44:06 +02:00
Matthias Rauter
bb48dbb113 Add conversion from QUtf8StringView to std::u8string_view
Writing the tests for QUtf8StringView showed that this conversation does
not work if the underlying storage_type is not char8_t. This is
something a user rightfully expects from our library and we therefore
added an explicit conversion operator for it.

[ChangeLog][QtCore][QUtf8StringView] Added std::u8string_view operator
if compiled with C++20.

Pick-to: 6.10
Change-Id: Ia80507bdd76686bee16a40745be064e9bdfef130
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-06-15 09:35:08 +00:00
Christian Ehrlicher
cfd52c5c5f QStyleSheetStyle: replace c arrays with std::array
Replace some c-arrays with std::array<> for easier handling.

Pick-to: 6.10 6.9
Change-Id: I34766a2aad603d83187515626982adc976667d48
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-06-14 16:55:46 +00:00
Axel Spoerl
3416d28c8b QWindowsScreenManager::removeScreen() - don't leave stale screen behind
QWindowsScreenManager::removeScreen() read an element from m_screens
and removed it. If the removed screen was not the primary screen,
QWindowSystemInterface::flushWindowSystemEvents() is called.

When removeScreen() is called from handleScreenChanges() in the same
class, flushing window events can lead to a re-entry. That is e.g. the
case when a RDP connection is closed and the server removes the virtual
screen.

QWindowScreenManager::removeScreen() removes the platform screen only
at the very end, which means that m_screens contains a stale pointer.
The re-entry can therefore crash with a double delete.

Take the platform screen at the beginning of the method, to make it
safe for re-entry.

Fixes: QTBUG-135337
Pick-to: 6.10 6.9 6.8 6.5
Change-Id: Id18a6fb3e72922bcdb62c9e79857b6bb713c0c1b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2025-06-14 17:51:17 +02:00
Marc Mutz
e45916fada [docs] QScopeGuard: fix a grammar mistake in ctor docs
Even though there are two \fn's, we still use singular form when we
refer to the effects of the function.

Amends 4f077b7e5ff1081afc0e362bdab6522c2b7ee43b.

Pick-to: 6.10 6.9 6.8 6.5
Change-Id: I7cc150eb96b4aac40abcf7076bb82049a209f837
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-14 15:38:40 +02:00
Marc Mutz
902e0a723a [docs] QScopeGuard: mention dismiss()ing in \class
The class docs should include a discussion of salient API, not leave
that only to \fn's.

Amends 9229452e574e603aa86fd5adb28da33cf5879db9.

Pick-to: 6.10 6.9 6.8 6.5
Change-Id: I53144c7e56eca21ceeda0c1bca0028e987da9e18
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-14 15:38:40 +02:00
Fabian Kosmale
f2ef861688 moc: support __has_include
__has_include is part of C++17, but moc did not handle it so far.
This commit fixes moc to correctly support it.

It should be noted that support for __has_include relies on all
necessary include paths being passed to moc.

Pick-to: 6.10 6.9 6.8
Fixes: QTBUG-136097
Change-Id: I7284e97dea12d1637b38349d32e090c0102124e7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-14 12:48:30 +02:00
Fabian Kosmale
246b43d581 cmake: Unify the set flags between AUTOMOC and qt_wrap_cpp
For AUTOMOC, we were missing the compiler flavor flag, as well as the
WIN32 define. While the latter has not caused any known issues yet, the
former is rather problematic for implementing __has_include in moc.

Note that this only applies in the case where the AUTOMOC flags are set
by us in a qt_ function like qt_add_excutable. Plain add_executable
won't benefit from it, but we already mention that Qt targets should not
use plain CMake functions.

This change is (indirectly) tested by the commit adding __has_include
support for moc.

Task-number: QTBUG-136097
Pick-to: 6.10 6.9 6.8
Change-Id: Ie2beb08a44a3a67e3bc363d9c1ba93b7d6a49133
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-06-14 12:48:30 +02:00
Ulf Hermann
9a7d06f0d4 QNetworkAccessBackend: Do not leak wrapped upload byte device
The wrappedUploadByteDevice is obviously intended to be owned by
QNetworkAccessBackend. It needs to be deleted when QNetworkAccessBackend
is destroyed.

Ideally we shouldn't use bare pointers at all here, but since we need
to pick this back all the way to 6.5, a minimal fix is preferred.

Amends commit bba0bdb35c2806bcdde8e89965e99b3d412b8d3a

Change-Id: Icbe857ad02c23693c313d3fcb2d0ee068362e5b7
Pick-to: 6.10 6.9 6.8 6.5
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-06-14 09:38:39 +00:00
Marc Mutz
f4e7eebd27 QCoreApplication: fold two atomic ops into one
The old code performed a fetchAndSubAcquire() followed by an implicit
loadAcquire() in the Q_ASSERT(). But fetchAndSub() returns the old
value, so we don't need to re-load it; we just need to store the
result of fetchAndSub().

We need to adjust the assertion, of course, since we're now checking
the old value, which is one more than a load would show, so replace ≥
0 with > 0.

Amends the start of the public history.

Pick-to: 6.10 6.9 6.8 6.5
Change-Id: I6f6804261cd56a5a8bbb276ed7a0ac360c94195e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-14 09:38:39 +00:00
Thiago Macieira
96dfe0373c QVarLengthArray: use assign() for the iterator,iterator ctor
Let's avoid std::back_inserter for non-complex types, which generates a
huge amount of unnecessary code. The implementation of assign() is far
more modern.

Pick-to: 6.10
Change-Id: Ia8b9c90336af2bebd49ffffd0d69ace761c6aa59
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-06-13 21:24:53 -07:00
Thiago Macieira
54069d37ef tst_ContainerApiSymmetry: add non-deprecated copy assignment to Movable
Despite the name, this class is copyable, as evidenced by the fact it
has a copy constructor. But that copy constructor causes the implicitly-
declared copy-assignment operator to be deprecated.

warning: implicitly-declared ‘constexpr Movable& Movable::operator=(const Movable&)’ is deprecated [-Wdeprecated-copy]
tst_containerapisymmetry.cpp:55:5: note: because ‘Movable’ has user-provided ‘Movable::Movable(const Movable&)’

Amends 2e1763d83a1dacfc5b747934fb77fa7cec7bfe47 (5.14).

Pick-to: 6.10 6.9 6.8 6.5
Change-Id: Ie661f7361a8d86648b21fffdaf9e7d076f86ebe9
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-06-13 21:24:29 -07:00
Rami Potinkara
1141a6fa17 Android: fix QtDisplayManager getDisplaySize function
This patch fixed QtDisplayManager::getDisplaySize
function to use API's that do not require
MANAGE_APP_TOKENS permission.

The function previously failed on 32-bit architectures
with Android 11 aka SDK 30 aka VERSION R due to
createWindowContext requiring MANAGE_APP_TOKENS
permission. The earlier try-catch lead to next error,
because of invalid values.

Amends: 98120622ff1f6f87664f4c42e830000a21391751

Fixes: QTBUG-137027
Pick-to: 6.10 6.9 6.8 6.5
Change-Id: Ia9c3a64ea41ad0575a34a96858851a1123cfc915
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-06-14 06:37:14 +03:00
Ahmad Samir
cee8ea7c13 QDirListing: properly deprecate ExcludeSpecial
Add "since 6.10" to ExcludeOther's docs.

Found in API review.

Amends c553f39e3d3cd02854850da0dfc639acbae59299.

Pick-to: 6.10
Change-Id: I3edb32d4d50864ddbdde03aaca750d590a0e0854
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-14 05:40:56 +03:00
Mårten Nordheim
94f0ff704e Schannel: Use modern key management APIs
The key/certificate lifetime management in our Schannel backend is a
little lacking. We haven't guaranteed that the original contexts are
held alive for the full duration of their usage. Though with default
settings they get persisted to disk so it has been mostly fine.

One problem with that is that the legacy APIs in Windows for this is not
smart enough to figure out that a repeatedly-loaded key is the same one,
so it 'persists' a new file to disk every time we set up a credential
context for a connection. For a busy server this may end up with
creating a ton of small files that don't get deleted (or reused).

By using the ncrypt APIs we don't fully stop persisting _all_ data to
disk, but from testing we now only have one file per key. Regardless of
the amount of connections.

Another patch around lifetimes can be done for dev, and dev only, as
it's quite a bit more extensive, and not fit for picking back to the
LTS branches.

Fixes: QTBUG-136055
Pick-to: 6.10 6.9 6.8
Change-Id: I61398a3773ef8c25aab21df3e78b71f3ab11d488
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-06-14 04:40:56 +02:00
Christian Ehrlicher
a0c591c120 QStyleSheetStyle: use range-based for loops
Replace some for loops with range-based ones.

Pick-to: 6.10 6.9
Change-Id: Ib11fb4ec5785b8ec4c9c297684f90d7f5031fe58
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-06-13 23:10:14 +02:00
Volker Hilsheimer
560bf5a077 Android/iOS: prefer files icons to come from the Icon theme
There are no icons for computer, trash, desktop, folders, files etc. on
mobile platforms. QAbstractFileIconProvider tests the
QPlatformTheme::PreferFileIconFromTheme hint, and if set, gives
QIcon::fromTheme a try with an icon name mapped to the icon provider's
icon type.

We have at least some mapping of such standard icons in the native icon
engines, and those engines would also be the right place to perform
additional platform specific look-ups of icons (i.e. for specific file
types). So as a first improvement, try to use the icon engine for file
icon provider icons.

Task-number: QTBUG-134239
Pick-to: 6.10
Change-Id: Ib8c301a19b0d7e23f1d3ebdccde2147709f3ddb3
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-06-13 19:52:41 +02:00
Volker Hilsheimer
9f93ddd2f3 QGroupBox: document non-standard behavior for enable/disable logic
When QGroupBox::checked changes, it disables children, and enables
children that are not explicitly disabled. The group box itself however
remains enabled, so it's possible for user code to override the behavior
for individual child widgets, which can happen accidentally when
the order in which children are added, and the checked state of the
group box is changed, is inconsistent.

We won't change this as it has too many side effects. Instead, document
the conceptually deviation from enable/disable state propagation.

Pick-to: 6.10 6.9 6.8 6.5
Fixes: QTBUG-25938
Change-Id: I2aa37600ec932cd4ce721bfa98f63169eb0d0beb
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-06-13 19:31:12 +02:00
Marc Mutz
ab53b12931 QAccessibleWidget: replace QString default arg with overload
We should not use defaulted arguments of non-trivial type, because
their construction and destruction, even if not passed, is repeated at
every call site, producing O(n) executable code.

By overloading out-of-line, we execute the same code at runtime, but
we have only one copy of the arg construction and destruction, in the
library, O(1) executable code production.

Found in API-review of QAccessibleWidgetV2.

Amends the start of the public history.

Can't pick further than (unreleased) 6.10, because this adds a new
symbol.

Pick-to: 6.10
Task-number: QTBUG-98117
Change-Id: I705bca764992d9e7a2aa1021e0f94006b6817177
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-06-13 14:31:56 +02:00
Axel Spoerl
444e5b63c3 Blacklist tst_qscroller::overshoot() on Windows
Function has become flaky due to additions made in
84e09e060bedd37d8de7cded7e430371e335c029.

Blacklist for now.
Add missing link to QTBUG-134105 in BLACKLIST file.

Task-number: QTBUG-134105
Pick-to: 6.10 6.9
Change-Id: I2e53ab8de08575f13c950dd92d24ad3017a7dc0a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-06-13 12:25:08 +00:00
Volker Hilsheimer
5dc261357e a11y on macOS: return a valid window element
Our accessibilityWindow implementation asks the parent for it's window,
expecting that it will always be the same. This is conceptually correct.

However, as we don't represent windows through QAccessibilityInterface
and instead rely on the natively provided element, the filtering out of
ignored elements result in accessibilityParent return a null object once
the parent is the window.

Instead, check if we get an interface that represents a Window, and
if so fall through to the code returning the NSView (after going through
QAcessibilityInterface::window call, which was so far missing).

And if we then get a Window element as the parent, then we don't have
to call accessibilityWindow on that parent again. Instead, return the
result directly and only keep going if we got some other element.

Add a test case that confirms that we now get a valid result for the
window attribute.

Pick-to: 6.10 6.9 6.8 6.5
Fixes: QTBUG-137157
Change-Id: Ifa485734b290284bd5a1286e3b3c18454442fa10
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-06-13 14:25:08 +02:00
Marc Mutz
90dbb413bf QCoreApplication: relax an atomic load in a Q_ASSERT()
A Q_ASSERT() must not have side-effects, incl. ordering memory. So the
implicit loadAcquire() was too strong. The code must also work with
loadRelaxed(), so use that.

Amends the start of the public history.

Pick-to: 6.10
Change-Id: Ib94bd0989d1a358b552275dc3963b014e6e4c180
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-13 14:25:04 +02:00
Marc Mutz
5efcbf9fb8 QAccessibleWidgetV2: make the dtor protected
QAccessibleWidget (i.e. V1) has a protected dtor, so V2, which merely
extends V1 because we can't add new virtuals (via a new base class)
due to BC constraints, shouldn't differ in this respect.

Amends bb2121551c3d7b1af1553710bc211ba0e39b4212.

Found in API-review.

Pick-to: 6.10
Change-Id: I0c9a00691a14c600b020ff1a9f433634bb7c8d24
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-06-13 14:25:04 +02:00
Marc Mutz
b9a43e7767 tst_moc: fix Clang -Winline-namespace-reopened-noninline
Says Clang:

  tst_moc.cpp:86:14: warning: inline namespace reopened as a non-inline namespace [-Winline-namespace-reopened-noninline]
     86 |    namespace B::inline C {}
        |              ^
        |    inline
  tst_moc.cpp:84:21: note: previous definition is here
     84 | namespace A::inline B {}
        |                     ^

There's no minimally-invasive fix, because neither

   inline namespace B::inline C {}

nor

   namespace inline B::inline C {}

are valid C++.

So wrap the whole thing in another namespace ("Qt_", to avoid clashing
with somthing else, incl. our own namespace Qt), so we have roughly
the same structure as before, but with two non-inline outer namespaces
instead of one.

Amends 5222df2be7d10bf44dfc2971774eadcb526b7a13.

Pick-to: 6.10 6.9 6.8 6.5
Change-Id: Ia0e35e87934abebc76b719e3bd8124ac77ea07f5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-06-13 14:25:04 +02:00
Marc Mutz
79ab9305c1 QAccessibleWidgetV2: de-inline ctors and avoid QString default arg
We should not use defaulted arguments of non-trivial type, because
their construction and destruction, even if not passed, is repeated at
every call site, producing O(n) executable code.

By overloading out-of-line, we execute the same code at runtime, but
a) we have only one copy of the arg construction and destruction, in
the library, O(1) executable code production, and b) being out-of-line
in the library, the compiler can optimize the call to the base class
ctor away, if it wants to, because it sees its implementation.

Found in API-review.

Amends bb2121551c3d7b1af1553710bc211ba0e39b4212.

Pick-to: 6.10
Task-number: QTBUG-98117
Change-Id: Ib6a3b15cc861893797c0445a91691132b21bbf2c
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-06-13 12:25:04 +00:00
Wladimir Leuschner
295933aadc WindowsQPA: Make custom titlebar a child window
The current approach for custom titlebar uses an overlay of a
frameless popup window at the position of the titlebar area. This
involves synchronizing the window state, position and size of the
popup window with the original window. Also, the drawing of
rounded edges needs to be done manually with the old approach.
This patch adds the titlebar as a real child to the
original window, so that the window manager takes care of the
synchronization and clipping process.

Fixes: QTBUG-135643
Fixes: QTBUG-133943
Fixes: QTBUG-133946
Pick-to: 6.10 6.9
Change-Id: I1770580a1c306074f41a7ff64c1d525c93918480
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2025-06-13 14:25:04 +02:00
Kai Uwe Broulik
3d405bfe67 doc: Fix typo in QCalendarWidget::dateTextFormat
renderd -> rendered

Pick-to: 6.10 6.8 6.9 6.5
Change-Id: If4df3cd0dd7a11e30283bf5925dc6364d0d79225
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-06-13 13:38:52 +02:00
Jonas Karlsson
c15e9740b3 Fix standardbutton-apply-16.png
There were some artifacts added (white pixels and bad anti aliasing)
when the icon was changed in e771e5e2d7ae77f46d01f087242e0f777fdc02ac

Pick-to: 6.10 6.9 6.8 6.5
Change-Id: I12a8658090a1f081321e53433d17fc19ad3e5f12
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-06-13 13:38:51 +02:00
Even Oscar Andersen
30c254591d wasm: a11y - Implement support for disabled attribute
Fixes: QTBUG-137449
Change-Id: I6aa07c7108b5ad14c12e6f24e71b8dda12fec483
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-06-13 12:02:20 +02:00
Dheerendra Purohit
60841478d3 Doc: Fix QtConcurrent::run member function parameter order documentation
Updated the description to match Qt 6 behavior,
clarifying that the instance argument now follows
the member function pointer.

Fixes: QTBUG-113401
Pick-to: 6.10 6.9 6.8
Change-Id: I6cb9c63718790eda153bc5202ed4eb1d23f032bc
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-06-13 08:27:35 +00:00
Christian Ehrlicher
4832f61212 SQL/DB2: Add and document DB2_ROOT
Sync the cmake arguments to search for DB2 with the rest of the qsql
find modules and provide a DB2_ROOT env or cmake var.
Also allow the old variables as a fallback.

Pick-to: 6.10
Change-Id: I587e519b5cf3513e9580f64f0fb9b46bf789da5c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-06-13 07:42:54 +00:00
Thiago Macieira
6489c41234 QTest::CrashHandler: print the Unix signal si_code name
It's easier to interpret an "SEGV_MAPERR", "FPE_INTDIV", or "ILL_ILLOPC"
rather than "code 1".

Alongside the decoded instruction pointer from the previous commit, we
now get a message like:

  Received signal 11 (SIGSEGV), code SEGV_MAPERR, at address 0x00005637dd5c1346, for address 0x0000000000000004

Change-Id: Ic9f54e06fd2956fea3ccfffde7aa7b54167333b7
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-06-12 19:14:58 -07:00
Thiago Macieira
5d28c05ba8 QFileSystemEngine/Unix: fix typos and correct comments
Change-Id: I4d90d8ea8d25b89c9e8dfffd0210fc99e0d5ac3e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-06-12 23:14:41 -03:00
Thiago Macieira
e1d418bcd0 QFileSystemEngine/Unix: avoid an unnecessary conversion to QString
Sometimes, fillMetaData() is called with a QFileSystemEntry with only
the native (QByteArray) format, which we used above in this function
anyway in order to lstat() and stat() the path. This avoids forcing the
QFSE to create the QString form for us to check the first character.

Pick-to: 6.10 6.9 6.8
Change-Id: I8d93f6db83a28d70a192fffd6668734a8024b88b
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-06-12 23:14:37 -03:00
Thiago Macieira
c5e6034bbd QFileSystemEngine/Linux: correct a minor problem with lstatx() failures
Our wrappers around the statx(2) system call on Linux return the
negative of errno, to avoid setting errno and reading it back for the
OSes where the system call doesn't apply. That means the vast majority
of errors from qt_lstatx() will not be -1 (the most common being -2 for
ENOENT) and we'd thus not enter the next block:

    // second, we try a regular stat(2)
    if (statResult == -1 && (what & QFileSystemMetaData::PosixStatFlags)) {

Pick-to: 6.10 6.9 6.8
Change-Id: I489e7c9ee1327fb98510fffd315c66948956534f
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-06-12 23:14:36 -03:00
Thiago Macieira
07d3d3935c QRangeModel/Doc: link to QtWidgets only if the feature is set
Amends efe41182fda94c0e4805c24b3305577e5da81880.

The code already tests for QT_NO_WIDGETS before including and using
Widgets APIs, and we will want to extend the corelib_snippets target
with more of the existing snippets code to make sure that they build.

To not break -no-widgets builds, don't link against Qt::Widgets unless
the feature is set.

Pick-to: 6.10
Fixes: QTBUG-137556
Change-Id: Ic30fd519416068c275c3fffd0e1df10a76ce8fad
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-06-12 21:17:58 +00:00
Volker Hilsheimer
45202b26ce Fix -no-feature-draganddrop builds
Amends 7d0017cda8fde28a1130feaeecf41010b40e3cb3 which added the APIs,
and ef7e5ea616a3f04ff0ba5f6fe34487a332152b01 which only added the guard
for QListWidget.

Address header review comment.

Pick-to: 6.10
Task-number: QTBUG-137478
Change-Id: I405190190f4d64dd810d7d35e9ef616ab0147b19
Reviewed-by: David Faure <david.faure@kdab.com>
2025-06-12 20:22:38 +02:00
Marc Mutz
668d81f73a tst_QPointer: fix Clang 19 -Wunused-lambda-capture
Clang informs that ITERATIONS_PER_THREAD need not be captured:

  tst_qpointer.cpp:548:66: warning: lambda capture 'ITERATIONS_PER_THREAD' is not required to be captured for this use [-Wunused-lambda-capture]
    548 |                 QThread::create([&startSemaphore, &targetObject, ITERATIONS_PER_THREAD]() {
        |                                                                ~~^~~~~~~~~~~~~~~~~~~~~

Make ITERATIONS_PER_THREAD (and NUM_THREADS, while at it) constexpr,
indicating even to non-language-lawyers that these variables, indeed,
need not be captured, then drop the capture.

Amends 253f34082f526ff1ffd9eaefac73cc9aa616ab2a.

Pick-to: 6.10 6.9 6.8 6.5
Change-Id: I27d94763058e1dcea3a65d4ff2c859b40336446f
Reviewed-by: David Faure <david.faure@kdab.com>
2025-06-12 18:22:38 +00:00
Marc Mutz
901a6e7986 tst_ContainerApiSymmetry: ensure we're checking defined iterator types
The old code used the same type of container for both target and
source in the range-assign() test. This limits our test coverage.

Fork the test to explicitly test with random-access (std::vector), as
well as forward-only (std::forward_list) iterators. This ensures we
have coverage of random-access, forward as well as the existing input
iterator types.

Amends 426d975cee9c783aec0832f376b836cdabee983f.

Pick-to: 6.10 6.9 6.8
Change-Id: I59c7a322ecbcc564baa1263e02b234bc53563fac
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-06-12 20:22:38 +02:00
Marc Mutz
c51a038615 tst_ContainerApiSymmetry: rename a variable in assign_impl()
A container is not an iterator, so don't call a container
'iter'. Since we're copying from it, call it 'src'.

Amends 7cbdc8abbda12488f51317313347bbc220b42fe0.

Pick-to: 6.10 6.9 6.8
Change-Id: I7732465f222032b2833396576873fed370f71d11
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-06-12 20:22:38 +02:00
Thiago Macieira
4f0156fa4b Q*Mutex: unexport for Qt 7
Those weren't caught for the Qt 6.0 release.

Pick-to: 6.10
Change-Id: I5831d4ad80b7f60d8782fffd6c64ef552f82ad6e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-06-12 11:22:38 -07:00
Alexey Edelev
d91d49ffe2 Move Android ABI detection to the separate function
Allows reusing the Android ABI detection.

Pick-to: 6.8 6.9 6.10
Change-Id: I8e452605b25e522c953f39a525c038a88174094b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-06-12 18:58:33 +02:00
Alexey Edelev
1f10cd4b45 Introduce _qt_internal_append_cmake_configure_depends
The function append the unique entries to the CMAKE_CONFIGURE_DEPENDS
property. This suppress the ninja recompat issue, which complains
about the duplicated entries in that come from the
CMAKE_CONFIGURE_DEPENDS property. It's likely the CMake issue, but
we may work around it.

Pick-to: 6.8 6.9 6.10
Change-Id: I2f10834b0dca3d2aa08fe13fba69849e97fa77d0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-06-12 18:58:33 +02:00
Mårten Nordheim
1bcfbfa3bc QDateTime::currentDateTime: fix time zone offset for repeated hours
Because we were consulting GetLocalTime we didn't get disambiguated
times for repeated hours. Drop that code-path and simple rely on
GetSystemTime instead.

Done-with: Mate Barany <mate.barany@qt.io>
Done-with: Edward Welbourne <edward.welbourne@qt.io>
Fixes: QTBUG-133656
Pick-to: 6.10 6.9 6.8
Change-Id: I3f1f09edfd9fb3135ccc12bf98e06254327e76fe
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-06-12 16:58:33 +00:00
Mårten Nordheim
3af5e42bdd Http2ProtocolHandler: fix logic error with potential use-after-free
We previously asserted that the reply was not nullptr, except in some
special circumstance. But then we proceeded to dereference it anyway.
This was then recently changed to be an if-check, but that just
highlighted the logic-flaw (and made static analyzers warn about it...)

What we want to assert is that the stream object is valid and
conditionally return early if the reply is nullptr, which it is for
promised streams, since no request has been made yet so no reply is
created.

At the same time, update the logic in the QHttp2Stream to not store or
emit header-related signals for a stream that has been reset.

Pick-to: 6.10 6.9
Change-Id: I55d69bbedc027893f6ad125c29468a34e7fb406f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-06-12 18:58:33 +02:00
Mårten Nordheim
f9fbdba3a1 Schannel: Use smart-ptr to manage the certiticate context
We already have the alias for it, we just never updated the stored
member to use it.

Pick-to: 6.10 6.9 6.8
Change-Id: I850c9f0b899a15603b4c5ac83693019b856effb2
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-06-12 16:58:33 +00:00
Marc Mutz
6c18b438a3 QMetaObject: port QArgumentType to QByteArrayView
Now that argumentTypesFromString() actually doesn't normalize types
anymore, all type names are substrings of the signature, and so
QByteArrayView suffices (was: QByteArray) to hold the result.

QArgumentType in only used transitively, during QMetaObject member
function or QObject::connect() calls, so the source string will also
never go out of scope before the QArgumentType object that references
it.

As a drive-by, make the QArgumentType ctor explicit and port from
QVLA::op+=() to emplace_back().

No discernable impact on tst_bench_qobject's connect_disconnect.

Task-number: QTBUG-135572
Change-Id: If6544917b9df8191a256dc2a67e31c6b7e5a38cb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-12 18:03:50 +02:00
Marc Mutz
afdf37ad8f QMetaObject: deprecate the Qt 6 QVector -> QList porting kludge
The argumentTypesFromString() function is clearly documented not to
perform any normalization, yet in typical Qt 6.0 porting rush, it did,
and this kludge was never removed.

Do it now; it's in the way of porting QArgumentType from QBA to QBAV,
and it's causing correct code to incorrectly fail.

This, however, changes the behavior of QMetaObject::indexOf*(), because
they don't fall back to normalization (indeed, these functions are used
as isNormalized checks, e.g. in connect()). So we can't remove the
kludge just yet, but we can drag it out of the fast path and re-try
with QVector replaced by QList when nothing was found using the
original signature. This way, we only pessimize unported users (and
calls that would have failed for other reasons, by scanning for
"QVector<" in the signature).

Add a qWarning() that we'll remove this behavior going forward.

It does, however, fix the bug that signals and slots that contain
types that match, but are not, "QVector<", fail to be found by the
machinery:

[ChangeLog][QtCore][QMetaObject/QObject] Fixed a bug that caused
signals and slots with argument types matching "QVector<"
(e.g. "MyQVector<int>" or "NotQt::QVector<int>") to not be found in
QObject::connect() or QMetaObject::indexOfMethod().

[ChangeLog][Deprecation Notices][QMetaObject] The
indexOf{Constructor,Slot,Signal,Method}() functions are documented to
require input according to QMetaObject::normalizedSignature(), but
accepted a QList declared as QVector. This was an internal porting aid
and is being deprecated now. Watch out for runtime warnings about this.
QObject::connect() and QMetaObject::invokeMethod() are unaffected, as
they fall back to normalizeSignature() automatically.

No change in tst_bench_qobject connect performance, which is
unsurprising, as the benchmark doesn't use a QVector alias.

Amends 03326a2fec416405b437089874f6439e937bbada.

Task-number: QTBUG-135572
Pick-to: 6.10
Change-Id: I7fd9293bba5d2b57b4452e55499ffbf360bc6123
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-06-12 16:03:50 +00:00
Olivier De Cannière
5aa1bc4621 Widgets: Set viewItemPosition style option for QTableView and QListView
Before this patch, we did not set the view item positions in the views.
This was fine as they were ignored until
b780eaf6a063a7efe03417cf6b7008a188e222a4 added a condition to early exit
on invalid positions. This then broke all qss background styling using
QStyleOptionViewItem::ViewItemPosition as they were always invalid.

Set the position when trying to draw a cell of the view before
reaching the code handling the qss rules for backgrounds.

Fixes: QTBUG-137346
Pick-to: 6.10 6.9 6.8
Change-Id: I83d7a3ea7b9bab98889791bb807988a74e355b93
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2025-06-12 17:22:23 +02:00
Petri Virkkunen
76bf2512e7 Android: Add default template argument return type to AndroidBackendRegister
For AndroidBackendRegister::callInterface, it would be more convenient
to call simple functions without parameters, without being forced to
specify the void return type. Added a default void type argument for
the return type.

Change-Id: Ib7f631c172955cdf0b2e853155fd57c06bef9843
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-06-12 13:37:19 +00:00
Petri Virkkunen
43e52253d5 Android: Add some developer documentation to AndroidBackendRegister
A quick blurb to explain the usecase and limitations of
AndroidBackendRegister, meant for future developers.

Also documents the two public-facing functions, getInterface()
and callInterface().

Change-Id: I79f07d4a19fdb1f4a53529ab42a8663999759f85
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-06-12 16:37:19 +03:00
Morten Sørvig
c2ec20b226 wasm: don't recreate WebGL context on surface change
The native WebGL context is tied to a single canvas,
and can only be used with that canvas. (Qt creates
one canvas per QPlatformWindow).

This means that we need new native contexts in cases
where a QWindow is repeatedly created and destroyed.
It can be tempting to just create a new WebGL context
"behind the scenes" on the makeCurrent() call in this
case, but this does not work since GL resources created
by user code with the original WebGL context in place
are now invalid.

Inform user code that this has happened by signaling
a context loss. This is done by returning false from
makeCurrent(), and then making sure isValid() returns
false as well.

The context becomes invalid whenever the owning platform
window is destroyed; add a call from ~QWasmWindow() which
handles that bookkeeping.

Pick-to: 6.10
Task-number: QTBUG-120138
Change-Id: I929b9bb51153007c16630b1a991399f01ebffa62
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-06-12 15:37:19 +02:00
Gleb Popov
59c29436db QNativeSocketEngine: React on POLLHUP too when selecting for writing
FreeBSD may return a single POLLHUP revent not coupled with any of POLLOUT nor
POLLERR. This causes a busy-loop, so put POLLHUP into write_flags.

Change-Id: Ief62138eeb6de8e2caf1d6937507bfd828adfb81
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-12 15:20:49 +03:00
Gleb Popov
4ba106b38f QEventDispatcherGlib: Put G_IO_HUP into pfd.events for all cases of QSocketNotifier::Type
On FreeBSD when asked for POLLOUT the poll() syscall returns only POLLHUP to
signify the fact that the other side closed the connection. It never sends
POLLERR for EOF cases, which results in a busy-loop inside the Glib dispatcher:
- poll() returns immediately with POLLHUP for a closed socket
- socketNotifierSourceCheck() does not detect it, because .events = POLLOUT | POLLERR
  and we get .revents = POLLHUP. The (events & revents != 0) condition evaluates to false
- the code decides there is nothing to do and a new iteration starts

A similar issue in dbus code: https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/526

Change-Id: I2660a5179031da8eb9fe2562abe7fb283c77f64a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-12 15:20:49 +03:00
David Boddie
5b86fca7cf Doc: Remove redundant "see also" link
Pick-to: 6.9 6.10
Change-Id: Id48d97a171b55f3dbf8d1fa32e23b82d28e5552d
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-06-12 12:20:49 +00:00
Thiago Macieira
25f396218d QBasicMutex: bring back fastTryUnlock for MSVC
MSVC exports inline functions, so we're not allowed to remove them. This
is an unlikely problem, though, since it was only called from other
inline functions: if the compiler was inlining content into user code
(as it should), then it would likely have inlined this one too; if
instead the inliner was disabled, then it wouldn't have inlined the
caller either.

Amends commit 1957597aa6bc6ebd8bd1f903389800897411ac5d. Seen in API
review.

Pick-to: 6.10
Task-number: QTBUG-137478
Change-Id: Idd01170c3396c5b6fefefffd748f3335fc42fd79
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-06-12 12:20:49 +00:00
Marc Mutz
184d0bf2ec QSharedPointer: fix uninit'ed field 'destroyer'
The getAndRef(const QObject*) function failed to initialize
ExternalRefCountData's destroyer field: the Qt::Uninitialized ctor
doesn't init anything and there are no following assignments to the
field, either.

This probably a) caused some Coverty complaint (but I didn't check,
because the Coverity UI is so clumsy) and b) was harmless, seeing as
the -1 in strongref indicated that the destroyer is never to be fired.

Fix it nevertheless by initializing it to nullptr.

Amends the start of the public history.

Pick-to: 6.10 6.9 6.8 6.5
Change-Id: Ib76b4bc00b08289bb8d6d58096b43501b47814d1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-12 14:04:58 +02:00
Marc Mutz
e4b0549a4c QSocks5SocketEngine: don't depend on zero-initialization of QBasicAtomic
It's unclear¹ whether static zero-initialization of a static
QBasicAtomic actually initializes the object with a zero value, or
whether it remains default-constructed (without a value until a
following call to std::atomic_init gives it one).

Play it safe and use Q_BASIC_ATOMIC_INITIALIZER(0) to dodge any issues
the old code may have had.

¹ see ongoing discussion on the Jira ticket

Amends 04d6495bf773a6bb0d4fa6980df22d3b81a605b0.

Task-number: QTBUG-137465
Pick-to: 6.10 6.9 6.8 6.5
Change-Id: Iee0d75ce10a589390afdd9069b7040a1c9c608e1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-12 14:04:58 +02:00
Marc Mutz
5aefe2d9a1 QRegion: fix potential UB in QBasicAtomic initialization
Until C++17 (inclusive), a default-constructed std::atomic object can,
officially, only be initialized with a call to std::atomic_init, for
which QBasicAtomic doesn't have API. It is even unclear whether
zero-initialization of static and thread-local objects will cause the
object to be initialized.

QRegion is using QtPrivate::RefCount, but that's just another wrapper
around QBasicAtomic, so it has the same problems: it must always be
initialized.

So don't default-construct and then storeRelaxed() (via
initializeOwned()), use NSDMI with (newly-added)
Q_REFCOUNT_INITIALIZE_OWNED to avoid this dark language corner.

Task-number: QTBUG-137465
Pick-to: 6.10 6.9 6.8 6.5
Change-Id: I4b765aed329211984c35c40fbc5648bf104990ce
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-12 14:04:58 +02:00
Jani Korteniemi
3047d6a8a1 Fix androiddeployqt copying build directory
When project's Android package source directory is set to the
project level (instead of project/android) androiddeployqt keeps
copying the build directory under itself infinitely.

Add check to copyFiles:
-If android source dir is the same as project source dir
-And if current directory copied is in build directory path

Pick-to: 6.5 6.8 6.9 6.10
Fixes: QTBUG-126743
Change-Id: If45766152c6cbf9e2ee916baa5a15282d3fedaf2
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-06-12 08:58:39 +03:00
Marc Mutz
270b219410 QTRY_IMPL: revert an incorrect change to a code comment
The comment in the QTRY_IMPL macro definition pertains to the
following using namespace std::chrono_literals, which has nothing to
do with the default timeout of QTRY_ macros, because that is
determined somewhere else. Further, "5 seconds" is not a valid chrono
literal, as "5s" was.

Partially reverts 55f163382d36ddf908fc2884f2020a1b92340c10.

Found in API-review.

Pick-to: 6.10
Change-Id: Ic1242436bf87d7067e3c5240eb2687505e24800f
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-06-12 00:34:17 +02:00
Marc Mutz
f1e1a933a6 qdebug.h: remove duplicate includes
Added by 51f702d4029148570d255daef80d071d98cf1e16 w/o rationale.

Found in API-review.

Pick-to: 6.10
Change-Id: Ia0afd3d3aaf7a8bc392333b8359ce5b5496bec7f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-06-12 00:34:17 +02:00
Mårten Nordheim
9ed754e754 Schannel: fix verifying intermediate certificates with netscape ext
We were always checking 'client' or 'server' usage depending on our own type,
which breaks for any intermediate certificate with the 'ca' usage set.

We assume that any non-leaf certificate should be a CA (if anything),
and leaf certificates must be for client or server usage.

Pick-to: 6.10 6.9 6.8 6.5
Fixes: QTBUG-137041
Change-Id: I268f3bad669df77351fc458f56e318db75ecac7b
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-06-11 21:22:55 +02:00
Volker Hilsheimer
33dc247b6a Test: don't discard result of QFile::open
QVERIFY that the file could be opened, fail the test if it couldn't.

Pick-to: 6.10 6.9
Change-Id: Iab9b819e70b71fade6a58286edff8e022748d9f6
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2025-06-11 20:10:43 +02:00
Fabian Kosmale
3f0261ebe3 QSFPM: Support source model undergoing reset during setSourceModel
Since 9d8663c18e88cb0b5a65f86cfd7726f3d31e04d6, we print a warning when
endResetModel is called without beginResetModel.
This however triggers false positives with a QSFPM if we set a source
model which is resetting at this point in time:
The QSFPM reacts to the endResetModel signal in _q_sourceReset by
calling its own endResetModel, but it does not have the resetting flag
set.
Fix this by deferring the endResetModel work that we are doing in
setSourceModel if the source is undergoing reset.

Task-number: QTBUG-132775
Pick-to: 6.10 6.9 6.8 6.5
Change-Id: I363f2f34a06cc5de031fa87c6274322bf03bd77f
Reviewed-by: David Faure <david.faure@kdab.com>
2025-06-11 20:01:04 +02:00
Topi Reinio
a9a68a87b9 Doc: Adjust styling of QML property signatures in offline docs
Recent changes in QDoc's output for QML type reference pages included
rearranging the `extra synopsis` element, i.e, read-only, since, and
deprecation information for properties.

As a result, the existing CSS for the offline documentation caused some
elements to be rendered on top of each other when using the qlitehtml-
based backend in Qt Assistant and Qt Creator.

To fix the layout, set a fixed width for the table elements that
are used to display the properties, property groups, and methods.
This change brings the style of QML reference pages closer to that
of C++ reference, where signatures also have a fixed width.

Pick-to: 6.10 6.9 6.8
Fixes: QTBUG-136990
Change-Id: I72adbeaca46cd9dd99c54368257268dc8db6bfdc
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: David Boddie <david.boddie@qt.io>
2025-06-11 17:21:52 +00:00
Matthias Rauter
25df8042a4 Incorporate the sub-class-of info when deriving mimetypes
The tika mimetype database contains multiple rules that would fit to a
valid file (e.g. svg file that is svg and xml) with the same priority
(50 in case of svg and xml). The choice is thus ambiguous which leads to
regressions in the reported mimetype.

In order to break ambiguity, we look now also at the sub-class-of
element and we prefer sub-classes as they are more narrow and detailed
than the super-class.
The recommended checking order of freedesktop.org suggests that this is
the correct thing to do: "If any of the mimetypes resulting from a glob
match is equal to or a subclass of the result from the magic sniffing,
use this as the result." However, this does not fit perfectly to the
case of the bug report because both results come from magic sniffing.

If two rules match and have the same priority, without one being a
sub-class of the other, there is still an ambiguity. In that case we
now print a warning about the ambiguity.

The patch adds a test for the previously ambiguous case. There is no
test for the warning on ambiguity, because such a test file would be
difficult to generate and is probably not worth the effort.

Fixes: QTBUG-133221
Pick-to: 6.10 6.9 6.8
Change-Id: I1817ec4da947cd91729d0ce35defc9f63cd784d9
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-06-11 18:46:52 +02:00
Marc Mutz
fe7f01019c tst_QMetaObject: don't compare QByteArray/QLatin1StringView
This isn't needed, and actually counter-productive, because this mix
used to be ambiguous in Qt 6.5.

Amends 5c563a98a5ffe2a72a641bfa9ed30e17ecffd893.

Not picking to 6.5, because the 6.5 cherry-pick of the amended commit
doesn't compile, so the _L1's were already removed as part of manual
conflict resolution.

Pick-to: 6.10 6.9 6.8
Change-Id: I1810f90c7cf6e3760f1d99e026b291311501c3aa
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-06-11 18:46:52 +02:00
Matthias Rauter
26bf2bedca Extend tests for QUtf8StringView
The existing tests were taken from tst_QLatin1StringView. This patch
adds the simple tests from tst_QStringView.

The tests fromLiteral(), fromRange() and fromContainer() are not
included in this patch.

Pick-to: 6.10 6.9 6.8 6.5
Task-number: QTBUG-132097
Change-Id: I1efc0c2d2f474f6644261575a745aa8f7e5ac4b2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-11 18:18:04 +02:00
Volker Hilsheimer
7ac8815a19 QRM: silence gcc warning that an array can never be nullptr
If T is a C-array, like it is in some of our tests, then an instance of
that can never be nullptr, which recent gcc versions think warrants a
compile time warning -Waddress.

As a C array is a valid data structure to instantiate a QRangeModel
from, silence that warning by handling the case explicitly.

Pick-to: 6.10
Change-Id: I63090891988e677cf3ae2d871418b1abd4d1dc71
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
2025-06-11 18:18:04 +02:00
Matthias Rauter
dd81b42127 Make include guard match its filename
Pick-to: 6.10
Change-Id: I57af3c237bddffc424cab734faa30deacaa9bcdb
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-06-11 16:59:46 +02:00
Laszlo Agocs
fdbc8079c9 rhi: Update the docs and manual test for geometry shaders
Task-number: QTBUG-137521
Change-Id: Ic9256eaaa55aef20c622429058fda9235c1f73c1
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-06-11 15:15:42 +02:00
Aaron McCarthy
7dd952667c Copy Android files from the application source in aux mode
The application provided overrides of the Android files were not being
used in aux mode. In aux mode androiddeployqt was only copying the
Android files from the Qt sources and updating them.

With this change androiddeployqt also copies the Android files from the
application source, allowing overrides prior to template processing.

Change-Id: Idf790f1c270691dab8fe093c20e84bed79bf481d
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-06-11 23:15:42 +10:00
Cristian Le
00a96237fd Propagate _Qt6CTestMacros in RunCMake
Propagate the `_Qt6CTestMacros` variable so that
`_qt_internal_get_cmake_test_configure_options` can be used
inside the RunCMake tests

Pick-to: 6.8 6.9 6.10
Change-Id: I2b7f3996315169d840bab3dff011927288c9782d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-06-11 09:14:06 +02:00
Tor Arne Vestbø
cdb33c3d56 macOS: Remove linkage to AGL framework
It's no longer available on macOS 26, and we don't use it anymore
anyways.

Pick-to: 6.10 6.9 6.8 6.5
Change-Id: Ia1d0e37dda177f333646e598e517f4af20215dad
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-06-10 21:17:22 -07:00
David Faure
5e971101f0 QIdentityProxyModel: avoid emitting reset in no-op setSourceModel
QSortFilterProxyModel does this exactly, it was missing in
QIdentityProxyModel.

Pick-to: 6.10
Change-Id: If14bc7a377c1ad9235dd70222e3bfbf88eef11c0
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2025-06-11 04:08:35 +02:00
Tor Arne Vestbø
b9c77b9685 macOS: Explicitly link the platform plugin to Foundation
In the macOS 26 SDK the NSUserActivityTypeBrowsingWeb is claimed to come
from both Foundation (as in earlier SDKS), as well as CoreServices.

However the latter is not the case on macOS 15, resulting into load
errors with missing symbol.

By explicitly linking to Foundation, and putting it first in the
framework list, we trigger the linker to use the right reference
for the symbol.

Reported upstream as FB17876148.

Pick-to: 6.10 6.9 6.8 6.5
Change-Id: I0c3203f92851ad9fa862aed237823f0e1e28f6ff
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-06-10 15:41:35 -07:00
Samuli Piippo
0f6c93c453 wayland: fix EGL build without x11
Amend 7c0a96785fee4fea8ef1452166b1dde88957445c and add needed
defines to fix EGL build without x11. Otherwise eglplatform.h
will try to include X11 headers.
See 4cc5428548cb8ab973e4b0281dd123d59bfaf6a0 for more details.

Pick-to: 6.10
Change-Id: I2c284219e83fecf862520a2f667d561adf4d4357
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-06-10 21:32:56 +00:00
Samuli Piippo
ccb854799d CMake: build QGnomePortalInterface always when DBus is available
Builds with DBus but without XCB/Wayland, failed with:
  qgnometheme.cpp:(.text+0x3ec): undefined reference to `vtable for QGnomePortalInterface'
  /usr/bin/ld: src/gui/CMakeFiles/Gui.dir/platform/unix/qgnometheme.cpp.o: in function `QGnomeThemePrivate::QGnomeThemePrivate()':

Change CMake configuration and build QGnomePortalInterface always with DBus,
except on Apple platforms, where it is not needed.

Pick-to: 6.10
Change-Id: I3fb6400d87ba08f03c30e33924c8c7d483486c3b
Reviewed-by: MohammadHossein Qanbari <mohammad.qanbari@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-06-10 21:32:56 +00:00
Volker Hilsheimer
1ee43844d4 Exclude MSVC version 19.44 in tst_qcheckedint and tst_qnumeric
Still causing an internal compiler error with the currently latest VC++
version.

Amends 4e3a1675793995e44f5c84f28bfdc0fd02aa27cc.

Pick-to: 6.10
Change-Id: Ia4290c9b21eb8163180d725ed200629e36e85f1f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-06-10 22:57:53 +02:00
Christian Ehrlicher
46c2aa2b61 QPA/Windows: Fix QPainter warnings when animations are disabled
Don't draw on a QImage with a size of 0/0.

This amends 5feefd30734cd12753956819fc7c152be07c24cd

Pick-to: 6.10 6.9 6.9.1
Fixes: QTBUG-135844
Task-number: QTBUG-127634
Change-Id: Ib57cdccfabe67454984f3229f9d7ad02dd0d9992
Reviewed-by: Błażej Szczygieł <mumei6102@gmail.com>
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2025-06-10 18:30:25 +00:00
Edward Welbourne
5e9efe45df Make QTest::failOnWarning() fail also on any message type >= warning
Particularly for the no-parameter case, which fails on any warning, it
makes no sense to not also fail on a critical.

Pick-to: 6.10 6.9
Change-Id: I36f02a7dfb195616ce68babedbccc61480935fb9
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2025-06-10 20:11:54 +02:00
Edward Welbourne
dd5f409c58 Rework tst_QDate{,Time} QDataStream test to include all versions
In tst_QDate the test previously had a hard-coded list of versions by
name. This, however, needed updates on each new release (or at least
new version of QDS), which have been neglected since Qt 5.0. The
tst_QDateTime version, meanwhile, only identified versions by their
numeric value, not their symbolic names.

So borrow the way tst_QCalendar enumerates QCalendar::System, making
QDataStream a Q_GADGET and its Version a Q_ENUM to support this, to
iterate over all versions algorithmically. Apply to both data stream
tests to get a more consistent form for their data tags.

Change-Id: I04d1060cfec822cfcdc0bce6d15b636fc165fe36
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-10 20:11:54 +02:00
Edward Welbourne
3905d3c4df Use QMetaEnum::fromType() instead of staticMetaObject.enumerator()
The old way relied on the order of enums within the type; using
fromType() makes the enum specific.

Change-Id: I418473a6983861ca105ccc5eb249f441dbbb28cf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-10 20:11:54 +02:00
Tor Arne Vestbø
f67ef4934b Add QOperatingSystemVersion/QSysInfo support for macOS 26 (Tahoe)
Pick-to: 6.10 6.9 6.8 6.5
Change-Id: If6e7ee92e7c491c91a17e2730112319a132ca623
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-10 11:11:54 -07:00
Frédéric Lefebvre
372a8f904a Unblacklist tst_qListView::styleOptionViewItem on Ubuntu Wayland
tst_qListView::styleOptionViewItem is no longer flaky on Ubuntu
Wayland.

Fixes: QTBUG-127920
Pick-to: 6.10
Change-Id: Ia79292c283bc21bb84b3cc30a7d6c1863c8d0836
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-06-10 18:41:35 +02:00
Liang Qi
22e193e293 Unblacklist tst_qGraphicsItem::itemUsesExtendedStyleOption on Wayland
tst_qGraphicsItem::itemUsesExtendedStyleOption is no longer flaky on
Ubuntu Wayland.

Fixes: QTBUG-115293
Pick-to: 6.10
Change-Id: Ic971a13c37398bd2eaa9ccb16c10bcf62fdb8d69
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-06-10 18:41:35 +02:00
Frédéric Lefebvre
ccd7eda005 Unblacklist tst_qGraphicsItem::cursor on Ubuntu Wayland
tst_qGraphicsItem::cursor is no longer flaky on Ubuntu Wayland.

Fixes: QTBUG-127920
Pick-to: 6.10
Change-Id: Ie9096f8790bd031b642c5f5c259445859848c2f5
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-06-10 18:41:35 +02:00
Frédéric Lefebvre
e3225008cb Unblacklist tst_qPrinter::testPrintPreviewDialog on Ubuntu Wayland
tst_qPrinter::testPrintPreviewDialog is no longer flaky on Ubuntu
Wayland.

Fixes: QTBUG-127920
Pick-to: 6.10
Change-Id: Iea857db7be3ef6656667b32011009d561b92a749
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-06-10 18:41:35 +02:00
Frédéric Lefebvre
cb97b31906 Unblacklist tst_qBackingStore::flush on Ubuntu Wayland
tst_qBackingStore::flush is no longer flaky on Ubuntu Wayland

Fixes: QTBUG-127920
Pick-to: 6.10
Change-Id: I16d91ceb8854f4aee8c569c792e8cb7977cb95ca
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-06-10 18:41:34 +02:00
David Boddie
d02ac6b3e0 doc: Fix links and auto-links
Changed function names to include parentheses so that they can be auto-
linked to getters and setters for bindable properties.

Pick-to: 6.9 6.10
Change-Id: I72a06a7def55348bd1295e559751a16c62c93a84
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2025-06-10 16:02:28 +00:00
Petri Virkkunen
2c6be851ae Android: Support multi-arg signal generation in androiddeployqt
This commit introduces support for generating Java code for
multi-argument QML signals.

Pre-existing code remains unchanged, and the new code is only executed
when the number of params in a signal is above 1.

Multi-arg signals are handled with a new generated interface type,
named after the signal, which has a default method that takes an
Object[] array and calls the user-implemented signal method with the
arguments cast to the desired types.

For example, a QML signal with the following signature:

signal manyTypeArgSignal(intValue: int, boolValue: bool,
doubleValue: double, stringValue: string)

Is generated into this Java code:

@FunctionalInterface
public interface manyTypeArgSignalListener {
    default void onSignalEmitted(Object[] args) {
        onSignalEmitted((Integer) args[0], (Boolean) args[1], (Double) args[2], (String) args[3]);
    }
    void onManyTypeArgSignal(Integer intValue, Boolean boolValue, Double doubleValue, String stringValue);
}
public int connectManyTypeArgSignalListener(manyTypeArgSignalListener signalListener) {
    return connectSignalListener("manyTypeArgSignal", new Class[]{ Integer.class, Boolean.class, Double.class, String.class }, signalListener);
}

Task-number: QTBUG-124489
Change-Id: I94e3e88e807017bcbeba16cf0e34263e28e5885f
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-06-10 18:09:25 +03:00
Mårten Nordheim
8d5db24c14 Http2: fix handling incoming frames on locally reset stream
After some of the RST stream handling was updated to more closely
follow the RFC it was accidentally not updating the handleHEADERS
function, and the handleDATA function was handled incorrectly leading
to a potential nullptr dereference.

Amends d17d260948e16549d82f1fdd4dec98d246b0622e.

Pick-to: 6.10 6.9
Change-Id: I345448efd7da92f4f74033b03a5c040b5db9d271
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2025-06-10 17:09:25 +02:00
Mårten Nordheim
904aec2f37 Http2: Explicitly send RST_STREAM on cancelled request
It will do this when it gets deleted, but due to deleteLater just adding
an event to the event queue the events that are ahead in the queue may
use the stream in question. This would lead to a variant of
'stream not found', or specifically in the case of the bugreport, a
'HEADERS on non-existent stream' stream error.

Amends 6b4e11e63ead46dde5c1002c123ca964bb6aa342

Fixes: QTBUG-137427
Pick-to: 6.10 6.9
Change-Id: I5f2b2d5660866f1ad12aaafbb4e572b08ed5a6e4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2025-06-10 17:09:25 +02:00
Laszlo Agocs
97fe141f25 rhi: metal: Handle MSAA backing textures like other textures
...when it comes to dropping them in the swapchain's createOrResize().

There is no wait for command completion normally, unless the
code path that calls destroy() is hit. Therefore, handling msaaTex
like the textures behind any normal QRhiTexture is important. Use the
deferred release mechanism that QRhiTexture's destroy() would use on its
backing textures.

This avoids the occasional validation message when resizing Qt Quick
windows that have both multisampling and Metal validation enabled.

Task-number: QTBUG-112355
Pick-to: 6.10 6.9 6.8
Change-Id: I34549ce47e675d5869239b9330a166b80b40b30d
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-06-10 16:22:28 +02:00
Bartlomiej Moskal
21616e1447 Android-Keyboard: Avoid manual keyboard visibility updates on API 30+
Keyboard visibility is now tracked via OnApplyWindowInsetsListener,
which provides reliable visibility state changes starting from API
level 30. In this setup, manually updating the visibility property
is unnecessary and may lead to inconsistencies.

Task-number: QTBUG-98984
Pick-to: 6.10 6.9 6.8
Change-Id: Ife80898e20d4038efeae3438fb89b593bdaa056a
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-06-10 15:28:31 +02:00
Bartlomiej Moskal
acbcf992ee Android-Keyboard: Remove redundant code in isKeyboardHidden()
The m_keyboardIsVisible variable already reflects the current
keyboard visibility state. This commit simplifies the
isKeyboardHidden() method by using it directly, removing
unnecessary logic.

Task-number: QTBUG-98984
Pick-to: 6.10 6.9 6.8
Change-Id: I6bba90e6fbfb1191415e7ee812517ca15ac1c937
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-06-10 15:28:31 +02:00
Bartlomiej Moskal
33cf82c13d Android-Keyboard: Improve keyboard visibility tracking
Starting with API level 30, keyboard visibility can be easly checked
using [0]WindowInsets.isVisible(int). This eliminates the need for
relying on callbacks to detect when the keyboard opens or closes.

This commit updates the logic to track keyboard visibility by
observing changes via OnApplyWindowInsetsListener and checking for
visibility changes using the new API.  From now on, for API 30 and
above, the internal keyboard visibility property should no longer be
updated manually.

[0] https://developer.android.com/reference/android/view/WindowInsets#isVisible(int)

Task-number: QTBUG-98984
Pick-to: 6.10 6.9 6.8
Change-Id: I40f3ccc4e652f1ae0c6c0ebd154d690d1a9d7ca8
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-06-10 15:28:31 +02:00
Bartlomiej Moskal
3823d99a68 Android-Keyboard: Use new show() / hide() methods for keyboard control
Starting with API level 30, Android introduced new
[0]WindowInsetsController.show(int) and [1]hide(int) methods for
controlling the keyboard visibility. This commit updates the code to use
these methods on devices running API 30 and above.

[0]https://developer.android.com/reference/android/view/WindowInsetsController#show(int)
[1]https://developer.android.com/reference/android/view/WindowInsetsController#hide(int)

Task-number: QTBUG-98984
Pick-to: 6.10 6.9 6.8
Change-Id: Icfcad3430cd269353572f66f72114238045f7756
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-06-10 15:28:31 +02:00
Fabian Kosmale
f1c0bd2e06 QStringConverter: Introduce finalize()
When doing a streaming conversion, it is not enough to check whether
there are errors. Once all input has been consumed, one must also check
whether there has been any data that was consumed, but not converted
yet. Provide finalize() to do the check, set an error if there was
incomplete data, and to optionally write replacement characters for it
to an output buffer.

[ChangeLog][QtCore][QStringDecoder] Added finalize(), a function to
force the converter to consider the sequence of inputs as complete,
flushing potential partial character sequences.

[ChangeLog][QtCore][QStringEncoder] Added finalize(), a function to
force the converter to consider the sequence of inputs as complete,
flushing potential partial character sequences or restoring state for
stateful text encodings.

Change-Id: I5fe26ae8e5d1477a86b365cc49c430b057876893
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-06-10 15:28:31 +02:00
David Boddie
479fb822bf Doc: Fix links in see also documentation
Pick-to: 6.9 6.10
Change-Id: Ie2b6964550ea166def27de311c2b948afba5bf04
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-06-10 15:28:31 +02:00
Laszlo Agocs
619ea08036 rhi: d3d: Change a warning to categorized logging
It is not that important to warn about the DXGI factory being stale
when a screen gets connected or disconnected. It is not an error,
and happens every time if a screen gets added or removed while the
application is running.

Pick-to: 6.10 6.9 6.8
Change-Id: I414668dc7aa0279f63fc79799ea53101065ab013
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-06-10 10:23:48 +02:00
Marc Mutz
8f4ffb72f9 QEventLoop: fix potential UB in QBasicAtomic initialization
Until C++17 (inclusive), a default-constructed std::atomic object can,
officially, only be initialized with a call to std::atomic_init, for
which QBasicAtomic doesn't have API. It is even unclear whether
zero-initialization of static and thread-local objects will cause the
object to be initialized.

To fix, port from QBasicAtomic to QAtomic (which initializes to zero).

Task-number: QTBUG-137465
Pick-to: 6.10 6.9 6.8 6.5
Change-Id: I31a95b36506c376ef0817ef3d61bd8ca02371585
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-09 20:36:40 +00:00
Marc Mutz
49db71bb19 QContiguousCache: drag the initialization of atomic ref behind ABI boundary
All callers of QContiguousCache<T>::allocateData() followed the call
with a storeRelaxed(1) to the ref member. So we can just drag that
into the function itself.

Next, it's UB to storeRelaxed() into a default-constructed std::atomic
(and, therefore, into a QBasicAtomicInt), because until C++17
(inclusive) you're supposed to use std::atomic_init to assign the
first (and only the first) value to a default-constructed
std::atomic. QBasicAtomic doesn't have API for that, so you can never
assign anything to a default-constructed QBasicAtomic.

To fix, use placement new to be able to create a QBasicAtomic directly
with an initial value (replacing QBasicAtomic with QAtomic wouldn't
help here, either, since a malloc doesn't run ctors).

A proper fix has to wait until we can depend on C++20's atomic_ref,
which decouples the underlying type from the atomic operations
performed on it, letting us depend on malloc's zero-initialization
of an int member properly initializing it even for a following atomic
operation on it.

Task-number: QTBUG-137465
Pick-to: 6.10 6.9 6.8 6.5
Change-Id: Ic22d0766bcffb967a86c8ec28b63ee480aebd4a0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-09 20:36:21 +00:00
Christian Ehrlicher
4896448ffd SQL/ODBC: misc cleanup
Misc cleanup
 - merge qGetIntData and qGetBigIntData
 - remove unused braces
 - properly initialize values

Pick-to: 6.10
Change-Id: I0867dbbfa611087cd470b821f1f8d7ed74ed0aae
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-06-09 20:33:57 +02:00
Lars Schmertmann
ce101c2c3c Android: Unify behavior of Accessible.description with other platforms
On Windows, macOS and iOS both text and description are read out. On
Android the description is only used, when there is no name/text and
the result is used in AccessibilityNodeInfo::setContentDescription
while AccessibilityNodeInfo::setText is ignored. Using the content
description only is right, because Android will prioritize description
over text. So we need to do our own concatenation to use both.
Using ", " as separator looks like the right way, because Android use
it to separate the text from the role too. This was checked by enabling
TalkBack settings -> Advanced settings -> Developer settings -> Display
speech output.

Fixes: QTBUG-128494
Pick-to: 6.10
Change-Id: Ib25e993ffc8614b9c9ccdc37207f2c3c496ecb1f
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-06-09 17:58:21 +00:00
Marc Mutz
231069963d QLogging: fix potential UB in QBasicAtomic initialization
Until C++17 (inclusive), a default-constructed std::atomic object can,
officially, only be initialized with a call to std::atomic_init, for
which QBasicAtomic doesn't have API. It is even unclear whether
zero-initialization of static and thread-local objects will cause the
object to be initialized.

But initialization with = {} is definitely fishy, because that, by
definition, invokes the problematic default constructor. So make the
initialization explict with Q_BASIC_ATOMIC_INITIALIZER(0) instead.

Amends 4a154170773199f5b3376496c7b1a1c4530744e9.

Task-number: QTBUG-137465
Pick-to: 6.10
Change-Id: I177e05c09e20e0830af7bf1ccb650afc860ab9d5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-09 15:18:23 +02:00
Marc Mutz
0ba05ca500 [docs] IPC: don't mention undoc'ed QBasicAtomic
Use Q(non-Basic)Atomic instead.

Amends 7a370838177e581c8a9342808ba86e081951a41c.

Task-number: QTBUG-55421
Pick-to: 6.10 6.9 6.8
Change-Id: Ia8cc059a94acbee667c19b443ed2e2f487b56806
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-09 14:55:09 +02:00
Christian Ehrlicher
bac0226ac3 SQLite: Update SQLite to v3.50.1
[ChangeLog][Third-Party Code] Updated SQLite to v3.50.1

Pick-to: 5.15 6.5 6.8 6.9 6.9.1 6.10
Change-Id: I238e95f3e028731aa871e279f21503d39acdbd2d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-06-09 12:41:19 +02:00
Christian Ehrlicher
ccf81822cf SQL/DB2 & ODBC: avoid some code duplication
Avoid some code duplication by using a template parameter for
qMakeError() and qSqlWarning().

Pick-to: 6.10
Change-Id: I698ab063fce6c7be1cb3debdb9e83978eac10409
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-06-09 12:41:19 +02:00
Assam Boudjelthia
2b4effeec8 Revert "Android: qtbase/src/android/. ./QtAndroidBinder.java security sensitive"
This reverts commit 7796ad3face5246ad62a959b61fdd3a92cea2803.

Reason for revert: the code is not doing critical data parsing.

Pick-to: 6.10 6.9 6.8
Change-Id: Ic07b98c3866b65d0575e29abe97ca6b284c981bb
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-06-09 06:47:48 +00:00
Dheerendra Purohit
b52c0dafd8 Doc: Modernize QSharedDataPointer Example for Rule of Compliance
Replaced the manually defined copy constructor with = default to
improve clarity and maintainability.Added a default copy assignment
operator to ensure consistency,as copy constructor and copy
assignment should be defined as a pair.Also included defaulted move
constructor and move assignment operator in accordance with the rule
of 6,ensuring the example is modern,complete,and suitable for
educational purposes.

Fixes: QTBUG-111392
Change-Id: Ia7cfccfc46182d8d9102868fc93dc0ebd9649a32
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-06-08 16:56:07 +00:00
Dheerendra Purohit
045eb2179c Doc: Improve opening description of Qt's Paint System
Clarified the Paint System introduction to better convey
its purpose and highlight its flexibility across different surfaces.

Fixes: QTBUG-136487
Change-Id: Ib636087b9bae4d08541566145c4a0943dccb5432
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-06-08 22:25:47 +05:30
Christian Ehrlicher
d2cd406b34 SQL/ODBC: fix escaping the username/password
The escaping for '{' was wrong in the previous commit.

Amends 38277a88f1dd69de6e031bc8313c8d5beadf6bd0

Pick-to: 6.8 6.9 6.10
Task-number: QTBUG-122642
Change-Id: Ia363c76b27e527114769b4a923418cddad5586f1
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-06-08 07:36:11 +00:00
Allan Sandfeld Jensen
51d5b9e258 SSE2 optimize QColorSpace CLUT
Optimize clamping setup for CLUT lookup.

Pick-to: 6.10 6.9
Change-Id: I35d65fc00efcb96a54518466e1e1de169571b862
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-07 17:15:43 +02:00
Marc Mutz
a97ac8507e tst_QMetaObject: add a reproducer for overly eager QVector/QList replacement
The kludge that was added to argumentTypesFromString() for Qt 6 to
support merging QVector into QList—specifically, the replacement of
QVector< with QList<—was unfortunately not removed before the Qt 6.0
release. As a kludge, it has unintended consequences, as Thiago
pointed out in a comment on a related patch.

This change adds a reproducer that demonstrates cases where the
kludge causes correct code to fail incorrectly. We need this test to
ensure that we do not silently change behavior when deprecating and
eventually removing the kludge.

Adapt the MyQList normalization test, which was carefully written to
avoid hitting the kludge, to use template arguments. This will allow
it to trigger the buggy code path and avoid confusing the reader with
the mention of a non-template MyQList, given that MyQList is now a
template.

Reported-by: Thiago Macieira <thiago.macieira@intel.com>
Pick-to: 6.10 6.9 6.8 6.5
Task-number: QTBUG-135572
Change-Id: I91d769d494489fe63dbbb67f849b78fc7aa39ec6
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-06-06 22:16:36 +02:00
Michael Weghorn
99ad6a51a5 a11y atspi: Warn on unimplemented Application iface method
As already happens in the implementation for the
handling of all other AT-SPI interfaces
(called from AtSpiAdaptor::handleMessage), also
warn when an unimplemented/unknown method gets called
for the Application interface: increase log level
to warn and align message with the one used for
the other interfaces, so this can be more easily
identified.

Task-number: QTBUG-137344
Pick-to: 6.10
Change-Id: I33d3811fd34ca0f9f4b1ab9d809f505c12c6517c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-06-06 18:04:35 +00:00
Mårten Nordheim
1a870f4bf2 tst_QHttp2Connection: fix typo of tested variable
Accidentally used clientStream instead of clientStream2.
Test still passes though.

Pick-to: 6.10 6.9
Change-Id: I118f1e429faa0367f0b4d02c74a221027ecb2b4d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-06-06 19:06:04 +02:00
Marc Mutz
ab7c1386d5 QTestResult: remove unused QTestResultPrivate forward declaration
This class was never pimpled in Qt 5.

Amends the start of the public history.

Pick-to: 6.10 6.9 6.8 6.5
Change-Id: I5761bb0e8401dd654a885b5edcf821be9e4c2694
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-06-06 19:06:03 +02:00
Tor Arne Vestbø
965b799c3f Decouple QApplication from QColormap
Initialize the shared QColormapPrivate on first call to
QColormap::instance, in a thread safe manner for good measure,
and clean it up on app exit if needed.

The cleanup now also accounts for the possibility of QColormap
instances outliving the cleanup. We still reset to a new QColormap
on next use, following the existing behavior.

Change-Id: Ia16a84994b3ee05f9431ba24dd9126f2dc271b61
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2025-06-06 18:10:07 +02:00
Laszlo Agocs
a589ef5cff Revert "rhi: gl: Maintain Qt 5 compat wrt disk cache behavior"
This reverts commit 38279dea558b06cef6c1d345962df3063fd12c5b.

Causes endless complaints about old GPUs (e.g. PowerVR) on Android and
embedded Linux.

Qt 6.8.2 restored the Qt 5 behavior of writing program binaries to files
every time a GL shader program is linked. That is in addition to the Qt
6 pipeline cache, which writes out all collected program binaries once
in one go, when the QQuickWindow is closing.

The Qt 6 abstractions are modeled after the VkPipelineCache-style
system, meaning no way to query and write out individual
program/pipleline binaries, just an ever-growing blob containing
everything encountered so far, which we then want to do rarely due to
the potential cost and the size of the blob, so e.g. when the Quick
scene is shutting down.

Before 6.8.2, Qt 6 did the logical thing and disabled the Qt 5 legacy GL
disk cache code path, since we do not need two caches concurrently. From
6.8.2 on, when running with OpenGL, there are now two parallel disk
caches. Because the Qt 5 style one works even if the application is
killed. Which is unexpectedly common on mobile/embedded.

Pick-to: 6.10 6.9 6.8
Fixes: QTBUG-133904
Fixes: QTBUG-134245
Fixes: QTBUG-134089
Fixes: QTBUG-135411
Fixes: QTBUG-134496
Fixes: QTBUG-135810
Change-Id: Icbd880898941195fcbc2da544e1599867c6d5f51
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-06-06 14:52:39 +00:00
Eskil Abrahamsen Blomfeldt
fb89d498a9 Add support for font features and variable axes to QTextCharFormat
These can be set on the font directly, but had not been added to
QTextCharFormat, so there would be no way to override them by
formatting in a rich text document.

Fixes: QTBUG-134060
Change-Id: I4494e24cb9b99d84fb376ba895e2461fc3cd054b
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-06-06 16:27:54 +02:00
Alexandru Croitor
9b9a2398f3 CMake: Make QT_CMAKE_EXPORT_NAMESPACE available in the top-level scope
Previously QT_CMAKE_EXPORT_NAMESPACE was set by calling
find_package(QtBuildInternals) at repo dir scope, even in a top-level
build.

Starting with ddcafa0a51c65d86f6b5481f06fce5faeb75920d in
qtdeclarative, we now have a deferred call of
_qt_internal_write_deferred_qmlls_build_ini_file in the
CMAKE_BINARY_DIR scope, which lacks the QT_CMAKE_EXPORT_NAMESPACE
variable.
This caused errors in a top-level standalone tests build:
  Error evaluating generator expression $
    No target "::qtpaths"
    CMakeLists.txt:DEFERRED

To avoid the error we now set QT_CMAKE_EXPORT_NAMESPACE in the
top level scope.

To avoid duplicating the code into the QtBaseTopLevelHelpers,
we extract the qt_internal_top_level_setup_cmake_and_export_namespace
function into a new QtBuildInternalsHelpers.cmake file, which is
included by both QtBaseTopLevelHelpers.cmake and
QtBuildInternalsConfig.cmake.

We also copy and install that file.

This has less side effects than trying to call
find_package(QtBuildInternals) in the top-level scope.

Pick-to: 6.10
Change-Id: I8e54e21d3f07ee86860cad49d6e43e0fdefbcee3
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-06-06 16:27:54 +02:00
Alexandru Croitor
587649deb7 CMake: Make qt-cmake-standalone-tests work from prefix build dir
We didn't copy the standalone test template files into the build dir
when configuring a prefix build.

We also need to copy the mkspecs.

Pick-to: 6.8 6.9 6.10
Change-Id: I517165b2b8db84b0766935e3d535a7a1ef2b6ad9
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-06-06 16:27:54 +02:00
David Edmundson
1ede87a735 wayland: Add unit test for sibling client grabbing popups being created
Task-number: QTBUG-119110
Change-Id: Ie31da8073d0107f6515ce2e0152cb2bbc97c8582
Reviewed-by: David Redondo <qt@david-redondo.de>
2025-06-06 15:13:15 +03:00
Nic Zonta
25fdc044f5 make all convenience functions in QFileDialog open modal dialogs
most convenience functions in qfiledialog.cpp (e.g. getSaveFileUrl, getOpenFileUrl) open modal dialogs, with the exception of getOpenFileContent and saveFileContent. This makes every function consistently open modal dialogs

Fixes: QTBUG-137329
Pick-to: 6.10 6.9
Change-Id: I48952144ed15596b9acba3230c63cece613fb045
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-06-06 13:20:27 +02:00
Axel Spoerl
839d569dc2 QCommandLinkButton: Don't reset icon on change to QStyleSheetStyle
d4c518b210ad56cb51c17e6e1b4a81b0deb7253c has implemented a reset of the
icon on a style change.

This has caused a regression, because it overrode an icon set by a
style sheet.

Do not reset the icon if the new style is a QStyleSheetStyle.

Amdends d4c518b210ad56cb51c17e6e1b4a81b0deb7253c.

Fixes: QTBUG-137011
Pick-to: 6.10 6.9 6.8
Change-Id: Ib77faa03c867b2660a45bdc3ab94e7d739eed4f8
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-06-06 06:26:13 +02:00
Santhosh Kumar
2e0dc22bdb Fix regression in drawing table cell border when border-collapse enabled
The patch 732962d604e7469f9a9f02fe0cd3d1fd04caddb8 enables drawing a
border around cells within the table when set through CSS styling. But
this caused a regression when border-collapse is enabled without setting
the cell border. This patch enables drawing borders for table cells
when either of those conditions is satisfied.

Fixes: QTBUG-136590
Pick-to: 6.10 6.9 6.8
Change-Id: Ibf43c404439c9fee1cfd2b40789150edb76c6971
Reviewed-by: Nils Jeisecke <nils.jeisecke@saltation.com>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-06-05 23:58:00 +02:00
Friedemann Kleint
38ce4ad2f8 QColorDialog: Stop color picking when application is deactivated
Fixes: QTBUG-134143
Pick-to: 6.10
Change-Id: Ibfeff4f861ac5c63f4bdd85db40b25eee51c4d31
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-06-05 23:58:00 +02:00
Thiago Macieira
4e57583f33 Wayland tests: use initTestCase() instead of init() to set env
Once is fine. We don't need to set the environment before each test
function.

Pick-to: 6.10
Change-Id: Id27938950c196d6d3397fffd2fbf1a66fe7504f9
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: David Redondo <qt@david-redondo.de>
2025-06-05 17:15:28 -03:00
Marc Mutz
687fb92440 tst_QMetaObject: refactor indexOfMethod() test
Removes duplication in preparation of adding more tests.

Pick-to: 6.10 6.9 6.8 6.5
Task-number: QTBUG-135572
Change-Id: I9ebfc40e24256d2d92af3f593f905d97b273e187
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-05 21:26:02 +02:00
Konsta Alajärvi
fd52f868ac CRA: Android: Mark QtLoader.java as security critical
Mark QtLoader as critical with "execute-external-code" due to
library loading in:
-loadQtLibraries()
-loadLibraryHelper()
-loadMainLibrary()
-loadLibraries()
QtLoader also parses library paths in:
-parseNativeLibrariesDir()

Fixes: QTBUG-136726
Task-number: QTBUG-135178
Pick-to: 6.10 6.9 6.8
Change-Id: I58a11fd44ea8159b8399ac7a27fd50eaab8185a6
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-06-05 14:42:45 +00:00
Konsta Alajärvi
0a4c11633b CRA: Android: Mark qtandroidplatformfiledialoghelper.cpp as security critical
Mark qtandroidplatformfiledialoghelper.cpp as security critical with
"data-parsing" as a reason.

Data parsing in nameFilterExtensions() using QRegularExpression.

Fixes: QTBUG-136820
Task-number: QTBUG-135178
Pick-to: 6.10 6.9 6.8
Change-Id: I378698327a36496317782d6dc0acd092c19de7ca
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-06-05 14:42:45 +00:00
Ivan Solovev
5b03d9f68b QProperty: fix comparison with comparable type
After e115c60b6da0db7013229e678720f36632c2e614, the comparison with
a type which is different from QProperty::value_type, but is comparable
to it, could result in ambiguous operator==() overloads.

Fix it by adding a new overload for operator==(QProperty<T>, U), where
operator==(T, U) exists.

Explicitly delete operator==(QProperty<T>, QProperty<U>) for such
types T and U, because the implicit conversion might be unwanted here.
The user should manually call .value() at least on one property, if
they want the comparison. Note that GCC does not allow to do it,
treating `= delete` as declaration and complaining about a default
template argument in friend template declaration. So, do it only for
Clang and MSVC.

Amends e115c60b6da0db7013229e678720f36632c2e614.

Task-number: QTBUG-134921
Pick-to: 6.10
Change-Id: Id3ed48738cc462b5b0820fa3b25d80d4d4414548
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-06-05 16:42:43 +02:00
Eskil Abrahamsen Blomfeldt
9a950b1ecb Add an envvar restoring Qt 5 behavior for vertical font metrics
As a last resort for users who have existing Qt 5 applications and
see differences in line metrics when porting to Qt 6, we introduce
an environment variable which lets them restore the old behavior
as a last resort.

This is primarily meant as a porting tool, since we do have other
tools, such as QFont::PreferTypoLineMetrics to work around issues
with fonts that by mistake do not explicitly set the
use-typo-metrics flag even if these are valid.

Pick-to: 6.8 6.9 6.10
Fixes: QTBUG-134602
Change-Id: Id1d7829888d55247d2f07ee0a49b91ff34f26889
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-06-05 13:58:49 +00:00
Tor Arne Vestbø
c604f2031a iOS: Always update screen properties on status bar orientation change
If we move from landscape to inverse landscape orientation, the window
will not lay out, so we won't hit viewWillLayoutSubviews, but we still
need to reflect the new orientation of the screen.

Task-number: QTBUG-137249
Pick-to: 6.10 6.9 6.8
Change-Id: I9655052772990ca524c5b94e25b2c58cc058ff67
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2025-06-05 14:37:54 +02:00
Tor Arne Vestbø
a8dab6eb65 iOS: Report inverted screen orientations via windowScene orientation
In bc014d5fc705e95bb34b7729b2c3bb5f9539d777 we stopped using the device
orientation as source for the QScreen orientation, as the former reports
the orientation independently of any locked orientation, while QScreen
is supposed to reflect the logical window-manager orientation.

However in doing that we lost the inverse orientations, which can be
useful in some cases.

We now use UIWindowScene.interfaceOrientation as input, and fall back
to the primary orientation only if we can't resolve the window scene's
orientation.

Interestingly, for visionOS, UIWindowScene.interfaceOrientation reports
portrait orientation, which should be investigated further, but for now
we trust what the system gives us.

[ChangeLog][iOS] QScreen::orientation() now reflects the inverse
portrait and landscape orientations, as long as system allows
rotating the UI to those orientations.

Fixes: QTBUG-137249
Pick-to: 6.10 6.9 6.8
Change-Id: I8d20f05e72abcec446fd39342c8632960337943a
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Doris Verria <doris.verria@qt.io>
2025-06-05 14:37:54 +02:00
Piotr Wiercinski
5618710d63 fusion: Improve visibility of Checkbox in dark mode
Fixes: QTBUG-136960
Pick-to: 6.8 6.9 6.10
Change-Id: I606fd034ba83011624ff9a38a8c973659c241c26
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
2025-06-05 12:37:54 +00:00
Volker Hilsheimer
9b9511c354 QTreeView: Delay reset of accessibility when laying out items lazily
QTreeViewPrivate::doItemsLayout might get triggered when accessibility
elements query properties of items, such as the state or geometry. If we
reset the model immediately, then the items that are currently querying
might get destroyed, resulting in crashes.

Instead, use a queued invocation to reset the model only once control
returned to the event queue. This leaves current elements intact.

Amends 6a4afebc5ce8db69a6c9fb398cada31e6bad5e3c and follow-up commit
a86321cb665b1af03b245b3b0fe0b57faa4a678f.

Pick-to: 6.10 6.9 6.8
Fixes: QTBUG-136074
Task-number: QTBUG-133855
Change-Id: I2c6acda3b31105447393a6efcb85ddf737161fe8
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-06-05 08:41:39 +02:00
Oliver Eftevaag
4720b592d7 Windowsvista style: Fix hover widget attribute when using contrast theme
The windows vista style sets the widget attribute for certain widgets to
have the Qt::WA_Hover attribute, which makes the widget eligible for
receiving hover events from QApplication::notify(QObject*, QEvent*).

However, if the windows system had enabled a high contrast theme,
the QWindowsVistaStyle::polish(QWidget*) function would return early,
without making any widgets eligible for receiving hover events.

Fix the issue by enabling hover events for select controls first,
before potentially returning early due to using a contrast theme.

Pick-to: 6.10 6.9 6.8
Change-Id: I5562f46385c6f1b498bc659c65e501f9e9376db3
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2025-06-05 02:47:23 +02:00
Jani Heikkinen
7f1e6f8079 Bump version to 6.11.0
Change-Id: I14ec3a08bf704535b9b10e33ec8ee0f9415f2d7c
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-06-05 00:07:53 +01:00
Marc Mutz
5c563a98a5 tst_QMetaObject: add more QList/QVector tests
Check that a slot that was declared using QVector ends up stored as,
and can be called with, QList (and QVector).

Also check that the various indexOf*() methods do the QVector</QList<
normalization, even though they're documented to require normalized
input. A subsequent patch will deprecate that behavior, so make sure
we don't break it as we change it.

Amends 1fa31be7ce3a6899f1c1597311d7593648ecd1d8.

Pick-to: 6.10 6.9 6.8 6.5
Task-number: QTBUG-135572
Change-Id: Id28bf3c4163099f07213bfbf7d296b4fd76b71a5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-06-04 23:22:45 +02:00
Marc Mutz
e51675b891 QWaylandGLContext: init fields in default ctor
Coverity complains that the =default'ed default ctor leaves
m_decorationsContext and m_api uninitialized, which is true.

To fix, use NSDMI for the former.

For m_api, initialize it in the default constructor's member
initializer list, because the default value is closely related to the
other constructor's choice of value¹, and so should be more proximal
to the other constructor's initialization of m_api (which is
dynamic). Using NSDMI for m_api would also remove tooling's ability to
detect faults in the other constructor.

¹ I had to track into QSurfaceFormat to verify which of the possible
  values is the correct one (= the one that gets mapped from
  DefaultSurfaceFormat by the switch in the other QWaylandGLContext
  ctor).

Amends 7c0a96785fee4fea8ef1452166b1dde88957445c.

Pick-to: 6.10
Task-number: QTBUG-110758
Coverity-Id: 481857
Change-Id: I837d0a3a63bd6e2948ef1c9757e250bfba7dd957
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-06-04 23:22:45 +02:00
Bartlomiej Moskal
a4850d0e0f Android: Avoid restarting InputMethodManager during IME batch edits
beginBatchEdit() means the start of a batch of related input operations
from the Input Method Editor. We should not restart input until
endBatchEdit() is called. Restarting it before may cause issue with
inactive InputConnection.

This commit fixes an issue where calling
InputMethodManager.restartInput() during a batch edit (e.g., between
beginBatchEdit and endBatchEdit).

Pick-to: 6.10 6.9 6.8
Fixes: QTBUG-136229
Change-Id: I408e6dfd8a91f2d0f1dd8c18dc0dcc2d13cc3e38
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-06-04 19:24:38 +00:00
Alexandru Croitor
86d843be47 CMake: Improve atmoicfptr error message on failure
Remove the obsolete reference to the atomicfptr directory in the error
message.

With the improved error reporting of the parent change, the build
system will now dump the output of the atomicfptr test in case of
failure, which should provide more information about what goes wrong.

Pick-to: 6.8 6.9 6.10
Fixes: QTBUG-133687
Change-Id: Iaffc992f90c06425113cc2ef721d87d31e97bbc6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-04 19:08:14 +02:00
Alexandru Croitor
5220685a11 CMake: Fix capturing of x86intrin compile test output
TEST_x86intrin_OUTPUT is not set anymore since we lazily evaluate
compile tests after 605913f9d7a60461939c1a8fb8dac05054cade2d .

Use the new qt_configure_add_report_entry
COMPILE_TESTS_TO_SHOW_ON_ERROR option to dump the test values in case
of an error.

Amends 9e9099865a0881ac5bb6035237e0a0c86962c45f

Pick-to: 6.8 6.9 6.10
Task-number: QTBUG-122596
Change-Id: I48d1c57145ad5d9418631025927581c4eb5ec93c
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-04 19:08:14 +02:00
Alexandru Croitor
a20a40095a CMake: Improve compile test error reporting in configure summary
Starting with 605913f9d7a60461939c1a8fb8dac05054cade2d we run
configure.cmake compile tests lazily during feature evaluation.

This means that qt_config_compile_test() calls will no longer set
TEST_foo_OUTPUT variables in the scope of configure.cmake files and
thus the build output of compile tests is no longer available for
configure summary error reports.

Instead of setting the output variable in the caller scope, save the
output in a global property.

Then, when we add error reports that mention compile tests either in
CONDITION or in a newly introduced COMPILE_TESTS_TO_SHOW_ON_ERROR
option, dump those outputs in the error report.

We continue to set the output in the parent scope, in case if
qt_run_config_compile_test is called manually.

Amends 3334a77ecfb792fba0144e99887f11cd0fa2506d
Amends 605913f9d7a60461939c1a8fb8dac05054cade2d

Pick-to: 6.8 6.9 6.10
Fixes: QTBUG-137198
Change-Id: Idc0470556a053123286983c44063e17b7eb9949d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-06-04 19:08:13 +02:00
Alexandru Croitor
7542aaea60 CMake: Improve error reporting for failed linker no undefined flag
Capture the output of the check_cxx_source_compiles calls in
qt_internal_add_link_flags_no_undefined like we do for
qt_config_compile_test.

Amends 3334a77ecfb792fba0144e99887f11cd0fa2506d

Pick-to: 6.8 6.9 6.10
Task-number: QTBUG-137198
Change-Id: Ic7dd4eae0ac1af0f8293f2ce285d2987e4e26249
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-06-04 19:08:13 +02:00
Magdalena Stojek
e94a951862 Mark qtbase/src/corelib/plugin files as security-critical
- quuid.cpp parses the string representation of a UUID
- qfactoryloader.cpp parses metadata from loaded plugin
- qcoffpeparser.cpp, qelfparser_p.cpp and qmachparser.cpp as they are
  binary object files parsers
- qlibrary.cpp, qlibrary_unix.cpp, qlibrary_win.cpp, qpluginloader.cpp
  are responsible for finding and loading plugins from untrusted
  locations.

Fixes: QTBUG-135193
Change-Id: Ibbcefeab80e7455225ade620bdba45dbc592c581
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
2025-06-04 19:08:13 +02:00
Edward Welbourne
a34195508a Fix WASM build for the recent qtestcrashhandler changes
Amends commit fddb6fceaa28df2a24f7bdd216792985bf8141d1 - the code in
qtestcrashhandler_unix.cpp is written to compile for WASM, and some
declarations in the _p.h aren't excluded on WASM, so the exclusion of
the .cpp when WASM lacks threads lead to linker errors.

Pick-to: 6.10
Change-Id: Idb941643302ed5a4c084d0fd2b4dfc07a44122e3
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
2025-06-04 16:30:32 +02:00
Edward Welbourne
9be6e51a50 Update QJsonValue(qint64) docs to reflect full precision
Amends commit 35adb74ddd915831789f0175423660f8e898942e (from 5.15) to
reflect the improved precision of 64-bit int when stored as a JSON
value.

Task-number: QTBUG-28560
Pick-to: 6.10 6.9 6.8 6.5
Change-Id: I07915bc190dd7696e58356143e8857f91e888c67
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-04 16:30:32 +02:00
Edward Welbourne
65365e9bb7 Fix typo in qlocale_tools_p.h unicodeForDigit() comment
Got the name of the numeric tokenizer helper wrong, making the
cross-reference comment misleading.

Pick-to: 6.10 6.9 6.8
Change-Id: I88b850975aa77b6175e8d95afa2960e589c42d8d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-04 16:30:31 +02:00
Tor Arne Vestbø
4d4843df42 Document QT_WARN_DEPRECATED_UP_TO
The default value is 0x070000, via qtdeprecationdefinitions.h

Pick-to: 6.10 6.9 6.8
Change-Id: I78586231e123321a11d41ec8c1324ab928e5fdc8
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-06-04 14:07:07 +02:00
Eskil Abrahamsen Blomfeldt
2d82e845cc Revert "dwrite: Support additional font names for system fonts"
This reverts commit 6854ea63365ae419a04a470eb17e5f7662f00931.

This caused errors in a Qt Declarative test. It's possible the test
is depending on assumptions that are not strictly true (such as
QFontDatabase::styles() never returning an empty list), but it's
a surprising side effect and should be investigated. So we revert
until it can be addressed.

Pick-to: 6.10 6.9 6.8
Reopens: QTBUG-135817
Fixes: QTBUG-137398
Change-Id: I2e673b316f3d5fc14342b36095f9983ad55ea796
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2025-06-04 14:07:07 +02:00
Eirik Aavitsland
472306523a Doc: Explicitly advise adding svg, if any, before other files to QIcon
Adding in the wrong order yields a QIcon that does not provide the
expected or desired behavior.

Fixes: QTBUG-135652
Pick-to: 6.10 6.9 6.8
Change-Id: Ie1f6e50ee82ddaae8857b076c383ede20ab872df
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-06-04 09:18:44 +02:00
Li Changze
5ee2737d91 qdbus: add call GetConnectionCredentials interface
[ChangeLog][QtDBus][QDBusConnectionInterface] Added method serviceCredentials().
See <https://dbus.freedesktop.org/doc/dbus-specification.html>
section: 'Method: org.freedesktop.DBus.GetConnectionCredentials' for more information.

Pick-to: 6.10
Change-Id: If37687a35278fde8b0afc33eb19f9fa6b8dbe200
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-04 12:58:07 +08:00
Nils Petter Skålerud
cb09be1512 QScreen, iOS: Make grabWindow() use UIGraphicsImageRenderer
Currently the QIOSScreen::grabWindow implementaton relies on
UIGraphicsBeginImageContextWithOptions to do a screenshot. This API
is deprecated and produces a few warnings logs that we can't silence
even when we handle the errors. The current approach also has a memory
leak when taking screenshots in rapid succession (i.e 60 FPS).

This patch modifies grabWindow() to use UIGraphicsImageRenderer, which
replaces the deprecated API. This no longer produces warning logs when
errors are handled. This API can be used in the future to let us take
HDR screenshots once Qt has support for this. This patch solves the
mentioned memory leak.

Pick-to: 6.10 6.9 6.8
Change-Id: Ifbc8503482886246ce9611d0b7a19462fc830ecd
Reviewed-by: Tim Blechmann <tim.blechmann@qt.io>
2025-06-04 02:37:47 +02:00
Ahmad Samir
e67c4c986f QLogging: use std::unique_ptr instead of QScopedPointer
Task-number: QTBUG-132213
Change-Id: I6c5e72108e4ed79e645b8dbd9b2103e13e4849d0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-04 02:13:06 +03:00
David Edmundson
a639807a8f wayland: In test lock thread when setting env variables
putenv/setenv are not thread safe. The Qt wrappers lock a mutex
but this only works if all users use it.

Fixes: QTBUG-136450
Pick-to: 6.10
Change-Id: I9a46b5be607c84436864afcf7eb063275e065738
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-06-04 00:23:23 +03:00
Liang Qi
c72ba39e50 wayland: use qgenericunixtheme_p.h instead of qgenericunixthemes_p.h
This amends 54651971a260d65c987d03973168f7d274ed8930 .

Pick-to: 6.10
Change-Id: Iadeff9a59288934233bbf0f10d26510b5626b4f7
Reviewed-by: David Redondo <qt@david-redondo.de>
2025-06-03 23:23:22 +02:00
Christian Ehrlicher
a66dbb19e6 SQL/MySQL: add option MYSQL_OPT_SSL_VERIFY_SERVER_CERT
Add option MYSQL_OPT_SSL_VERIFY_SERVER_CERT to disable ssl for MySQL
5.7.x and MariaDB. This is needed as MariaDB does not support the
SSL_MODE options but defaults to ssl nowadays.
Also enhance the documentation for MYSQL_OPT_TLS_VERSION and
MYSQL_OPT_SSL_MODE by providing the needed MySQL/MariaDB versions for
those options.

Pick-to: 6.10 6.9 6.8
Fixes: QTBUG-136550
Change-Id: If570cf8e92d0df7c9e2c4d0e009857eaf33f4f2d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-06-03 19:39:50 +00:00
Christian Ehrlicher
cc6d78325b SQLite: Update SQLite to v3.50.0
[ChangeLog][Third-Party Code] Updated SQLite to v3.50.0

Pick-to: 5.15 6.5 6.8 6.9 6.10
Change-Id: I20eef45bbb93ae3a50cdd7ffecaa53eec18823f7
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-06-03 19:39:50 +00:00
Christian Ehrlicher
15c2ec5344 QStyleSheetStyle: avoid creating QString
Don't create a QString when comparing the strings from
knownPseudoElements - a QLatin1StringView is enough.

Pick-to: 6.10 6.9
Change-Id: I69e207bac0fb3d3df12ae9d4bebc9cd30cde30de
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-06-03 21:39:50 +02:00
Tor Arne Vestbø
b02da5f04a Remove docs claiming QColormap is involved in mapping colors to display
Change-Id: Iebf949d91379fff903b229c631b97a3c8a9ad03a
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-06-03 21:07:34 +02:00
Tor Arne Vestbø
ecad0ca351 Decouple QColor from QColormap
They don't need to be BFFs.

Change-Id: I7017347b348bd8e63dfb5f664c95597f84190e7c
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-06-03 21:07:34 +02:00
Tor Arne Vestbø
c7625d14df Decouple QApplication::isEffectEnabled from QColormap
Change-Id: I26468cc528d2c516492db11ca4109e6be63c1b5a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2025-06-03 21:07:34 +02:00
Toni Saario
3056da6711 Coin: Sign cross-compiled Windows binaries
Pick-to: 6.8 6.9 6.10
Task-number: QTBUG-137228
Change-Id: Idda7bfd97ac74a87987dcd4c31440b0c2f193c14
Reviewed-by: Simo Fält <simo.falt@qt.io>
2025-06-03 19:07:34 +00:00
Axel Spoerl
36ebec92e8 QCocoaMenu: Explicitly remove NSMenu from supermenu on destruction
The d'tor of QCocoaMenu calls dismiss() to remove the current menu.
dismiss() calls cancelTracking, which doesn't always remove the
menu from its parent.

Remove the menu from its parent in addition.

Fixes: QTBUG-135634
Pick-to: 6.10 6.9 6.8 6.5
Change-Id: Ic8e9b4172c3b2035b7e9ad1b576725923987abf2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-06-03 18:56:07 +00:00
Michael Weghorn
77f02471ed a11y atspi: Create local variable on stack
There is no reason to allocate the OrgA11yAtspiSocketInterface
object only used inside AtSpiAdaptor::registerApplication on
the heap.

Pick-to: 6.10
Change-Id: I2985acb5bd3e2f89c60de2b4ffa77b2a78cb4eff
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-06-03 18:56:07 +00:00
Lars Schmertmann
36b5854af5 Android: Bump androix dependency to 1.16.0
The Android target API level was bumped to 35 in
997a1fae98d35cd0d4d16f37ab68afe2729ff551 so we can
bumb the version of the androidx dependency too.

Pick-to: 6.10 6.9 6.8
Change-Id: I30d561cc0b74645c939e7d3dd595926b6013caf9
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-06-03 19:55:47 +02:00
Marc Mutz
c485c07c6d Explain what "junk" means in tst_QDataStream::status_QBitArray_data()
It means the data contains bits outside the [0, size()[ range.

Found while debugging why these data rows fail in the 5.15 cherry-pick
of 78f8dfc5427457783ceef7d85885cddbec035ebe.

Amends the start of the public history.

Pick-to: 6.10 6.9 6.8 6.5 5.15
Change-Id: Ic21d15da25944d4897357dd27e2986d448b5ee60
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-06-03 17:13:55 +00:00
Thiago Macieira
ae973dc2de QFileSystemEngine::tempPath: simplify handling of fallbacks
If the environment variable is empty, we have a couple of fallbacks, one
for Apple Darwin systems and one for everyone else. A non-absolute path
in the environment or the Apple API makes no sense, but this code
retains this defensive measure for them; for _PATH_TMP from <paths.h>,
we assume it is absolute.

Pick-to: 6.10 6.9
Change-Id: I3e486f73276a3ae288d1fffdbfe20a74271f73f2
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-06-03 11:54:38 +00:00
Thiago Macieira
7bd7df5aa1 QFileSystemEngine::tempPath: bypass QDir and go straight to QFSEngine
Temporary paths coming from the environment must be real filesystem
things, never a Qt file engine, so we don't need to create QDir with its
QDirPrivate, in order to call QFileSystemEngine.

The replacing of canonicalPath() with QFSE::absoluteName() is fine
because canonicalizing *after* cleanPath() is the wrong thing. For
example, if you had:

  $ ln -s $HOME/tmp /tmp/symlink
  $ TMPDIR=/tmp/symlink/..
then
  cleanPath($TMPDIR) = /tmp
  absolute($TMPDIR) = /tmp    # QFSE::absoluteName calls cleanPath
  canonical($TMPDIR) = $HOME
  canonical(cleanPath($TMPDIR)) = /tmp

The lack of canonicalization now only affects when the final path is a
symlink. Doing so bought us little security if it is a symlink and it
could change, because the result is not cached and could change from
call to call. That changing is probably worse than any attack, because
you could end up with

  QDir::tempPath() != QDir::tempPath()

[ChangeLog][QtCore][QDir] tempPath() may now return a non-canonical
path. This means going up from it (cdUp()) may result in different paths
from string manipulation (adding "/..").

Pick-to: 6.10 6.9
Change-Id: Iddf6f46edf6f3b6c3222fffd1e1e5479f0be92a9
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-06-03 11:54:37 +00:00
Jani Heikkinen
05f8abc61d Revert "Android: consider DecorView insets at app startup"
This reverts commit e96a4b84e136d065054600c07bf5fae17f3049ce.

Reason for revert: QTBUG-137306

Pick-to: 6.10 6.9
Change-Id: Id5718737f3f426de49ad109d214af1c920e5ae22
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-06-03 10:47:14 +00:00
Kai Köhne
95229bb7d0 Doc: Fix broken links in Qt Widgets
The iQRhiWidget API got changed in commits acebb97b5880,  acebb97b58807d1d591.

Pick-to: 6.8 6.9 6.10
Change-Id: I7791b1a61d94f33ba01cfe22e63ecfdc7b81022b
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-06-03 10:41:10 +00:00
Ilya Fedin
7c25b916dc xcb: mark xcb-image dependent on xcb-aux
Pick-to: 6.10 6.9 6.8 6.5
Fixes: QTBUG-86287
Fixes: QTBUG-137004
Change-Id: Ic4055078dedbbd8fcf1fba3983d6d64b7a06a20e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-06-03 10:41:10 +00:00
Liang Qi
ac2a38d80c Reapply: xcb: add xcb-util dependency for xcb-image
xcb-image includes xcb_aux.h, which is part of xcb-util.

0.3.8 is enough for the dependency, it also make Debian 10
(Buster) satisfied. xcb-image is from xcb-util-image, which
should follow same version number as xcb-util. Not sure how
Debian 10(Buster) got xcb-image 0.3.9 with xcb-util 0.3.8
combination.

See also https://lists.x.org/archives/xorg-announce/2012-May/date.html#1965 .

This reverts 92a57e0b016f811876ec1d62328ca8edfe452a3a .

Fixes: QTBUG-86287
Pick-to: 6.10 6.9 6.8 6.5
Change-Id: I838b1e06a25fa1e45470466de17cbb6b6da851a4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-06-03 10:41:10 +00:00
Jie Liu
1c87e9a60a wayland: fix image copy failed problem on data control
Change-Id: I20d26af8bdbf5f35ae78c984eb21e91f6fcc72b4
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-06-03 09:19:03 +00:00
David Edmundson
d687ac6d3e wayland: Drop unused member variable
The only mWaitingForUpdate is checked is to show a debug. The only
public way to call requestUpdate is via QWindow::requestUpdate which has
a guard already.

Change-Id: I542e0f470ec2134f0a9fd415aab6ac7832e77263
Reviewed-by: David Redondo <qt@david-redondo.de>
2025-06-03 12:19:03 +03:00
Michael Weghorn
5e7891f73f a11y atspi: Set correct child index in children-changed:add event
When sending an object:children-changed:add AT-SPI2 event,
set the actual index of the child instead of always using
the child count of its parent.

If the new child were added at the end, its index would be
"[child count] - 1", but the new child doesn't necessarily
have to have been added at the end.

Therefore, use the actual child index either already used as loop
variable or retrieved via QAccessibleInterface::indexOfChild
instead.

The mismatch could e.g. be demonstrated with a simple pyatspi
script when typing Enter in LibreOffice Writer to create
new paragraphs.

Script:

    #!/usr/bin/python3
    import pyatspi
    def listener(e):
        if not e.host_application.name.startswith('soffice'):
            return
        print(e)
        print(f'index in parent set in event: {e.detail1}')
        print(f'index in parent reported by child: {e.any_data.get_index_in_parent()}')
    pyatspi.Registry.registerEventListener(listener, "object:children-changed:add")
    pyatspi.Registry.start()

Sample output without this commit in place:

    object:children-changed:add(4, 0, [paragraph | ])
            source: [document frame | Untitled 1 - LibreOfficeDev Document]
            host_application: [application | soffice.bin]
            sender: [application | soffice.bin]
    index in parent set in event: 4
    index in parent reported by child: 2

Sample output with this commit in place:

    object:children-changed:add(2, 0, [paragraph | ])
            source: [document frame | Untitled 1 - LibreOfficeDev Document]
            host_application: [application | soffice.bin]
            sender: [application | soffice.bin]
    index in parent set in event: 2
    index in parent reported by child: 2

Pick-to: 6.10 6.9 6.8
Change-Id: I30316c59f8ad6fd018089a8dca8e7a8d1d92d7ec
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-06-03 05:34:43 +00:00
Christian Ehrlicher
e0130876ba QHeaderView: remove unused include, add missing include
Remove unused include of qtableview.h in the source - this also fixes
the compilation with feature_tableview = OFF.
Move the missing include of qlist.h into the header.

Pick-to: 6.10 6.9
Change-Id: Ie443cf6f3bf6b76dedc994bf1b8c16daebf9022d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-06-02 20:23:58 +00:00
Rami Potinkara
ea8f19f50b Android: don't disambiguate the convertToJni call with 'template'
There is no non-template overload of LocalFrame::convertToJni, and
clang 18 complains about an explicit .template without a template
argument list. We call convertToJni without either in other places, so
do so here as well.

Pick-to: 6.10
Fixes: QTBUG-136967
Change-Id: I2b4bbc8a4e2056bd2a8bff390ea0847f2e18202e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-06-02 20:23:54 +00:00
Michael Weghorn
6cca30bb11 a11y atspi: Support Application iface "AtspiVersion" property
As the AT-SPI XML spec for the Application interface says,
this should currently always be "2.1" [1]:

    <!--
        AtspiVersion: You should return "2.1" here.

        This was intended to be the version of the atspi interfaces
        that the application supports, but atspi will probably move to
        using versioned interface names instead.  Just return "2.1" here.
    -->
    <property name="AtspiVersion" type="s" access="read"/>

This makes the expected value show up in Accerciser with
pending merge request [2] in place instead of triggering a fallback
path in Accerciser handling the null case for Qt applications.

[1] 2d83e3a6df/xml/Application.xml (L19-26)
[2] https://gitlab.gnome.org/GNOME/accerciser/-/merge_requests/95

Pick-to: 6.9 6.10
Change-Id: I0d849d5d6d160c48fd4fc2d443e4fde43cde5606
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-06-02 20:23:54 +00:00
Christian Ehrlicher
db07a03874 StyleSheetStyle: Don't paint CE_ComboBoxLabel when no stylesheet is set
Don't paint through stylesheet code when a combobox label has no
stylesheet set at all.
This should be done also for others but may break existing painting
stuff so only fix this here as it's a regression from
a77a7c157d5cdcc88bf0a02caed2aa5ff8850d06.

Pick-to: 6.10 6.9 6.8
Task-number: QTBUG-131761
Fixes: QTBUG-137108
Change-Id: I462ba198821692aa60e6869df9c8e92332422c44
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-06-02 19:53:35 +00:00
Cristian Le
295b3ca5bd Deprecate FEATURE_regularexpression
There have been places where regex support has been implied and bootstrap
always builds with regex enabled. Therefore, disabling
`FEATURE_regularexpression` currently produces an error. Until a need
for building without regex emerges, we are enforcing it as a
requirement.

Users must either use system or bundled pcre2.

Fixes: QTBUG-136346
Change-Id: I9e92bb4e7f0dfb84884a2a23f45b20d18ddc8985
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-06-02 20:54:31 +02:00
Cristian Le
618053e279 Add feature deprecation capability
Emit a warning if `FEATURE_*` variable is set. The "feature" is not
registered as a true feature after deprecation.

Pick-to: 6.10 6.9 6.8
Change-Id: I715af231c228c73d70b037ee31aa61edcd45c21e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-06-02 20:54:31 +02:00
Cristian Le
11fab3d150 Display feature alias information in configure
Pick-to: 6.10 6.9 6.8
Change-Id: Ia7d054436ffcca64d6fecd363795e7439694b3f4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-06-02 20:54:31 +02:00
Joerg Bornemann
eaf87cdfd8 CMake: Add targets for building Android docs from Java sources
One can now run "ninja android_docs" to generate HTML docs for Android
Java sources of Qt. This is done with javadoc.

One can now run "ninja android_source_jars" to generate source jars for
Android. They're supposed to be loaded into an IDE.

The targets are enabled automatically for Android builds.
For non-Android builds, set QT_BUILD_HOST_JAVA_DOCS=ON to create those
targets. In that case you must also set ANDROID_SDK_ROOT.

Fixes: QTBUG-117028
Change-Id: I2df51153359a95870c055d3ee373b8381f10cb51
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2025-06-02 19:18:04 +02:00
Alexandru Croitor
89e7facc2e CMake: Fix location of iOS framework prl files
iOS prl files for static frameworks were previously placed at a path
like
  6.8.3/ios/lib/QtCore.framework/Versions/A/Resources/QtCore.prl

This caused qmake to silently fail to find iOS framework prl files.
The failure could only be seen when calling qmake with -d -d:

  DEBUG 2: QMakeMetaInfo: Cannot find info file for
    6.8.3/ios/lib/QtCore.framework/Resources/QtCore.prl

This in turn can lead to various build failures if a different non-iOS
prl file is found in a system path.

Place the prl file into the root of each framework, e.g. at
  6.8.3/ios/lib/QtCore.framework/QtCore.prl

We didn't have this issue in 6.7 and earlier, because by default iOS
was built with static libraries rather than static frameworks.

Amends 291817b0bf3f351843b0c1d0de237dc8df5c0fa5

Pick-to: 6.8 6.9 6.10
Fixes: QTBUG-137297
Change-Id: Idff8e808e9bfc009f82d2a59e5e6752ed8a55714
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-06-02 19:18:03 +02:00
Lars Schmertmann
577f9ebfe6 Android: Enable all warnings on javac for user code too
In addtion to 1cf03c974c433b7a5330b56bd9e519287fce6f7f we should also
enable all warnings in the template as a recommendation for users.

Pick-to: 6.10
Change-Id: If60a3d9f3c1fd97b49ec7513f781bdfe1775d9d4
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-06-02 19:18:03 +02:00
David Redondo
1260aaf954 Send synthesized button release event immediately
...not only on the next frame.

Pick-to: 6.10
Change-Id: Iad31a3d80576c5cd8fa3ba7f64a39d7a6a01337a
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-06-02 19:18:03 +02:00
Alexandru Croitor
747741119a CMake: Improve Apple SDK name and path reporting
If CMAKE_OSX_SYSROOT or QT_APPLE_SDK was set, we still reported the
default platform sdk path, rather than taking into account the set
value.

Improve the reporting by considering these values.

The implementation is incomplete because we don't handle explicit sdk
paths, but this is not critical for the current use cases, because the
value of the function is only used for reporting purposes.

Amends ab7eb492cba64fe985ea80b2f0be22c1c18f3c5e

Pick-to: 6.8 6.9 6.10
Change-Id: Ic69aec3641d435736018c96f72ba7f75a0f74508
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-06-02 19:18:03 +02:00
David Edmundson
602fa3f337 wayland: Ack configure events when suspended
All configure events should be acked, and that acknowledgement is double
buffered with the surface commit.

If a window is not exposed, for example being in a suspended state, us
sending an expose event is semantically wrong. It also ends up not
resulting in a commit as at some point it no-ops, we have to commit
manually.

Change-Id: I020b06f04030c1209f2fc768adc8bd66d57975b1
Reviewed-by: David Redondo <qt@david-redondo.de>
2025-06-02 20:18:03 +03:00
David Edmundson
ca27a661bd wayland: Use modern syntax for method invokation
Change-Id: I4b4d15fcb932460a1b6a132145451fa2990496ad
Reviewed-by: David Redondo <qt@david-redondo.de>
2025-06-02 19:32:47 +03:00
Olli Vuolteenaho
3bf9047a34 Android: Don't reparse same paths in QML to Java codegen
appImports can have the same directory added multiple times - first if
it's found in the xxx_conf.rsp file and secondly for the inner qmldir
scanner. This is because the xxx_conf.rsp file can have both the
qmlModule directory and the parent of that directory as importPaths. For
example like this (the paths are truncated to save characters):

-importPath
.../build/qt_generated/qtquickview/qmlModule
-importPath
.../build/qt_generated/qtquickview

In this case when the "inner qmldir" finder processes the later path,
it would go to ./qmlModule, find the qmldir and add another
.../build/qt_generated/qtquickview/qmlModule to appImports. Also, if
there were other qmldir files somewhere under qmlModule those would
also get added twice, which would increase generation time yet again.

This commits solves the issue by removing duplicates from appImports.

Amends 7ed88eb565d40b195aa868e67777872ef07a5ea2.

Pick-to: 6.10 6.9 6.8
Fixes: QTBUG-137316
Change-Id: I641065479aec0f3d9ae1a8727a03bf62eb169ad6
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-06-02 17:40:54 +03:00
Matthias Rauter
7d163200f9 Mark three files in corelib/mimetype as critical
* qmimeprovider.cpp parses file names to identify the Mimetype,
* qmimemagicrule.cpp parses the file to identify its Mimetype.
* qmimeglobpattern.cpp implements a pattern matching algorithm, i.e.
glob parser.

All involve parsing of data that might come from untrusted sources.

QUIP: 23
Task-number: QTBUG-135191
Pick-to: 6.10 6.9 6.8
Change-Id: I97d4cd8d635f05613d5a979c61038cef9c759989
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-06-02 14:40:54 +00:00
Cristian Le
cebdf1eb1c Introduce INSTALL_QT_SHAREDIR
Normally `INSTALL_DATADIR` is the canonical place for
`share`/`CMAKE_INSTALL_DATADIR`, but this standard is not well
enforced.

In 834d92a, `INSTALL_SHAREDIR` was introduced to better enforce this
standard and allow to install into third-party program's
`CMAKE_INSTALL_DATADIR` (e.g. wayland). This ended up being used as
`INSTALL_SHAREDIR/qt6` instead, but this leaves little room for
configuration and renaming.

This change introduces a namespaced variant that is guaranteed to be
owned by Qt.

Pick-to: 6.10
Change-Id: I25c0e5b47c402b178120e9e628fdfaf4aaad27ad
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-06-02 16:40:54 +02:00
David Edmundson
d08f1d7dbc QVulkanWindow: Force render on paint event
When a paint event is dispatched from the platform, application code
should redraw contents and submit a frame regardless of whether contents
have changed.

This fixes an issue where the window does not always update after being minimized on wayland, and would also be needed for non-composited X11 when exposure changes.

Pick-to: 6.10 6.9 6.8
Change-Id: I506872f439e0c16d71ad13def1c8b58a0491dd73
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-06-02 14:40:54 +00:00
Andreas Eliasson
f27588348b Doc: Add \note to QTest::qWait() to consider QTRY_*() macros instead
There seems to be a case that qWait() is a source of eventual pain.
Add \note to encourage the use of the QTRY_*() macros.

Fixes: QTBUG-136538
Pick-to: 6.10 6.9 6.8
Change-Id: I52daa8c38a55f8db66d8c941c7cbfff7b7060a5b
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2025-06-02 14:40:54 +00:00
Tim Blechmann
e6dfd2e9b0 Cocoa: QNSView - fix memory leak of QContainerLayer
setLayer will increment the reference count, so QContainerLayer is
leaked, as it is not autoreleased.

Pick-to: 6.10
Change-Id: I43cef8bbf9ccb9b849322edfb1e7ab75f5ae9898
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-06-02 10:29:27 +00:00
Tim Blechmann
c8ebe2e5cd Cocoa: QNSView - fix memory leak of QNSViewMenuHelper
QNSViewMenuHelper is leaked, as dealloc did not nil it to decrement the
reference count.

Pick-to: 6.5 6.8 6.9 6.10
Fixes: QTBUG-131655
Fixes: QTBUG-137161
Change-Id: I783c400d1300046118ad3e12816e84709cc9d793
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-06-02 10:29:23 +00:00
Eskil Abrahamsen Blomfeldt
ab7a80a955 DirectWrite: Avoid infinite recursion with broken font data
If a font has an em square size of 0 it is not going to be useful.
However, if one was encountered we returned a default value to
avoid division by zero. The default implementation called ascent(),
which would depend on the em square size again and we would get an
infinite recursion for these fonts.

To avoid this, we simply return a default value of 16 in the case
of a broken font. (The Apple spec gives the range 64 .. 16384 for
the em square and the Microsoft spec says 16 .. 16384, so we use
the smallest of the two.)

Fixes: QTBUG-137277
Pick-to: 6.5 6.8 6.9
Change-Id: I63779e44c10c7021486787d1e1e818f4c6e47835
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-06-02 11:34:02 +02:00
Samuli Piippo
b23da37d71 CMake: qtwaylandscanner doesn't need Wayland::Client
Remove dependency to Wayland::Client as it's not needed and
prevents building qtwaylandscanner for Windows where Client
is not supported but scanner is needed for cross-compilations.

Change-Id: Ia38dda58c0800799673ae2d1e29626ce6b399f04
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-06-02 05:22:52 +00:00
Ahmad Samir
1f2863ae48 qdataurl: fix parsing parameter values with percent-encoded comma
Change-Id: I2faa8ce7c9932eb82a853421290c39a37ad91bcf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-01 19:39:59 +03:00
Ahmad Samir
c140d9ab8e qdataurl: modify the percent-decoded byte array directly
Parse the content-type first, then slice the byte array. This is useful
especially for large base64 payloads.

Drive-by, use QUrl::toEncoded(), it's the same result but more succinct
syntax; pointed out in code review. Also remove an old comment, it's not
relevant anymore since QUrl::encodedPath() isn't available any more in
Qt 6.0:
https://code.qt.io/cgit/qt/qt.git/commit/?id=c0d237b7aa6e0257e3c3eee7336deaed1cf68252

Change-Id: Id69345f315dab934d0f2867008bf4fe29d63cac9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-06-01 19:39:49 +03:00
Frédéric Lefebvre
4db3961ee1 Fix flaky tst_QFocusEvent::checkReason_ActiveWindow on openSUSE
tst_QFocusEvent::CheckReason_ActiveWindow is flaky on openSUSE where
the childFocusWidgetOne is unable to receive focus after d has been
hidden.

This is due to some asynchronicity when setActive is being called
while d is already active.

Remove the call to activateWindow on d as it is already active by
calling show.

Pick-to: 6.9 6.8 6.5
Change-Id: Id01c6704122df42982d65d28ddb94d184d00d9aa
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-06-01 14:07:43 +02:00
Frédéric Lefebvre
6c7f61f081 Fix flaky tst_QMdiArea::currentSubWindow()
tst_QMdiArea::currentSubWindow() is flaky and fails when the
dummyTopLevel window is not marked as active before verification.

Verify that the dummyTopLevel is active, before checking what is the
active topLevel window.

Fix the flakiness of tst_QMdiArea::currentSubWindow() on Ubuntu 24.

Pick-to: 6.9 6.8 6.5
Change-Id: If5b85713d0bfec40e2722c471f7c3ba5ac73171c
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-06-01 14:07:29 +02:00
Marc Mutz
71842cfb89 QXdgDesktopPortalTheme: normalize SLOT argument
Non-normalized signatures passed to SIGNAL or SLOT macros require a
normalization step before the actual connection can be made, which
takes extra time and extra memory.

Also, a normalized signature is generally smaller than a
non-normalized one, so we save even in executable code size.

Amends a833d5682ac44571e13568336f2bd3ec7deb1d6d.

Task-number: QTBUG-116197
Pick-to: 6.9 6.8
Change-Id: I942f5ac262f05ca4486b2ed2a22654d1a12a3ef0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-05-31 15:43:22 +02:00
David Boddie
475c951d69 Doc: Fix auto-links to deprecated functions
Change-Id: Id4456eef3440734add2d804d186966e253335b7c
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-05-31 06:41:36 +00:00
Eskil Abrahamsen Blomfeldt
6854ea6336 dwrite: Support additional font names for system fonts
Fonts have multiple name fields that users may expect to be able to
use for referring to them. In particular, on Windows it has become
common to use a legacy font family name which contains the sub-family
of the specific font, because of backwards-compatibility reasons.

This is not technically the family of the font, but native
applications will typically list them as such anyway, and Qt would
also do this prior to Qt 6.8 because the GDI backend prioritizes
these.

When we moved to DirectWrite as the new default, these legacy names
for system fonts disappeared from the families list, which is
perceived as a regression.

Now, there was already an implementation for getting the legacy names
for fonts for application fonts, but this had not been implemented
for system fonts when populating the font database.

We rectify this by sharing the code which gets the additional font
names and also calling this when populating system fonts.

[ChangeLog][Windows] Fixed an issue where legacy names such as
'Arial Narrow' would no longer be listed as separate font families.

Fixes: QTBUG-135817
Pick-to: 6.8 6.9
Change-Id: I2e1b42b7be926e3b5af7bb2aab3ebe5a1fbe29de
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-05-31 08:41:18 +02:00
Tor Arne Vestbø
b490623b0c Remove note saying Qt::AA_ShareOpenGLContexts must be set before qGuiApp
Amends 4a7ccb65f0065e878c5762db05eca9c5cd6731e5.

Change-Id: I597713df2832406336486b683df1b5dd2bceb850
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-05-31 01:16:26 +02:00
Tor Arne Vestbø
e9dbdaa499 Make QOpenGLContext::globalShareContext() lazy creation thread-safe
We move the context to the main thread (or the thread of qGuiApp),
as that's where it will be deleted.

Amends 4a7ccb65f0065e878c5762db05eca9c5cd6731e5.

Caught-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Change-Id: I8e5dc512dce02d22980730a46474b2262684a713
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-05-31 01:16:23 +02:00
Alexey Edelev
11f149d987 Introduce qt_internal_set_module_transitive_properties
The function sets properties on target that then are propagated
transitively. This only works with Qt modules, but can be extended
for other Qt targets later. These transitive properties not necessarly
require Qt be built using CMake versions supporting transitive
properties(>= 3.30). Properties are stored and exported within the
Qt module unconditionally and can be used in user projects, if
CMake version allows this.

Change-Id: I1ff6f1099753784c721dc1e3cd972dcd9dafedc4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-05-31 00:44:07 +02:00
Alexey Edelev
c6f15f57cd Introduce Qt<Module>TransitiveExtras.cmake for Qt modules
This file sets the transitive module properties provided by
Qt Module that is built using CMake versions < 3.30. The idea
is to not limit user projects capabilities and allow using
transitive Qt Module properties if user CMake version allows it.

If Qt Modules are built using CMake versions >= 3.30 this code is noop,
since values are stored directly in the respective
INTERFACE_properties.

Change-Id: I5a0bc0aa4f79a04c81dfa0fee1d37cfee5935b0f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-05-31 00:44:07 +02:00
Michal Klocek
fb4c1257d8 Add run opengl tests feature
On Woa cross compile we want to compile with opengl feature,
however tests windows arm nodes do not have opengl installed
add a feature to skip the tests preventing the crash otherwise.

Note this is just temporary workaround and should be reverted
as soon as opengl libs land on windows arm vm nodes.

Task-number: COIN-1211
Change-Id: Iaae205b9cc10bd17e82152a44b2e976e4321d00d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-05-30 22:24:56 +00:00
Giuseppe D'Angelo
7c0a96785f Wayland: support adoption of native EGL contexts
QWaylandIntegration does not implement the
QNativeInterface::Private::QEGLIntegration interface. This means that
trying to create a QOpenGLContext from a native EGL context fails,
and QNativeInterface::QEGLContext::fromNative() always returns nullptr.

This commit makes QWaylandIntegration inherit from QEGLIntegration and
implement its interface. This in turn requires adding a new API to the
HW interfaces (implemented by both the EGL and the brcm-egl
integrations) to request adoption of a native context.

Fixes: QTBUG-110758
Change-Id: I81c08fcf1110b5e9e1d8739532df9ce78410d694
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-05-30 19:45:39 +02:00
Giuseppe D'Angelo
89ec9276fc EGL: undef X11 macros
Including egl.h may transitively include X headers which define a bunch
of macros that clash against our code. Undef these macros just after EGL
is included. This was already done locally in eglfs, but the same
problem appears in any code that uses qt_egl_p.h, like the Wayland
platform plugin.

Change-Id: I2fbd617f57de6ae7366795aabacd81c639903699
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-05-30 19:34:59 +02:00
Frédéric Lefebvre
f6126ccb1c Fix flaky tst_QScroller::overshoot on multiple Windows versions
tst_QScroller::overshoot is flaky on multiple versions of Windows 11.
The failure occurs in the part testing overshoot always off and slow,
where the result of the deltaPos and the startPos are equal to 0
instead of being smaller.

Slightly increase the value of touchEnd so that deltaPos is smaller.
As a drive-by, constify a local variable.

Fix the flakiness on Windows 11 24h2 mingw.

Fixes: QTBUG-137201
Change-Id: I6dacc7b5ac140f427fa6fbb8fddb5447ae14a233
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-05-30 17:34:59 +00:00
Mitch Curtis
c29868830c QtFlagHandlingHelpers.cmake: account for GCC when producing error
This changes the error message I get when configuring with
-DFEATURE_sanitize_thread=ON from:

    CMake Error at cmake/QtFlagHandlingHelpers.cmake:183 (message):
      Platform linker doesn't support erroring upon encountering undefined
      symbols.  Target:"Core".
    Call Stack (most recent call first):
      cmake/QtModuleHelpers.cmake:898 (qt_internal_add_link_flags_no_undefined)
      src/corelib/CMakeLists.txt:30 (qt_internal_add_module)

  to:

      ERROR: detected a std::atomic implementation that fails for function pointers. Please apply the patch corresponding to your Standard Library vendor, found in qtbase/config.tests/atomicfptr

    CMake Error at cmake/QtBuildInformation.cmake:240 (message):
      Check the configuration messages for an error that has occurred.
    Call Stack (most recent call first):
      cmake/QtBuildInformation.cmake:59 (qt_configure_print_summary)
      cmake/QtBuildRepoHelpers.cmake:393 (qt_print_feature_summary)
      cmake/QtBaseHelpers.cmake:287 (qt_build_repo_end)
      CMakeLists.txt:36 (qt_internal_qtbase_build_repo)

Pick-to: 6.8 6.9
Change-Id: If6243362521802d8b1348ae53d744c33add814f1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-05-31 00:16:41 +08:00
Morteza Jamshidi
c2bdf7636e Use WS_EX_NOACTIVATE to prevent window from getting focused
On top of handling ActivateWindowEvent,MouseActivateWindowEvent and
PointerActivateWindowEvent events and returning MA_NOACTIVATE we can
also set the window extended style to prevent windows from stealing
focus in special cases.
Also on top all those mentioned events, when the window is requested
to get keyboard focus, it should check if the window accepts focus
or not. If it does not, then it should inform the underlying system
that the window does not accept the focusIn event.
[ChangeLog][Windows] Windows with flag Qt::WindowDoesNotAcceptFocus
no longer have a taskbar entry.

Pick-to: 6.9
Fixes: QTBUG-131714
Change-Id: I79f767b1622449ba05b41f8b80bf390d8cecfff8
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Zhao Yuhang <2546789017@qq.com>
2025-05-30 18:16:41 +02:00
Fabian Kosmale
e115c60b6d Q(ObjectBindable)Property: Properly support comparisons
Before, it was possible to do some comparisons due to the implicit
conversion to T. However, that does not work in all contexts.

Fix this by explicitly declaring the comparison operators. We need to
a) use the helper macro directly, as the operartors are only available
   if the underlying type has them and
b) mark the operator as noexcept(false), as capturing a property in a
   binding might allocate.

Fixes: QTBUG-134921
Change-Id: I2855964ba481b9e7778a4a7076528593549910fe
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-05-30 18:16:41 +02:00
Marc Mutz
dc45850c1e Mark QUrl* classes as security-critical
These classes, too, are usually in the first line of defense, handling
tainted data before anything else had the chance to verify it.

Amends 8df072fc8006510c9b743e8ffedaaf51a876883a.

QUIP: 23
Task-number: QTBUG-135187
Pick-to: 6.9 6.8
Change-Id: I21dbea39078a583f0bbf7737bd7151893fb98d17
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
2025-05-30 18:16:41 +02:00
Marc Mutz
e4f8601236 QMetaObject: extract helpers from indexOf*() methods
This makes the different functions more similar to each other, thus
facilitating adding a warning about non-normalized arguments to them
in the next step.

Task-number: QTBUG-135572
Pick-to: 6.9 6.8 6.5
Change-Id: Ia2b82928e9a24fb9d43b43933b9a9c5308fa2835
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-30 18:16:41 +02:00
Marc Mutz
3e98657898 QPainter: make Private::d_ptrs a QVLA<unique_ptr>
This way, we remove the impedance mismatch between QPainter::d_ptr
(which already is a unique_ptr) and Private::d_ptrs, which still dealt
in raw pointers, simplifying the code.

Since we're now owning the objects in d_ptrs, add an assertion that
d_ptrs is empty on QPainter destruction.

Coverity-Id: 425479
Change-Id: I849e80752b4bc5a71aef8d47663c6ffc9fdca9f7
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-05-30 18:16:40 +02:00
Venugopal Shivashankar
e670a6d77b Doc: Update the HTML tab config
- Added translat='no' attribute to input and style
- Added the missing linefeeds

Change-Id: I51ffe1bd0eb8d06bab7a7eedcd862e88fe794588
Pick-to: 6.9 6.8
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2025-05-30 18:16:40 +02:00
Aurélien Brooke
433360c6cd rhi: vulkan: make it easier to hunt VMA leaks
When leaking a RHI resource, the VMA asserts (VMA_ASSERT_LEAK) before
the RHI has a chance to list the leaks.

Plug the VMA leak output to the QDebug infrastructure, and give names to
the VmaAllocations so that we know exactly what leaked. This is only
enabled for debug builds or when QT_RHI_LEAK_CHECK is set.

Change-Id: Ief0e46cceaefb2e736542f9764264c29b0c28c64
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-05-30 12:23:09 +02:00
David Edmundson
70e75851bf wayland: Reset surface on QWindow type change
Changing the role between toplevel and popups is illegal on wayland even
if the window is not visible. We need to reset to the wl_surface.

This meant we cannot call setWindowFlags in the constructor.

QWindow::flags / QWindow::windowType changes after
QPlatformWindow::setFlags has finished, so we need to use our own flags
rather in XdgShell rather than pulling them from the QWindow.

Task-number: QTBUG-136110
Change-Id: I8b54b7ea8a768a539178395e53cc63a64fd80232
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-05-30 05:16:53 +00:00
Thiago Macieira
7838a57d29 QLocale: remove WhiteSpacesAllowed mode from qt_asciiToDouble()
It's no longer used. It was used by QByteArray{,View}::toDouble() but
that caused an all-space string to be considered a valid conversion. Now
that those functions do the trimming themselves, we don't need this
mode.

Pick-to: 6.9
Change-Id: I2c24d3011fd7969bcc92fffd802a5d78ca28c157
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-05-29 19:50:47 -07:00
Thiago Macieira
61b17127ae QByteArray: make toDouble() reject space-only strings
This does not affect leading and trailing spaces, which remain allowed.
This is only about a string containing only spaces, which used to be
rejected prior to Qt 5.9 and are rejected with QString (unit tests added
to confirm).

Drive-by indent one QString test row, which I've also reordered so null
comes before empty.

[ChangeLog][QtCore][QByteArray & QByteArrayView] Fixed an old regression
that caused toDouble() and toFloat() to return ok = true for a string
containing only whitespaces.

Pick-to: 6.9 6.8
Fixes: QTBUG-137038
Change-Id: Ia6f7714c5e289317de60fffd0f8aa6d2198a91ef
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-05-29 19:50:47 -07:00
MohammadHossein Qanbari
2fe9eed3fd QGnomeTheme, QGtk3Theme: Refactor and Simplify DBus Interactions
This patch refactors the DBus integration in both QGnomeTheme and
QGtk3Theme to centralize and simplify the portal and settings access
logic. Previously, the codebase contained duplicated and scattered DBus
logic for querying GNOME/GTK appearance settings, such as color scheme
and contrast, which were implemented separately in both QGnomeTheme and
QGtk3Theme.

The patch introduces a new QGnomePortalInterface class which
encapsulates all DBus interactions related to GNOME/GTK appearance
settings. The old DBus interface logic is removed from QGtk3Theme and
QGnomeTheme, and replaced with calls to the unified
QGnomePortalInterface. The update also ensures signal-based updates for
theme and appearance changes via the new interface.

Change-Id: I5440f7ac00f956b846b18bd890113af0044482f0
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-05-30 03:25:04 +02:00
MohammadHossein Qanbari
933338f947 Dbus: Enhance process of determining color scheme and contrast
The XDG portal has changed some interfaces since version 2. We already
support the changes in version 2. The DBus listener and GNOME theme do
not work properly if the machine uses version 1. This patch ensures
that the color scheme and contrast preferences work fine with the older
version.

Regarding contrast preference, the XDG desktop portal introduces the
`contrast` interface in version 2. This patch uses the GNOME settings
as a fallback method to determine the contrast preference in case the
XDG contrast interface is not accessible. The contrast value retrieved
from the DBus varies depending on the provider.

Regarding the color-scheme interface, the only difference between XDG
portal versions 1 and 2 is the method name. The method name to read the
color-scheme value from the portal setting changed to `ReadOne` from
`Read`. This is also used for reading the contrast value.

Change-Id: Id4d81ecf5465bbbab64c41e431a8d4d86e63849a
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2025-05-30 03:25:04 +02:00
David Edmundson
e9eba1ef0d wayland: Drop ShellIntegration::handleExpose
This was effectively deprecated when the virtual isExposed was added and
we moved towards a state based system.

The region of the exposed geometry is something we want to phase out and
is of no use to shells.

The other usage in XdgShell was for updating contentGeometry on first
show, but this is now an explicit call updated by QWaylandWindow
directly.

Change-Id: I09a083fcfcc69c444ca4270f425b591b046e0617
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2025-05-29 23:06:50 +03:00
David Edmundson
27283b02ca wayland: Make initial commit for surface state opt-in
After setting up the shell surface we setup the initial state and have
to commit the surface to apply the surface role in order to get a
configure event from the compositor.

This is not a requirement for subsurfaces, and can be skipped.

It is also problematic for some 3rd party shells, such as
ext-session-lock-v1, which has a different setup behaviour.

Task-number: QTBUG-136337
Change-Id: I9e7874ec2f4150e24eb4790384eacc4123f9552b
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2025-05-29 23:06:49 +03:00
Michael Weghorn
854d7021b8 a11y uia: Report locale via UIA_CulturePropertyId
Map QAccessible::Attribute::Locale to
UIA_CulturePropertyId [1] in the Windows UIA
accessibility bridge:

> Identifies the Culture property, which contains a
> locale identifier for the automation element (for
> example, 0x0409 for "en-US" or English (United States)).

In a test with 2 spinboxes whose locales were explicitly
set to

* QLocale(QLocale::English, QLocale::UnitedStates))
* QLocale(QLocale::Chinese, QLocale::China))

, retrieving the current value of UIA_CulturePropertyId (30015)
using NVDA's Python console gives the expected result:

With the spinbox whose locale is set to English/United States:

	>>> hex(focus.UIAElement.GetCurrentPropertyValue(30015))
	'0x409'

With the spinbox whose locale is set to Chinese/China:

	>>> hex(focus.UIAElement.GetCurrentPropertyValue(30015))
	'0x804'

as "[MS-LCID]: Windows Language Code Identifier (LCID) Reference" [2]
lists these identifiers as follows:

* 0x0409 en-US
* 0x0804 zh-CN

[1] https://learn.microsoft.com/en-us/windows/win32/winauto/uiauto-automation-element-propids
[2] https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/70feba9f-294e-491e-b6eb-56532684c37f

Task-number: QTBUG-137144
Change-Id: I2b0cad9ab7ede9f01dee3d7f3efddb8c5335caaf
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-05-29 21:59:26 +02:00
Michael Weghorn
bb2121551c a11y: Report QWidget locale
Implement support for QAccessible::Attribute::Locale
(newly introduced in a previous commit) for QWidget
by introducing QAccessibleWidgetV2 which subclasses
QAccessibleWidget and implements the
QAccessibleAttributesInterface to report the QWidget::locale
property for QAccessible::Attribute::Locale.
(Leave QAccessibleWidget unchanged for ABI compatibility.)

Switch QAccessibleWidget subclasses to subclass the
newly introduced QAccessibleWidgetV2.

Add a corresponding unit test.

Task-number: QTBUG-137144
Change-Id: I61385b17ee1272801ad769da5a807ca4e068cfb2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-05-29 21:59:26 +02:00
David Edmundson
e9e025a085 wayland: Move to synchronous expose events
Move to synchronous delivery for expose events.

One twist with this the expose event from geometry events. This event
normally comes from the display server, but in our case is synthesised
by the backend. This needs to be deferred, but we can do that
internally.

The move to synchronous events allows us to drop an old workaround for
renders finishing after a window is hidden.

The mInResizeFromApplyConfigure guard in geometry changes existed as all
configure events trigger their own expose event and we didn't want two.
Not the sending is deferred it's implicity handled by the
mLastExposeGeometry check.

Task-number: QTBUG-137021
Change-Id: I8758c083e4d44a04606ae72f1019f2bc577f51f6
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2025-05-29 21:06:53 +03:00
MohammadHossein Qanbari
6a21e0e212 QGnomeTheme: Enhance system color scheme detection
Previously, QGnomeTheme relied on the theme name to determine the
system's color scheme when a "SettingChanged" signal was emitted via
dbus. However, this approach overlooked the "color-scheme" property in
the signal, which directly provides the updated light/dark mode
information.

This patch updates QGnomeTheme to use the "color-scheme" property from
the dbus signal, ensuring accurate detection of changes in the system's
color scheme. The theme name fallback is retained for scenarios where
"color-scheme" data is not provided.

See also the XDG Desktop Portal documentation:
https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.Settings.html

Related to this commit: 4ac89dad78772ce90649b9846efa17319deba28f

Task-number: QTBUG-133595
Change-Id: I2c3982fd9871d76184f1b4233d95e7a5e0a34ad1
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2025-05-29 16:34:06 +02:00
Bartlomiej Moskal
393c294e10 Android: Avoid lazy initialization of QAndroidPlatformServices
In commit ff51ea5418d131248b07e327513b41dad1231f37, lazy initialization
was introduced for QPlatformServices, including
QAndroidPlatformServices. However, this approach causes a regression.
When QAndroidPlatformServices is lazily initialized, the intent listener
registration is delayed. As a result, handling custom URL schemes is
affected - especially those coming from external applications.

To address this issue, this commit removes lazy initialization for
QAndroidPlatformServices.

Fixes: QTBUG-135489
Pick-to: 6.9 6.8 6.5
Change-Id: I24becdf4ac573e7a2ca101cfbc27560d1eb4adef
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-05-29 08:01:13 +00:00
Dheerendra Purohit
d446df7599 QNetworkRequest: fix minor typo referencing non-existent method
Replaced incorrect setTimeout() with setTransferTimeout()

Pick-to: 6.9 6.8
Fixes: QTBUG-111993
Change-Id: I1eef02cda1be00d6ab99769f4a9b4406ac92d389
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2025-05-29 04:22:43 +00:00
Christian Ehrlicher
d34754ea81 QStyleSheetstyle: misc cleanup of QStyleSheetBorderImageData
Remove unused member 'image' from QStyleSheetBorderImageData and replace
c array with std::array<>.

Pick-to: 6.9
Change-Id: I149ef72e443027a6b6d30f25e8c7b1adf4138fc5
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-05-28 21:54:52 +02:00
Michael Weghorn
da3422ca15 a11y: Introduce QAccessible::Attribute::Locale, bridge to AT-SPI
Introduce a new Locale value for the QAccessible::Attribute
enum class that can be used to specify the locale
of an accessible object.

Use this to implement support for the
"Locale" property of the AT-SPI Accessible interface. [1]

If no locale has explicitly been specified, report
the default locale in the AT-SPI adaptor, as is
already the case in the implementation of the
"GetLocale" method of the AT-SPI Application
interface.

Being able to explicitly specify a locale is of
particular interest when an application contains
objects whose locale differs from the default
application locale, e.g. documents or paragraphs
written in a different language.

Demo LibreOffice change making use of this
new API: [2]

Sample use case with the above-mentioned LibreOffice
change in place:

1) start LibreOffice Writer, using English UI
   and document language
2) type "Hello world" for the first paragraph
3) press Enter to create a new paragraph
4) copy-paste "你好世界" ("Hello world" in Chinese)
   into the new paragraph
5) start Accerciser
6) select the first paragraph in Accerciser's treeview
   of the LibreOffice a11y hierarchy
7) query locale in Accerciser's IPython console

    In [1]: acc.get_object_locale()
    Out[1]: 'en_GB'

8) select the second paragraph in Accerciser's treeview
   of the LibreOffice a11y hierarchy
9) query locale in Accerciser's IPython console

    In [2]: acc.get_object_locale()
    Out[2]: 'zh_CN'

For UIA on Windows, UIA_CulturePropertyId [3] seems
to be the equivalent property that the new attribute
could be mapped to (to be done separately, not implemented
in this commit).

[1] 2e65b0877d/xml/Accessible.xml (L55-67)
[2] https://gerrit.libreoffice.org/c/core/+/185709
[3] https://learn.microsoft.com/en-us/windows/win32/winauto/uiauto-automation-element-propids

[ChangeLog][QtGui][QAccessible::Attribute] Added new
Locale enum value that can be used to specify the
locale of an accessible object.

Fixes: QTBUG-137144
Change-Id: Ice11b9e45b512305dbb8195961b8b08e1389c69e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-05-28 21:44:13 +02:00
Ivan Solovev
ca50d72778 QtConcurrent: mark as security-significant
The QtConcurrent module applies user-provided map-, filter-, and reduce-
functions (or their combinations) to user-provided data.
It does not make any assumptions about the provided functions and
data, apart from input/return type validation. It also does not parse
the provided data and does not have any way to sanitize it.

Mark all the source and header files in the module with the default
security-significant score to confirm that the code was reviewed.

QUIP: 23
Fixes: QTBUG-135179
Pick-to: 6.9 6.8
Change-Id: I2c1b315b837111627c2f0ce6e2ade704415972e2
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-28 18:00:36 +02:00
Joshua Goins
c50ede0b20 Add autotest for ensuring restoring cursor shapes doesn't regress
We now try to keep track of the cursor state for each window, but was
missing an autotest (modeled after QTBUG-133541.)

Pick-to: 6.8 6.9
Change-Id: I9d081f5a3cc8bdaa860d48beb5f105afa424f102
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-05-28 16:34:45 +02:00
Joerg Bornemann
286e309373 Revert "CMake: Make generated pkgconfig files relocatable"
This reverts commit 731d9a13956ef40e3f563f5ff5ff5c250b8d6d94.

Reason for revert: ${pcfiledir} cannot be used, because this
leads to wrong prefix values if PKG_CONFIG_SYSROOT_DIR is set.

See the comments of the associated task for instances of this
problem in other projects.

Pick-to: 6.8 6.9
Task-number: QTBUG-136210
Change-Id: I2a60946828f07866b931dacfe0ef81346f1aac9d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-05-28 14:34:45 +00:00
David Boddie
fbc6b0c6e6 Doc: Fix link to removed QFontMetrics::width function
The function was removed but documentation still referred to it.

Change-Id: I2fc1ef2ffc9cdc93e059dd1854816e6aa86dc972
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-05-28 12:05:57 +02:00
Alexandru Croitor
674a6dc5f6 CMake: Stop spamming CMP0156 debug messages
We set the CMP0156 policy to NEW for Apple platforms for each created
Qt target, but the debug message is generic, so we should only show it
once.

Amends c20d7bcb86361d0c9f8af3807dcad9db1a3a5ca0

Pick-to: 6.8 6.9
Task-number: QTBUG-135978
Change-Id: I332bd357999647df1d5f715d154fb568911889b1
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-05-28 11:38:24 +02:00
Alexandru Croitor
c2f7004204 CMake: Prefer target arch qmltestrunner when searching for it
Currently qmltestrunner is built as a tool, instead of an app.

That means that for most cross-compiling platforms (aside from Yocto),
the build system will look for a host binary when referring to the
qmltestrunner target. We want to look for the target platform binary
instead.

Switch the code around to prefer looking for the target platform
binary via find_program, before falling back to referring to it by
target name.

In the future when we change qmltestrunner to be an app, and also
expose its target platform binary as a target name, this should not be
needed anymore, and we could rely solely on the target name.

Amends 9edcc4690665496c2b6f15876b3979487dbad22a

Task-number: COIN-1211
Task-number: QTBUG-137005
Change-Id: If2eb93d8832a17aae3d0648d1d0f5997805796fa
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-05-28 11:35:07 +02:00
Edward Welbourne
6f8431b930 Modernize string usage in corelib/time/ tests
This incidentally lets me turn on QT_NO_CAST_{FROM,TO}_ASCII for them.

In the process, convert some test-cases to addRow() and use plain QBA
in place of newRow((QString arithmetic).toLocal8Bit().constData()),

Change-Id: I0117338dd927fc4eee74688ac86975508fa43b51
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-05-28 11:28:10 +02:00
Lorn Potter
f5d888b44a wasm: Make sure native fetch is destroyed before reply is canceled, closed
finished signal was being sent before native fetch was destroyed
which, in some instances, was causing a crash.

Fixes: QTBUG-136710
Pick-to: 6.9
Change-Id: I2134431cbf9af0511d888dc5db3f589f5259c88a
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
2025-05-28 15:53:10 +10:00
Topi Reinio
cc07564978 Doc: Enable automatic linking to sources on code.qt.io
Since 6.10, QDoc is capable of generating links to the declaration in
the source code for each documented C++ API entity in their `Detailed
description`.

Add the required configuration to enable this feature in online
documentation builds.

Change-Id: Iaafabc5aea50a6cd72549bb1c04007bb4de498ca
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2025-05-27 23:32:25 +00:00
Aurélien Brooke
2c6d729be9 QMetaType: only use sized-delete when available
Sized-delete is C++14 feature, but Clang didn't enable it until version
19.1 because it needs to support different standard libraries, and many
of them hadn't implemented support when the code was originally written.

https://github.com/llvm/llvm-project/pull/83774

Amends 44b5602536a95b847404b28948ad2bb4a4076f4b.

Change-Id: I17fc098d70bfb7474f4324d29ec6f32c91e3a705
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-28 00:59:58 +02:00
David Edmundson
68562d9b2e Wayland Client: explicitly attach a buffer in sendExposeEvent()
if an expose is not handled by application code. This primarily is a
workaround for Qt unit tests using QWindow directly and wanting focus.

Done-with: Liang Qi <liang.qi@qt.io>
Fixes: QTBUG-137021
Change-Id: Ibcbd931af9a3558cf7244699216bc716eba4850c
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-05-27 20:51:05 +00:00
David Edmundson
4c8333a353 qtooltip: Fix whitespace
Change-Id: I97676328036560a8afb66d607d1bef21a6930fad
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-05-27 20:05:50 +00:00
Tor Arne Vestbø
26f92a333e Windows: Only use UpdateLayeredWindowIndirect if window has an alpha
We only call UpdateLayeredWindow in setWindowOpacity if the window
has an alpha an no native frame, which means we need to use the
same condition in the backingstore when choosing how to flush the
window.

Amends 9a45fea9d1f6e445fb488693b107cdec6e42cccd.

As a follow-up we should refactor this code to avoid the duplicated
logic that must always be kept in sync.

Pick-to: 6.9 6.8
Change-Id: I2bd79bdc4a726339fc486d0892ff4e1960a5a10e
Reviewed-by: Zhao Yuhang <2546789017@qq.com>
Reviewed-by: Nodir Temirkhodjaev <nodir.temir@gmail.com>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2025-05-27 22:05:50 +02:00
Giuseppe D'Angelo
f56ed53261 moc: indent the generated code for ResetProperty
Make it match the one for the other property-related operations.

Change-Id: I9248cca81f9ab48cf6765f66d696631e91f5ad07
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-05-27 22:05:50 +02:00
Tim Blechmann
6d820c8551 entrypoint: remove extern "C" from main declaration
clang emits -Wmain if `main` is declared as `extern "C"`.

Pick-to: 6.8 6.9
Change-Id: Ieee28204f18e5153eaae8d6088294539f4991f96
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-28 03:34:58 +08:00
Vlad Zahorodnii
4ddc7a1407 wayland: Deliver WindowScreenChangedEvent synchronously
The QWaylandWindow::handleScreensChanged() function checks
window()->screen(), but QWindow's screen is updated asynchronously. It
can lead to the following issue:

- start on screen 1
- QWaylandWindow::handleWindowScreenChanged(screen 2): it'll update
  the window geometry so the window position is at the top left corner
  of screen 2
- QWaylandWindow::handleWindowScreenChanged(screen 1): it'll do nothing,
  despite the fact that the geometry has to be updated

This change makes the delivery of WindowScreenChanged events sync, so
the QPA updates the window geometry as expected if the window moves back
and forth between two outputs.

This fixes misplaced popup menus in Konsole.

Change-Id: I5a200b33ef63c6082f54ee85667b7b1ab513335e
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-05-27 18:11:03 +03:00
Matthias Rauter
1ecbad8da9 Add TEST_ALL_COMPARISON to tst_qstringview
While porting some of these tests to QUtf8StringView, Thiago suggested
to add the comparison tests from qcomparisontesthelper_p.h.

Pick-to: 6.9 6.8
Change-Id: Id8f2c1c5690f7219ac000eebb637f48acbc5662d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-27 13:35:40 +02:00
David Redondo
deec49bac6 qtwaylandscanner: Handle destructor requests with new_id correctly
Instead of generating code like
    return request(args)
    m_object = nullptr
do
   new_id = request(args)
   m_object = nullptr
   return new_id
This came up in the color managment protocol where
wp_image_description_creator_params_v1::create creates a new object
but is also a destructor at the same time.

Pick-to: 6.9
Change-Id: Ic5d9f72656d99740bf6665c07393f69ee78af013
Reviewed-by: David Redondo <qt@david-redondo.de>
2025-05-27 11:35:40 +00:00
Lu YaNing
555bda1736 Client: add cursor state management
When tooltip window is shown and dismissed under Wayland, the cursor state

Add cursor state storage and application logic to ensure cursor state
is properly updated when changing cursors on focused

Fixes: QTBUG-135938
Change-Id: I8c3520bcb785cea03cddd1eb91e58b9d253b4fe0
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-05-27 14:28:27 +08:00
Tim Blechmann
1f6352010d network: silence -Wimplicit-exception-spec-mismatch
`noexcept` drop implicit noexcept from QHttp2Connection dtor

Pick-to: 6.8 6.9
Change-Id: I0ff6afb1f70d3fe68739380b6f18c308871aa327
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2025-05-26 23:02:30 +02:00
Edward Welbourne
d4a54ba56a Deploy QCOMPARE_op() more widely in corelib/time/ tests
Exceptions:
* In tests of comparison operators themselves, still verify.
* Hash values aren't interesting to display.

Change-Id: I046be84f0f2637eddf57409895f20f164bda9a6b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-26 21:12:52 +02:00
Thiago Macieira
9ffa770afa QLogging: fix build: narrowing conversion from qsizetype to size_t
Amends a6070847f075296458e1afef0210f9c89aca4b2a.

error: narrowing conversion of ‘(& ba)->QByteArray::size()’ from ‘qsizetype’ {aka ‘long long int’} to ‘size_t’ {aka ‘long unsigned int’} [-Werror=narrowing]

Task-number: QTBUG-120047
Task-number: QTBUG-120048
Change-Id: I1fe8c5d7318c398e4ef3fffd17e06f0eeccdd791
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2025-05-26 12:12:52 -07:00
Alexandru Croitor
d2ed84514d CMake: Skip sbom file checksum checks for excluded test targets
If a developer configured Qt with
 -DQT_GENERATE_SBOM=ON
 -DQT_BUILD_TESTS=ON
 -DQT_BUILD_TESTS_BY_DEFAULT=OFF

The would get the following error upon installation of qtmultimedia:

CMake Error at
qt_sbom/SPDXRef-PackagedFile-qt-plugin-MockMultimediaPlugin.cmake:5
  (message):
  Cannot find 'plugins/multimedia/libmockmultimediaplugin.a' to
  compute its checksum.

This happens because QT_BUILD_TESTS_BY_DEFAULT == ON sets the
EXCLUDE_FROM_ALL directory property on the tests directory, which
means all plugins created under tests/ subdir are not installed by
default, and the SBOM code could not read the installed files to check
the checksums.

In such a case, set a QT_INTERNAL_TEST_TARGETS_EXCLUDE_FROM_ALL
directory-scoped variable in the tests/ subdir, and use that as a
marker for the sbom code to know it should skip the checksum check.

Pick-to: 6.8 6.9
Fixes: QTBUG-137168
Change-Id: I970c3bc5732cc648549e5099fa1d50b3b39cb26f
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-05-26 20:11:33 +02:00
Piotr Wiercinski
fcb89d1560 wasm: Skip tst_QDir::mkdirOnSymlink
Skip this test temporarily to enable upgrading Emscripten to 4.0.7.

Change-Id: Ieb01a3d3d231828a127c5d7c1866cab547e22fb6
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
2025-05-26 20:11:33 +02:00
Ahmad Samir
a0c0d40842 QHttpNetworkConnection: use std::optional instead of QScopedPointer
As pointed out in the code review.

Task-number: QTBUG-132213
Change-Id: Ia67cae1aa89dd11bd54331d1593d5717deafcf8d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-05-26 19:58:30 +03:00
Ahmad Samir
ffc5491757 QLocalServer: use std::unique_ptr instead of QScopedPointer
Task-number: QTBUG-132213
Change-Id: I6a18e787efa9a2ecfe89339569a9724467ac3e6a

Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-05-26 18:56:49 +03:00
David Boddie
9eb2c404ee Doc: Fix page file name typo
Change-Id: Id3e932426c01725b6f6ba2f64f06e211689235dd
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2025-05-26 17:56:49 +02:00
Bartlomiej Moskal
ab98013efc Android: Fix text update issues with fullscreen virtual keyboard
In commit 1f6d7cbb341bd79826d3f6d69e1f1a427ebb8f1b, we introduced
support for the full-screen software keyboard.

However, this revealed issues with text not updating correctly in the
view, particularly with composing text.

This commit addresses the problem by adding calls of [0]restartInput()
in three methods: setComposingText, deleteSurroundingText and
setSelection.

These calls help synchronize the editable state with the input method
and ensure the displayed text remains consistent and up-to-date.

There is one more issue that needs to be solved: QTBUG-136229

[0]https://developer.android.com/reference/android/view/inputmethod/InputMethodManager#restartInput(android.view.View)

Pick-to: 6.9 6.8
Fixes: QTBUG-135376
Fixes: QTBUG-128745
Fixes: QTBUG-130058
Change-Id: I3f905dd02cb3bfe5046b01164412f328160b7a8b
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-05-26 17:38:31 +02:00
Volker Hilsheimer
bdbe4c8858 QGIM: Rename to QRangeModel
As per the discussion on the mailing list [1], we want to avoid the word
"Generic" in class names. And QGIM is by design not using 'items', so
similar to e.g. QAbstractListModel or QSqlQueryModel, we don't need to
have "item" in the class name either.

It is a "Model", which is a well defined concept in Qt, that operates on
any C++ range, which is a well defined concept in C++. QRangeModel
is the best name.

Future evolutions on this API, e.g. adding a C++ template class that
provides an idiomatic C++ range API around the data while also updating
the Qt model, are not expected to be problematic by using this name.

[1] https://lists.qt-project.org/pipermail/development/2025-May/046322.html

Change-Id: Idaa70f8b2a30754cb28da13a0e6b0e22334afa11
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
2025-05-26 16:11:27 +02:00
Wladimir Leuschner
2d0e3c5001 Revert "Windows QPA: Remove usage of deprecated DwmEnableBlurBehindWindow"
This reverts commit b07876105788d519a3bb04a353eaa5ffa6269253.

Reason for revert: Introduced regression QTBUG-136098

Change-Id: Id1f4d7a485659c4150f6750866c2f702fcdc1bf6
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2025-05-26 15:15:08 +02:00
Even Oscar Andersen
e48c19449e wasm: Fix stacking order problem for transient parent windows
Windows with a transient parent does not reflect the relationship
in the stacking order. Essentially AboveTransientParent is missing
as a configuration choice.

What makes this slightly convoluted is that the window stack
does not depend on the window (for testability).

We solve this problem by making the stack and treenode templates,
and provide test class as arguments when testing.

QWasmWindow and QWasmScreen are not templated as before.

There is also a new order type StayAboveTransientParent. Which
means that we can no longer use order type to get to the
group location (Since StayAboveTransientParent can map to either
of the three types).

The window stack tests have been updated to handle the
StayAboveTransientParent type.

Finally, we do not do anything with a normal parent
child relationship as this should already work
correctly.

Fixes: QTBUG-131699
Change-Id: Ie08e18f9e0a2339175c4a09da0a831f031df71e1
Reviewed-by: Lorn Potter <lorn.potter@qt.io>
2025-05-26 13:27:17 +02:00
Leena Miettinen
3ad9d5777f Doc: Update external links to Qt Creator docs to 16.0.0 level
Mostly additions, but some title changes, too.

Pick-to: 6.8 6.9
Change-Id: Ic911183c1ad77f68f2fc958d82456010b8ce8201
Reviewed-by: Mats Honkamaa <mats.honkamaa@qt.io>
Reviewed-by: Esa Törmänen <esa.tormanen@qt.io>
Reviewed-by: Inkamari Harjula <inkamari.harjula@qt.io>
2025-05-26 13:27:17 +02:00
Lauri Pohjanheimo
10b9a43bf8 Mark QtNative as security sensitive
QtNative handled app input parameters and parses Uri:s

Pick-to: 6.9 6.8
Task-number: QTBUG-136727
Task-number: QTBUG-135178
Change-Id: I9830a51816ef41cd3b090382593012c22171c87b
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-05-26 11:27:17 +00:00
Aurélien Brooke
c100bb306a QMetaCallEvent: remove the QMetaCallEvent::create() function
It is unused since 0bd1fc006097e481d8b92ee1c5246ffa1ae9379f, and
duplicates a lot of code.

The last usages were replaced by QMetaObject::invokeMethod().

Change-Id: Idad7c75a7b43670269b0cfcea9543114839e604c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-26 13:27:17 +02:00
Ivan Solovev
3c1e2b8a24 network/ssl: Fix deprecated usages of QHashCombine
Amends c05ae82efb33507959ae2082483fb9425ccca8a0 which deprecated the
default constructor in favor of always requiring to pass the seed.

Change-Id: I1d77aff13fd1af8b8db8c61b19a6f70cfd092f54
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-26 13:27:17 +02:00
Tim Blechmann
f90dd023cf QQueue: add enqueue signature to enqueue elements by moving
Using the QQueue shim one could only use `enqueue` by copying. Adding a
signature to copy to allow elements to be moved.

Change-Id: Idfbabb6fc01265285f128c5657ccb4050e902720
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-26 08:59:48 +00:00
Juha Vuolle
bed78605e7 Make Qt for Android configurable without 'desktopservices' support
Put all URL open handling behind desktopservices-feature flag.
Move the few remaining function (desktopEnvironment()) a bit to
keep #ifdeffery simple.

Fixes: QTBUG-135722
Pick-to: 6.9 6.8
Change-Id: Id210f99f905719b8c5dc0a5fa5ac3cf10181ae84
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-05-26 07:32:02 +03:00
Tim Blechmann
6f319847d0 Add q23::expected as a private type
This patch adds a std::expected-like type in Qt for use in the Qt
implementation. It is using Sy Brand's tl::expected which is similar to
std::expected, and works with C++17. Although it closely resembles
std::expected, it is not identical and is therefor added as a private
header. The new type is intended to be accessible to all Qt modules and
is therefore made available through Qt Core. It is, however, not
intended for use in public APIs.

[ChangeLog][Third-Party Code] Added Sy Brand's tl::expected as a third
party dependency for use internally in Qt implementation.

Change-Id: I09930f31bf97498643d62814c688f288d5c33265
Reviewed-by: Tim Blechmann <tim.blechmann@qt.io>
2025-05-25 23:09:56 +02:00
Thiago Macieira
60f36b8d02 QTest::CrashHandler: extract the address of the crashing instruction
From the user and machine context provided in the signal handler.

Linux w/ GDB prints:
   0x563bb2ab7346 <_ZN11tst_Crashes5crashEv+28>:	movl   $0x1,(%rax)

FreeBSD w/ LLDB prints:
(lldb) x/i 0x0000319a0ae86996
    0x319a0ae86996: c7 40 04 01 00 00 00  other       movl   $0x1, 0x4(%rax)

macOS w/ LLDB prints (after disabling the check for SIP):
(lldb) x/i 0x00000001054086c8
    0x1054086c8: movl   $0x1, 0x4(%rax)

Done-With: Samuel Gaist
Done-With: Ivan Solovev
Change-Id: Iac02025b1922b6b4d927fffd3efe210ef51fc759
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
2025-05-25 13:24:27 -07:00
Thiago Macieira
33435ce567 QTest::CrashHandler: prepare to disassemble the crashing instruction
This is the infrastructure code, without actually getting the
instruction pointer from the machine context.

Change-Id: Iadd2c78913b2d0177949fffdeafa12e9fc3daf87
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-25 13:24:27 -07:00
Thiago Macieira
4fcd854657 QTest::CrashHandler: switch to execvp() instead of execlp()
There will be variable options.

Change-Id: Ie633615daeac87e8bd2cfffd962666a85d91d5cd
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-25 13:24:27 -07:00
Thiago Macieira
c8d3d7a7af QAbstractEventDispatcher: prevent too late unregistering of timers
Timers can't unregister when the dispatcher object is no longer of a
dispatcher type. It's too late even at ~QAbstractEventDispatcher,
because unregisterTimer() is a pure virtual. To prevent their attempting
to unregister, we set the thread's dispatcher to nullptr if it is this
object.

This has been a latent bug, so it's worth fixing. This started happening
for me with an un-pushed change that changed the order of how
QCoreApplication and QGuiApplication destroy the main thread event
dispatcher (namely, in their destructors, not waiting for ~QObject to
deleteChildren()).

Drive-by relax the store in QThread::setEventDispatcher().

Fixes: QTBUG-137130
Pick-to: 6.9 6.8
Change-Id: I8845736c38a931af62e3fffdfd3554874df89e8e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-05-25 13:24:27 -07:00
Thiago Macieira
08325952ee QThread/Unix: fix silly mistake: static was missing after refactoring
Amends commit 6763e25cbc16cf8c54ab9b1ef97030aab9bb0eec, which refactored
        static struct Cleanup {

to move the body if said cleaning up closer to the rest of the clean up
code in QThreadDataDestroyer::EarlyMainThread. But it accidentally
forgot the static keyword. As a result, we attempted to clean up before
::currentThreadData was set yet, resulting in a no-op and no clean up.

Task-number: QTBUG-135044
Task-number: QTBUG-134080
Task-number: QTBUG-133861
Task-number: QTBUG-132697
Task-number: QTBUG-102984
Task-number: QTBUG-132381
Pick-to: 6.9 6.8
Change-Id: Ibe40567bba8dea205401fffdb71f7e6a3be130e4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit b5e47fa433f218a47db98a370fbad97c70455e85)
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-05-25 16:58:28 +00:00
Thiago Macieira
1a54a03301 QLibrary/Darwin: don't use RTLD_NODELETE, just don't dlclose()
As the comment says, the OS does support the flag and a perusal of the
source code for dyld[1] shows it does handle the flag, setting an
internal flag called "leaveMapped", which is different from the
"neverUnload" flag. My guess is that it literally just leaves the memory
for the plugin mapped, but removes all links to it in the dyld internal
data structures.

That results in the Objective C runtime crashing when running content
from NODELETE plugins that has been dlclose()d. This probably explains
why lldb stops seeing those symbols too:

(lldb) f
frame #0: 0x0000000103872eb4 QtCore`QLibraryPrivate::unload_sys(this=0x000060000179c210) at qlibrary_unix.cpp:258:21
-> 258      if (doTryUnload && dlclose(pHnd.loadAcquire())) {
(lldb) target modules list libqcocoa.dylib
[  0] 81EB58D5-8D31-333A-9E8C-F2385F6EFCF4 0x00000001043de000 libqcocoa.dylib
(lldb) image lookup -vn QCocoaEventDispatcher::QCocoaEventDispatcher
2 matches found in libqcocoa.dylib:
        Address: libqcocoa.dylib[0x0000000000036480] (libqcocoa.dylib.__TEXT.__text + 190368)
        Summary: libqcocoa.dylib`QCocoaEventDispatcher::QCocoaEventDispatcher(QObject*) at qcocoaeventdispatcher.mm:776
...
(lldb) n

(lldb) target modules list libqcocoa.dylib
[  0] 81EB58D5-8D31-333A-9E8C-F2385F6EFCF4 libqcocoa.dylib[0x0000000000000000] libqcocoa.dylib
(lldb) image lookup -vn QCocoaEventDispatcher::QCocoaEventDispatcher

[1] https://github.com/apple-oss-distributions/dyld

Task-number: QTBUG-135044
Task-number: QTBUG-134080
Task-number: QTBUG-133861
Task-number: QTBUG-132697
Task-number: QTBUG-102984
Task-number: QTBUG-132381
Pick-to: 6.9 6.9.0 6.8
Change-Id: I7da3b3615a6ace7c72d1fffd5cf560d8f8a4e1bb
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-05-25 16:58:27 +00:00
Ahmad Samir
0c0b5d0ff0 QMetaObject: port qRemoveWhitespace() to QByteArrayView
Change-Id: Ib5754708f25bdb3ac9d6546deaf3182dbb7ed8a8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-05-25 10:54:52 +00:00
Assam Boudjelthia
054dfb50a0 Android: avoid no impl found for updateNativeActivity() at startup
It seems that try/catch and ignoring the exception is not enough
to silence the error message about no implementation found for the
native method updateNativeActivity() when it's invoked at the start
before the libraries are loaded. To fix that we can call it only
if m_stateDetails.isStarted assuming that it would mean the libraries
were loaded since the app has been started.

Pick-to: 6.9 6.8
Change-Id: Ic23ce16439000090e2661b2e6956bcd9954bf33f
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2025-05-24 18:37:30 +03:00
Assam Boudjelthia
98120622ff Android: guard against potential SecurityException in QtDisplayManager
Pick-to: 6.8 6.9
Change-Id: I45768069612c0b5492b490047902313383799334
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2025-05-24 18:37:23 +03:00
Friedemann Kleint
977b6daa92 uic: Handle horizontal and vertical layout size constraints (Qt 7)
Ignore vertical constraint and use the horizontal one for the
property.

Task-number: QTBUG-17730
Pick-to: 6.9 6.8
Change-Id: I6317ce8c1c1e2ac2bf6ae3b24a60735a72dcb7bc
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-05-24 07:10:43 +02:00
Thiago Macieira
ee04a324ce QTest::CrashHandler: add asyncSafeToHexString()
Extracted from existing code; I'm going to need it for some GDB/LLDB
commands in an upcoming commit.

Change-Id: I7bdb7ef287ecd924df5cfffdc5aa3617540f7756
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-05-23 20:36:45 -07:00
Thiago Macieira
a0c7ca3773 QTest::CrashHandler: use string_view for writeToStderr() for the inputs
For regular strings, it'll call strlen() for us, removing the need of
our doing it. We just have to remove the one case where we were passing
iovec into it: make asyncSafeToString() return a string_view too.

Change-Id: I7d17e5c4525637df23f1fffd5e5c381632386f49
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-05-23 20:36:45 -07:00
Thiago Macieira
2ef4ea3319 QTest::CrashHandler: reorganize Unix header blocks
Change-Id: Ib45e7e913fcc2e00f198fffdcc216e9f74c97e15
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-23 20:36:45 -07:00
Thiago Macieira
cf0c73e9fe QTest::CrashHandler: move the enum definition to the header
It's common between the two implementations, though currently completely
unused on Windows because we don't start debuggers.

Change-Id: I7a42db2db35cf6191693fffd3e4e46d482032630
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-05-23 20:36:45 -07:00
Thiago Macieira
0409fa9edd QTest::CrashHandler: move the Unix signal-handling code into the .cpp
This further reduces the size of the header.

Change-Id: I24a16daec8aed5a38e1ffffd812629cc7e7377f7
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-23 20:36:45 -07:00
Thiago Macieira
09edc851c5 QTest::CrashHandler: move the Unix async-safe I/O code to the .cpp
This declutters the header from code that doesn't need to be there and
is only used in the .cpp anyway. This code used to be in qtestcase.cpp
before commit c0014becca2cd376eadd5c8a0265e5cf47c9aa01, which we now
amend. Additionally, since Windows code doesn't need to be async-safe
anyway, we can simplify it.

I'm also going to need the toHexString() lambda in another place.

Change-Id: Ic9571bac864dfb31564cfffd785e8ab15cab3ae5
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-05-23 20:36:45 -07:00
Thiago Macieira
9a66c7c1b9 QTest::CrashHandler: move windowsFaultHandler() out of the class
It accesses no members (there are none!), which further simplifies the
header.

Change-Id: Ic1251d8b56dc6cfeb136fffd7baf4d8bc7143750
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-23 20:36:45 -07:00
Thiago Macieira
fc7c5c0a2b QTest::CrashHandler: move DebugSymbolResolver to the .cpp
It doesn't need to be in the header.

Change-Id: I2e80568174e6637c6be0fffde4837ac502f4641a
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-23 20:36:44 -07:00
Thiago Macieira
c9b68292b3 QTest::CrashHandler: split into Unix and Windows (2/2)
This file is convoluted and hard to read due to #if all over the place.
Let's split the two very different implementations.

This is the conclusion, which removes the Unix code from the Windows
file and the Windows code from the Unix file.

Drive-by remove the unnecessary header #includes.

Change-Id: Iec7bd36d0aeabdc3c445fffd17bad22050c6b208
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-05-23 20:36:44 -07:00
Thiago Macieira
fddb6fceaa QTest::CrashHandler: split into Unix and Windows (1/2)
This file is convoluted and hard to read due to #if all over the place.
Let's split the two very different implementations.

This is the first commit, which just copies the files around without any
changes, to help with Git history.

Change-Id: I758dad7a07d927ccb61dfffd0199fb5e1e544c98
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-23 20:36:44 -07:00
Tor Arne Vestbø
b6ffbebbbe Use QObjCWeakPointer to track QMacKeyValueObserver observed object
Otherwise we might run the risk that the observed object dies before
we try to do removeObserver.

Pick-to: 6.9
Change-Id: I2b54ff32728fc40fd47be2d14070fc43640f81bf
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-24 05:35:22 +02:00
Tor Arne Vestbø
1c98b3fe40 Use __weak for implementation of QObjCWeakPointer
By moving the implementation to qcore_mac.mm, and using a union
for the object pointer, we can build qcore_mac.mm with -fobjc-weak
to take advantage of the automatic weak-tracking. This allows us
to drop the manual handling via ObjC associated objects, while
also allowing non-Objective-C code to use QObjCWeakPointer.

In particular we want to use it for QMacKeyValueObserver, which
today runs the risk of removing the observation on an object that
is long gone.

Pick-to: 6.9
Change-Id: I5d605e5ac82b39223b246d6758d0da88a1702357
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-24 05:35:22 +02:00
Alexey Edelev
e7b3a094a0 Restructure android tests
Change-Id: I14bc0db28dcc928771b14a6854ba1c53d76461a7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-05-24 04:57:22 +02:00
Mårten Nordheim
31d84ed739 qt_noop is not defined in the qt-namespace
Causes compilation errors when qt_noop is used, like from QT_THROW when
compiling without exceptions.

Amends 88f2d7aacb17119aebc701fbf10f9c89d4e9b79a

Fixes: QTBUG-137104
Change-Id: I377e278bd6a1b5a4a3b5a58d52d5205fb9545ec5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-24 00:46:04 +00:00
Lauri Pohjanheimo
a6caa394ba Mark files as security sensitive
androidcontentfileengine.cpp
qandroidapkfileengine.cpp,
qandroidassetsfileenginehandler.cpp and
extract.cpp marked
Reasons: Data serialization, filename parsing

Task-number: QTBUG-136818
Task-number: QTBUG-135178
Task-number: QTBUG-136816
Pick-to: 6.9 6.8
Change-Id: Ib277a04cc00dc0762feed17a7f185aa5d19942dc
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-05-24 00:46:04 +00:00
Ahmad Samir
29a00e959b qdataurl: make parsing the content-type more robust
Don't assume `charset` is the first parameter. The parameters
(attribute=value pairs) are delemited by a `;`. The order of the
parameters isn't specified, (except for `;base64` which is the last
one).

Add more tests. Add a test for image/png (.png file copied from
src/widgets/styles/images/arrow-down-16.png).

Change-Id: Ie3e45c607c093695d0c180e9a9783b2b02d7ef70
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-24 01:12:55 +03:00
Ahmad Samir
d4960f380e qdataurl: use QLatin1StringView instead of QByteArrayView
This is URL data and we use toLatin1() to convert from QString to
QByteArray. QL1SV is more suitable here because we need to do
case-insensitive look ups into the <mediatype> (see
https://www.rfc-editor.org/rfc/rfc2397.html) part of the URL.

Drive by, use QL1SV::sliced() instead of mid(), the precondition has
already been checked.

Change-Id: I670c41fdb6728f6420b1a4e2046357013ea210e0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-24 01:12:55 +03:00
Ahmad Samir
0b8f0123e0 qdataurl: optimize by using QByteArray::fromBase64Encoding()
It takes by rvalue and does the decoding in-place.

Change-Id: Ie49c46128b52d302ea69786471756039936ec7e1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-24 01:12:55 +03:00
Ahmad Samir
cec5066f32 qdataurl: treat comma as mandatory in the data URL syntax
In the syntax specified in https://www.rfc-editor.org/rfc/rfc2397.html:
data:[<mediatype>][;base64],<data>

The comma isn't inside square brackets, so not optional.

Change the unittests accordingly, "data:text/plain" isn't empty data,
it's rather malformed.

[ChangeLog][QtCore] Changed parsing 'data:' URLs to report failure if
the comma is missing, this makes it more compliant with RFC 2397.

[ChangeLog][QtNetwork][QNetworkManager] Changed parsing 'data:' URLs to
report failure if the comma is missing, this makes it more compliant
RFC 2397.

Change-Id: I91c45f42257de7840ab45c0f8eb31b8df3d483bc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-24 01:12:55 +03:00
Ahmad Samir
71bcd74542 qdataurl: don't set the mime type too early
If there is no actual data to decode, setting the mime type is
redundant. Also only set the mime type to the default if none is
specified in the URL.

Change-Id: I19f7ae98c7f1f4483069f580bea028a84a719656
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-24 01:12:55 +03:00
Ahmad Samir
8df6859f08 Fix various compiler warnings
tst_QDebug: variable is only used conditionally

tst_QTimeZone: fix string literal format

QRhiWidgetPrivate: unused local variable `q`

Change-Id: I8f9d7f86df2ff781f8ab64bee44dbebbe67eb6f3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-24 00:12:55 +02:00
Ahmad Samir
42ee6adff7 tests/manual/*: add missing includes
Change-Id: Id3abd673d22bd6365bec4688c41c0b57d7aabc0b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-24 00:12:54 +02:00
Tor Arne Vestbø
4a7ccb65f0 Lazily create global share context when Qt::AA_ShareOpenGLContexts is set
The requirement to set Qt::AA_ShareOpenGLContexts before creating QGuiApp
was forcing users to also set the default surface format before QGuiApp,
which prevents us from initializing a default surface format based on
the platform integration.

By creating the global share context lazily when requested via the
Qt::AA_ShareOpenGLContext application attribute we open up this
possibility.

Change-Id: I958639c997e96321013b1080c31e2533a36c13ff
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-05-23 17:42:46 +02:00
Jarek Kobus
868fc456ac TaskTree: Fix coverity scan issue (initialization of destruction)
Coverity-Id: 479704
Pick-to: 6.9
Change-Id: Icae0c4183c29bc3646d6dd1786215e8bdbb3bf7f
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2025-05-23 14:01:31 +02:00
Jarek Kobus
f148cc3827 TaskTree: Fix some coverity scan issues (use std::move)
Coverity-Id: 462757 462760 462768 480367
Pick-to: 6.9
Change-Id: I56c17ba925459661f425ef72eeb1d397094e5a90
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2025-05-23 14:01:31 +02:00
Rami Potinkara
d99a7ca3c1 Android: qtbase/src/android/jar.../QtView.java security sensitive
This patch marks following files as security sensitive: executing-external-code
-QtView.java - loading library in QtView(Context context, String appLibName)
function parsing the external executable library name from external
CMakeList.txt file.

Fixes: QTBUG-136813
Task-number: QTBUG-135178
Pick-to: 6.9 6.8
Change-Id: I095f845459741312296f278d100dedb1bc9b3355
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-05-23 11:06:16 +00:00
Assam Boudjelthia
e96a4b84e1 Android: consider DecorView insets at app startup
Set the initial safe area margins based on the decor view as a
workaround since setOnApplyWindowInsetsListener() is not being called
reliably at startups. This way we can get the app's initial insets at
startup, then after that rely on each window reporting its insets.

And apply this initial inset only for top level windows that match
the screen size, i.e. we assume edge-to-edge is enable in that case.

Pick-to: 6.9
Task-number: QTBUG-135808
Fixes: QTBUG-135283
Fixes: QTBUG-135227
Change-Id: Ic5771809c94302b927ccc67ccc07c73ccc73b91d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-05-23 11:42:02 +03:00
Bartlomiej Moskal
6de8ce2af3 Android: Set correct initial selection values in EditorInfo
Previously, when a TextInput field was pre-filled with text,
focusing the input would cause the keyboard to behave incorrectly.
Typing any character would duplicate the last word. This appeared
to be caused by the keyboard reapplying a composition segment
(e.g., the last word), without a proper pre-edit region
defined—resulting in the word being appended again.

This issue is resolved by correctly setting
EditorInfo.initialSelStart and EditorInfo.initialSelEnd when the
InputConnection is created. Properly initializing these values
ensures the IME (input method editor) can synchronize with the text
field correctly. It can be found in [0]documentation:

  "Also, take good care to fill in the EditorInfo object correctly and
   in its entirety, so that the connected IME can rely on its values.
   For example, EditorInfo.initialSelStart and EditorInfo.initialSelEnd
   members must be filled in with the correct cursor position for IMEs
   to work correctly with your application."

[0]https://developer.android.com/reference/android/view/View#onCreateInputConnection(android.view.inputmethod.EditorInfo)

Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-135481
Change-Id: I5ae5a2fb22f285154ba3857033506d367bfd7642
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
2025-05-22 21:47:23 +02:00
Alexey Edelev
a867a16ef0 [Android] Skip goodToCopy check
Skip the goodToCopy check for the libraries that do not belong to
the main ABI. The rationale of this descision - goodToCopy was passing
in per-ABI build already, so we don't need to take care about this
check in main-ABI build. Also we indroduced the last-stand check of
bundled libraries in 7499fd0229d63f969bf6ca58d3b764b96395bed2.

Fixes: QTBUG-136493
Pick-to: 6.8 6.9
Change-Id: I438af867b0f25e0ea557bb5066f1c243bb6ab356
Reviewed-by: Bartlomiej Moskal <bartlomiej.moskal@qt.io>
2025-05-22 20:37:35 +02:00
Alexey Edelev
7aa2d1f5de [Android] Store the main ABI in deployment settings
Add the main Android ABI to the deployment settings. It's useful
for skipping functionality that is done in per-ABI builds.

Task-number: QTBUG-136493
Pick-to: 6.5 6.8 6.9
Change-Id: I9f59ffb1cae3107bbe695d99c33dd3426c163e6e
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-05-22 20:37:35 +02:00
Edward Welbourne
4b3a1bf272 Clean up some coding standard violations in MIME type code
Trivia, noticed while assessing security risk.
Stray braces where they aren't needed.
Long lines: reflowed comments and split a declaration.

Task-number: QTBUG-135191
Change-Id: I3e19673fc35bd7ee12a6e62849d12810e8997cdf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-22 20:37:35 +02:00
Edward Welbourne
578852f4ca Correct two misleading comments
Of course ucs4 >> 32 would be zero, as it's only a 32-bit value to
begin with; and the pattern of later bytes actually processed makes
quite clear what offsets the two short-cut ones really come from.

Brought to light while reviewing assessment of security level.

Task-number: QTBUG-135187
Change-Id: I8af6b5c935de400f3ac1c2efae297b0333891d64
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-22 20:37:35 +02:00
Oliver Wolff
b268177bf8 Small code cleanup
pathElements[n] cannot contain '/' as they are result of "split(u'/')"

Change-Id: I2a3c4651f65aa2731947a514a1f18660a95063ca
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-22 20:24:24 +02:00
Oliver Wolff
73c5c15d68 QFileSystemModel: Handle drive root paths properly on Windows
Fetching a node that was a drive root path (C:/) ended in a wrong result
on Windows. Instead of the drive root the QFileSystemModel returned the
current working directory. This was due to the fact that the code in
QFileSystemModelPrivate::node stripped the /s from the "path elements".
As "C:" (in contrast to "C:/") is seen as a relative path on Windows
that lead to wrong results.

Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-133746
Change-Id: I642a67853f31ad9b6710e2b5f696f22b1f60ead3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Miguel Costa <miguel.costa@qt.io>
2025-05-22 20:24:24 +02:00
Rami Potinkara
7796ad3fac Android: qtbase/src/android/. ./QtAndroidBinder.java security sensitive
This patch marks following files as security sensitive
-QtAndroidBinder.java - parsing data in onTransact(.., Parcel data,...) from
external source over IPC mechanism

Fixes: QTBUG-136815
Task-number: QTBUG-135178
Pick-to: 6.9 6.8
Change-Id: I022ee98be57a1a5b09beb7ccd07b4c04da612d2e
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-05-22 17:41:57 +00:00
Aurélien Brooke
5d679be9ff rhi: vulkan: use the vmaCopy* utility functions
- This simplifies the code from our point of view: the (invalidate-)map-
memcpy-unmap(-flush) dance is done by the VMA.
- In the read case, this adds an invalidate before the read.
- The flush/invalidate errors are handled and now print an error.

Change-Id: Ib29b9446796938f7b77c18976858a0ccf55c448a
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-05-22 19:41:57 +02:00
Jani Korteniemi
30f5ad0329 Mark qtbase/src/android files as security sensitive
QtApkFileEngine.java
-File/Data parsing

QtClipboardManager.java
-Text/Url parsing

QtEditText.java
-Password input type

Pick-to: 6.9 6.8
Fixes: QTBUG-136730
Task-number: QTBUG-135178
Change-Id: Ib2b574825e1f4acdc96c7bc781dbae00a274bd50
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-05-22 20:14:56 +03:00
Bartlomiej Moskal
604231deaf Mark androidjnimenu.cpp as security sensitive
QtAndroidMenu trying to parse the String by removeAmpersandEscapes
function.

Pick-to: 6.9 6.8
Task-number: QTBUG-136817
Task-number: QTBUG-135178
Change-Id: I840607666f72d7a5813520c2aa183f1bf7082470
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-05-22 17:14:56 +00:00
Tor Arne Vestbø
ee78c173e9 macOS: Port from deprecated NSAppearance.currentAppearance
When the system appearance changes, it will be reflected through
NSApp.effectiveAppearance, but NSAppearance.currentAppearance
and NSAppearance.currentDrawingAppearance will remain as is for
some reason (perhaps as a compatibility for apps that were not
ready to handle dark mode).

The original way to deal with this was to explicitly set the
NSAppearance.currentAppearance to the new effective appearance,
which would take effect for the thread from that point on. But
this API has been deprecated, most likely because overriding it
globally could mess up views or logic that was not prepared for
dark mode).

The replacement API, NSAppearance performAsCurrentDrawingAppearance
is given a block, and will only override NSAppearance.currentAppearance
during the block, which isolates it from other fragile components.

We generally use NSApp.effectiveAppearance in our own code when
resolving dark mode, so we only need to wrap AppKit APIs we use
with performAsCurrentDrawingAppearance, including NSColor for our
palette, and NSView/NSControl drawing in our styles.

For the latter case we introduce a helper that we can also use
in the Qt Quick Mac style. This helper can also be the basis
of shared style functionality between Widgets and Quick going
forward.

Fixes: QTBUG-135789
Done-with: Volker Hilsheimer <volker.hilsheimer@qt.io>
Change-Id: I4d006b8b1fbbd7ff888da8b903066c183adad188
Reviewed-by: Doris Verria <doris.verria@qt.io>
2025-05-22 18:21:37 +02:00
Marc Mutz
82015992c8 tst_QScopedPointer: add a test for reset/delete ordering
We have implementation divergence with libc++'s ~unique_ptr()
behavior, so make sure QScopedPointer behaves the same way as
unique_ptr is spec'ed, even though to check it, one has to rely
on UB, at least according to LLVM devs (I don't think the test
as written invokes UB).

Code's a bit duplicated. I tried making the struct a template,
but it's just too much of a fuss (needs a variable template,
which we can't use in Qt 5), so I decided to use cut'n'paste.

Task-number: QTBUG-137069
Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I8b55718eaf3c6ad9a4d89d4fc9d64f0c41bb21fa
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-05-22 12:08:48 +00:00
Ahmad Samir
b9c9215406 QNetworkDiskCache: construct a QFile on the stack
The QFile object is only used in its scope:
- `remove(url)` indirectly removes the file from the disk
  cache (by constructing another QFile) then immediately returns
- if the file could be read, all the read data is stored in a QBuffer,
  the QFile isn't needed after that

Amends c254d73be63033497838807119cb9cb47ca6c1fa.

Pick-to: 6.9
Change-Id: I714dcc619b8f5ed887f111395967d674ec875d6e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-05-22 07:14:30 +00:00
Joerg Bornemann
66803a863e CMake: Fix backup/restore of QT_NO_PRIVATE_MODULE_WARNING
...in _qt_internal_find_qt_dependencies. In the case where a package is
loaded via its own dependencies (Qt6FooPrivate -> Qt6Foo ->
Qt6FooPrivate) the inner _qt_internal_find_qt_dependencies call did
unset the backup value of QT_NO_PRIVATE_MODULE_WARNING. This could lead
to an unwanted display of the private module warning.

Treat the backup variable as a stack to deal with this situation.

Pick-to: 6.9
Change-Id: I0ee3700a040b0df8c6090470ea6fc515cb93a7d6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-05-21 22:22:18 +02:00
Audun Sutterud
4623def5fb Rename QDecompressHelper benchmark
The convention is to start the benchmark names with the "tst_bench_"
prefix. This makes it easier to detect the benchmark in tools, such as
the Core Benchmarks Runner.

Change-Id: I2dcebb6cef0aba4133c4135462e8d76387b776bf
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-05-21 20:36:55 +02:00
Marc Mutz
0a9d5bd476 QTriangulator: make primeForCount() safer
Move all the helpers into the function so nothing else can call them
(out of contract).

As a drive-by, adjust the comment to mention this is Qt 5 QHash
snippets; Q6Hash is different these days.

Pick-to: 6.9 6.8 6.5
Coverity-Id: 11295
Change-Id: Id1a23030e325076d81592e351dfe804742a21a87
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-21 16:57:21 +00:00
Piotr Wiercinski
8a9c2ca505 wasm: Export wasmglobal functions for dynamic linking
Change-Id: I73a6baa2da99ceb734197b33c18765fb9b372fe1
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-05-21 18:57:21 +02:00
Alexey Edelev
14081c086f Remove the _qt_is_android_executable property
Change-Id: I84095663ded465fa0cba29f4b4c36c2498fdb10f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-05-21 16:02:47 +02:00
Samuli Piippo
0a6647a1ed CMake: don't install wayland files in standalone build
The test and example standalone builds should not install
the wayland files.

Change-Id: If313479c8e17325cc3761fea093368f14d484d74
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-05-21 13:40:08 +00:00
Marc Mutz
0a7ee06b27 Mark QXmlStream{Reader,Writer} as security-critical
If QXmlStream isn't security-criticial, what is?

qxmlstream.h contains the definition of the QXmlString work-horse, so
it has to be security-critical, too (until we remove it).

Amends 8df072fc8006510c9b743e8ffedaaf51a876883a.

QUIP: 23
Task-number: QTBUG-135194
Pick-to: 6.9 6.8
Change-Id: Ib366e63fb89aa0b69ad437f6688285b2c390c5c1
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2025-05-21 11:47:36 +00:00
Kai Köhne
e89912460f Doc: Rewrite paragraph concerning OpenSSL 1 compatibility
Qt 5 compatibility details are not relevant for Qt 6.
Instead, make it explicit that the binary builds require
OpenSSL 3.

Pick-to: 6.9
Change-Id: I610254026e35def8f8206cd7c7e3015b2197852c
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Alexei Cazacov <alexei.cazacov@qt.io>
2025-05-21 06:07:33 +00:00
Ahmad Samir
1b66b6533e QString/QByteArray: add tests for replace() with negative lengths
Change-Id: I6bb67a65fdb0d61e1e1e36dd271c98df7849a305
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-20 23:30:49 +03:00
Ahmad Samir
ef0b8bc730 tst_QString: don't cast index/length to uint in replace() tests
Most of QString's API take by signed values, so let the tests match
reality.

Also, as pointed out in the code review, use qsizetype instead of int.

Pick-to: 6.9 6.8 6.5
Change-Id: I03cba8e35d080454506a35a956ad106fd9bb3246
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-20 23:30:32 +03:00
Christian Ehrlicher
3252e1808c QWidget: don't re-polish when style did not change
Don't call style->unpolish()/polish() when the old and new style did not
change which might happen when setting a style sheet as this might
create an infinite loop and the style (re)sets some window attribute.
Bailing out early is not an option here as newStyle might be a nullptr so q->style() will fall back to the application default style.

Pick-to: 6.9
Fixes: QTBUG-133332
Change-Id: Ifa9ee4fdfa64b2768337e2d90b7bbaac5f3fcd70
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-05-20 21:00:41 +02:00
Magdalena Stojek
263f06ae8b QXmlStreamWriter: add option to stop writing after an error
By default, QXmlStreamWriter continues writing even after encountering
an InvalidCharacter, EncodingError or CustomError, which contradicts
expected behavior.

This change introduces property stopWritingOnError with two new
functions: setStopWritingOnError() and stopWritingOnError(), allowing
users to control whether output halts immediately after the first such
error.

[ChangeLog][QtCore][QXmlStreamWriter] Added setStopWritingOnError() and
stopWritingOnError() functions.

Fixes: QTBUG-135861
Change-Id: Ia3ba894fc5bd8c5ff3a548e2585af9d435dec9b2
Reviewed-by: Safiyyah Moosa <safiyyah.moosa@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-20 20:33:49 +02:00
Marc Mutz
603499d2e7 QPainter: make ownership transfer more explicit
The push_back(get()) / Q_UNUSED(release()) was an attempt to separate
the reallocation from the release of the unique_ptr, to avoid memory
leaks in case the reallocation fails inside push_back(), at a time
when unique_ptr::release() had already been called.

Coverity doesn't understand this pattern (and many human readers
won't, either), so change this into an emplace_back(), followed by a
release() into the return value of emplace_back().

Since assignments evaluate right to left, we need to separate these
two actions into separate statements, otherwise we'd end up in the
same situation as described for push_back(release()) above. Add a
comment explaining the problem.

Amends the start of the public history.

Coverity-Id: 425479
Pick-to: 6.9 6.8 6.5
Change-Id: I727aaf791d7b523cd6e7301c49c152b4b6e80dd2
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-05-20 20:33:49 +02:00
Lars Schmertmann
ed76f816e6 Android: Avoid deprecation warnings (Space-assignment syntax)
Space-assignment syntax in Groovy DSL has been deprecated.
This is scheduled to be removed in Gradle 10.0.

Pick-to: 6.9
Change-Id: I2029af79b25351337c32db96053548ce5f4f47ae
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-05-20 20:33:49 +02:00
Marc Mutz
1285dbeb3c tst_QDataUrl: add a test with spaces around the charset parameter
Requested by Ivan Solovev in review.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I2f3dee8aad16af6748faa7660e2508e8ecd1709f
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-05-20 18:33:49 +00:00
Matthias Rauter
64693034ae Replace long for-loop-headers with short modern version
Change-Id: I0bf037e0a2483cc6e98a3336f878c46b31f92447
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-20 19:19:34 +02:00
Rami Potinkara
f9af480ed2 Android: update clang compiler detection
This patch updates the clang compiler detection to
allow Clang version 2010 and above to use C++26
macros.

This will allow Qt Android x86_64 build on dev to compile.

Fixes: QTBUG-136968
Pick-to: 6.9
Change-Id: I0988169e6e10357f0e210c3911843e6d04a43c0d
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2025-05-20 19:27:54 +03:00
Samuli Piippo
c18a773355 CMake: fix __qt_internal_collect_additional_module_paths
When the additional path did not point to cmake path, the
loop was using non-existing variable.

Pick-to: 6.9 6.8
Change-Id: Ie9599231599c3b90125825414956e345634c85ef
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-05-20 16:27:53 +00:00
Liang Qi
7cde375513 gui: support to build wayland on FreeBSD
Change-Id: I597b8d485307c9ba21499dc1a51d8567361530bc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-05-20 16:24:55 +02:00
Laszlo Agocs
97f7819f1d offscreen: Enable backingstore images with alpha
Grabbing a QQuickWindow (software backend) cleared to something
semi-transparent is not going to be correct otherwise.

Pick-to: 6.9 6.8
Task-number: QTBUG-136755
Change-Id: I59f378b177154af25b1d7bff878435c715e3d114
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-05-20 13:58:39 +02:00
Aurélien Brooke
44b5602536 QMetaType: use sized delete to deallocate a value
When destroying a value created by QMetaType::create(), pass the size
to operator delete. This allows allocators to potentially optimize the
deallocation.

The size passed is always the one used during allocation, iface->size.

As a drive-by, make the operator() function const.

Change-Id: I3224af525671d98327d21033d059f52620fbb837
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-20 08:04:29 +02:00
Ahmad Samir
bee20b2137 tst_QByteArray: create separate tests for replace() overloads
Change-Id: I576230a3e130ddf8e0124a8a1174a99a64dc691e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-20 02:50:03 +03:00
Ahmad Samir
a15639a3ab QByteArray: make replace(pos, len, view) consistent with QString's
Return early if `pos` is out-of-bounds.

Amends 57d91d8029064b592dee8adf819bde676763df28 (also part of this
commit message was borrowed from it).

[ChangeLog][QtCore][Important Behavior Changes][QByteArray] replace()
is now consistent with QString::replace() in its treatment of
out-of-bounds indexes.

Change-Id: Iae8cf795364654fd6438b2a4ed3162925a73cb9e
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-20 02:50:03 +03:00
Thiago Macieira
2da64908c2 QTest::CrashHandler: ask GDB for the memory mapping layout on crash too
Processes usually crash due to invalid pointers, but sometimes it's hard
to know if a given value is valid or not just by eyeballing it. So let's
ask GDB to print it.

I don't think LLDB has a way to do it.

Pick-to: 6.9
Change-Id: I35e35bd3b79eeba49192fffd61474054cd089301
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-19 14:46:36 -07:00
Kai Köhne
a6070847f0 qlogging: Journal: Log thread id, suppress empty fields
The TID field can be used to differentiate the threads of a process
where the message originates from. This allows to create a timeline
of events when identical messages are created from multiple threads,
or filter out messages from "uninteresting" threads in post-processing.

The file/line/func fields are typically empty for non-debug builds, so
storing these in the journal with dummy values is a waste of CPU time
and storage.

Use sd_journal_sendv instead of sd_journal_send, as that allows to vary
the number of sent fields, and skip the ones without actual information.
It is also slightly more performant, as it avoids the var-arg handling,
sprintf parsing and formatting etc. done by sd_journal_send.

[ChangeLog][QtCore][Logging] Qt now logs the thread id (TID) in journal,
allowing separation of identical messages from multiple threads.

Fixes: QTBUG-120047
Fixes: QTBUG-120048
Change-Id: Iccf3fe708dc4b896161693e13fb9012686bd1871
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-19 18:50:25 +00:00
Ivan Solovev
927798f5de QXmlStreamReader: try to keep the source encoding of the added data
The QXmlStreamReader(QAnyStringView) constructor, as well as the
QXmlStreamReader::addData(QAnyStringView) method were almost always
converting the UTF-16 and Latin1 data to UTF-8.

This commit tries to avoid unnecessary conversions by storing the
data together with its encoding.

As a result, we now have two decoders:
* a chunkDecoder is used when the encoding of the provided chunk
  is supplied along with the data;
* a document-global decoder is used when decoding raw data that
  is provided by QBA overloads. It tries to infer the encoding
  from the content, or explicitly uses the "encoding" attribute,
  if it was provided. This is the pre-existing behavior.

This patch has several corner-cases, mostly related to the fact
that the XML parser tries to read the XML prolog and extract the
encoding from it.
For example, what happens if we pass a QString (UTF-16 encoded)
that has an XML prolog with Latin1 encoding?

  const QString data =
      u"<? xml encoding=\"iso-8859-1\"?><foo>ÄÖÜ</foo>"_s;
  QXmlStreamReader reader;
  reader.addData(data);
  reader.readNextStartElement();
  const QString text = reader.readElementText();
  QCOMPARE(text, u"ÄÖÜ"_s);

The data inside the "<foo>" block can be represented by Latin1,
but because we used QString to store it, it's already in UTF-16.

This patch uses UTF-16 chunkDecoder to decode the data, but at
the same time sets the document-global decoder to Latin1, so
that the next raw data will be interpreted as Latin1.

At the same time, if the provided encoding is not recognized,
the document-global decoder is set to UTF-8, for backwards
compatibility.

The code path that uses an underlying QIODevice is unmodified.

The patch does not add any new public APIs, so theoretically can
be cherry-picked to older branches, but I'd prefer to have some
testing on the current dev to make sure that it does not introduce
any regressions.

Fixes: QTBUG-124636
Change-Id: I89bf0cbbcf21d7533d99e56b2522dcced9f675eb
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-19 20:50:25 +02:00
Tor Arne Vestbø
2a9444920b macOS: Make NSServicesMenuRequestor implementation rich-text aware
The protocol is used by services that interact with content in the
application on behalf of the user.

So far we have only been able to deal with plain text content,
which resulted in wiping any formatting if the user tried to
use a service to rewrite text in a rich text document.

We now support rich text, by teaching our IM protocol how to
deal with rich text for both reporting of the current text
selection, as well as text insertion (commit).

Unfortunately this doesn't help us for Writing Tools, as in
15.2 it no longer uses the NSServicesMenuRequestor protocol
for insertion if we also implement NSTextInputClient. As
a result we get insertions via insertText:replacementRange:,
which is not prepared for rich text yet.

[ChangeLog][macOS] Text services via the Services menu now
support rich text extraction and insertion.

Task-number: QTBUG-126238
Change-Id: I3d2933d766af8fe29e4f17636f703a257bf389fd
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-05-19 19:42:30 +02:00
Even Oscar Andersen
5c82db79d9 wasm: ignore keypresses if alt and numeric keyboard
When left-alt + num lock activated + number pressed the number
was inserted in the text. However in this input mode a 4 digit
keycode is used to insert a special character, it is wrong to
insert the individual digits in addition

Fixes: QTBUG-136799
Pick-to: 6.9 6.8
Change-Id: Iebafd1dfe5df1701a87a824ed99a440b122f0c57
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-05-19 18:03:29 +02:00
Even Oscar Andersen
ac710784af wasm: Handle exceptions in promise
Fixes: QTBUG-136962
Change-Id: I2d33b0132a83945b476f0f47fa4697ddaa2374b3
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-05-19 18:03:29 +02:00
Even Oscar Andersen
c3c51dd5d1 wasm: a11y - move to describedbycontainer
aria-description is more rarely supported than aria-describedby.
So switch to the latter. Create a new container inside the
a11yContainer.

Handle DescriptionChanged to update description in one place only

Task-number: QTBUG-134657
Change-Id: I0d025e5739451e6fab133c2590fd20ea13e2d946
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-05-19 18:03:29 +02:00
Piotr Wiercinski
a13d84b56a wasm: Fix parsing HTTP header values that contain colon (:)
According to RFC 7230 header values can contain colon(:). Fix
parsing HTTP headers to handle such cases correctly.

Fixes: QTBUG-136812
Pick-to: 6.5 6.8 6.9
Change-Id: I371342c5d84744e0427eb23fb1b648f8c0f0c9fe
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-05-19 16:03:29 +00:00
Morten Sørvig
a65554044c wasm: enable previously disabled tests on WebAssembly
The supported configurations for running tests on WebAsssembly
are:

  * -device-option QT_EMSCRIPTEN_ASYNCIFY=1" [old way]
  * -feature-wasm-jspi -feature-wasm-exceptions.  [new way]

(Non-asyncify/JSPI configs may work for some tests, especially
non-GUI tests).

In general all tests are now enabled for the wasm build so that
we can run the tests locally, even tests which fail/crash/hang.

Use QT_BUILD_WASM_BATCHED_TESTS to disable tests which should
not run on CI.

Task-number: QTBUG-121822
Change-Id: I20fac091d4d55bd1c947eeeb128a42a382dc11f0
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
2025-05-19 16:03:29 +00:00
Samuli Piippo
68346b2d1c CMake: try to find qmltestrunner from additional paths
Use QT_ADDITIONAL_PACKAGES_PREFIX_PATH to look for qmltestrunner.
Needed if module install is using separate staging prefix, like is
done on Yocto builds.

Change-Id: Icfe972a7ab1d0c99518383eab1c885e490cdb4d6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-05-19 16:03:29 +00:00
Laszlo Agocs
d22660a09d offscreen: Return the requested window format
Not the default constructed QSurfaceFormat.

If the window had alphaBufferSize set to some value, we want that
value returned from the platformwindow too.

Pick-to: 6.9 6.8
Task-number: QTBUG-136755
Change-Id: Ie0b51b773e0127cac797607a52947bba7ec5eba0
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-05-19 11:04:06 +00:00
Mårten Nordheim
b0b9adf066 Http2: remove any reference to HttpReply when deleted
Prior to switching the protocol handler to use QHttp2Connection this
particular issue (see bugreport) was not a problem because the handling
of the IO-device being destroyed was simply to drop any pointer to
it.
QHttp2Stream, however, also has to keep track of the lifetime of
the IO-device, because it needs to abort the stream if the data
it's uploading is destroyed earlier than expected.

Now, since QHttp2Stream might also have other errors come up, we
have to connect to the generic 'errorOccurred' signal from it and
handle whatever issues arise, notifying our users that the request
for some reason cannot be fulfilled.
It's thanks to this part that we were now, in certain cases,
grabbing a stale pointer to the HttpNetworkReply and trying to
call functions on it.

We fix this somewhat indirectly. Because, after a HttpReply is
destroyed, we shouldn't even have any references to it in the
first place. And while it would usually be done as part of
handling the deleted() signal, we actually disconnect from
HttpNetworkReply's signals when we have processed one of the
finished*() functions. But since we were still connected to the stream's
signals we would still try to handle it.
For the http1 protocol handler this was already handled in
QHttpNetworkConnection::removeReply, which the HttpNetworkReply itself
calls at start of destruction. The function will go through any place
that the reply can be referenced and removes it. For http/2 it would
remove it from the list of requests yet to be sent, but not from the
in-progress list. So, we now add a new virtual function to the
AbstractProtocolHandler and specialize it in Http2 to handle exactly
this.

Fixes: QTBUG-136549
Pick-to: 6.9.1 6.9
Change-Id: Ie41863677a3b163f77d10bc3904ca515f6840be3
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-05-19 13:03:27 +02:00
Inho Lee
7be5b47617 wayland textinputv3: initialize missing internal states
When entering surfaces, there are some internal states which
should be initialized before update.

When updating states, 'commit' will always be called by needsCommit
without checking flags.
It amends ea32a4946ac517031b70237a831c99e02acc4361,
but surface enable will make needsCommit true when 'enter'.

Moved from 4cc415157d09534aede41829c5c7cf0aac578720

Fixes: QTBUG-135921
Task-number: QTBUG-131983
Change-Id: Id48d64579adc49e4ecb929a892f9dfe742578dad
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-05-19 12:17:14 +02:00
Inho Lee
a25054d33d wayland keyboard: suppress a warning for NO_KEYMAP
Some compositor calls send_keymap with WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP
and it repeatedly makes "unknown keymap format" warnings.

Moved from 7f78afdc9657d2393e98a8244bafc076b569d845

Change-Id: I92564fbe579bac5a56f0a842ac1b065330343ab5
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-05-19 12:17:14 +02:00
Eskil Abrahamsen Blomfeldt
306e68939c Fix regression when selecting special font styles
The fix for QTBUG-131574 aimed to make it possible to have
multiple fonts in the same family with the same style name.

It, however, inadvertedly made it impossible to have multiple styles
of a font for which the typical font properties did not differ. This
was especially bad for variable fonts.

So in the case of e.g. Roboto Flex, where the "Italic" is not
recognized as an italic font, as it does not set the "ital"
axis, we would overwrite the default subfamily (Regular) with
the Italic, because these would be seen as the same.

This was not intentional, and this patch fixes it so that when
we enter fonts into the database, they have to match both on
style name and properties, otherwise we will register them as
a new font. So identical subfamilies will still be supported.

Pick-to: 6.8 6.9
Fixes: QTBUG-135977
Fixes: QTBUG-135315
Change-Id: I9fd673e7b1061af69cd27049311565a14a145aa4
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
2025-05-19 07:27:29 +02:00
Elias Toivola
52fe1d9d9e Windows 11 24H2: skip crashing tst_qnetworkinformation_appless
Current Windows 11 24H2 build version is 26100. It is assumed Windows 11
25H2 build version will be >26200, this is added to the if-condition so
>25H2 will not be skipped.

Task-number: QTBUG-136628
Task-number: QTBUG-135599
Change-Id: I2d39fd4f9db546f2d7c7db17f6569708255579b3
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-05-18 18:40:00 +03:00
Elias Toivola
0cd5788ab3 Windows 11 24H2: mark tst_QDnsLookup::lookupNxDomain as expected to fail
Task-number: QTBUG-136627
Task-number: QTBUG-135599
Change-Id: Ib336f6e8018d210a80d50fdd4c1c50f691232104
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-05-18 17:40:00 +02:00
Nodir Temirkhodjaev
bdb46a306c plugins/styles/modernwindows: Fix build with -no-feature-commandlinkbutton -no-feature-inputdialog
Change-Id: I320c3b7ae29fba31c4929a31d05e47bdbb5a5472
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-05-18 17:31:11 +05:00
Tor Arne Vestbø
876bf141cf Windows: Update layered state on creation instead of backingstore flush
The WS_EX_LAYERED state of a window can be determined on creation, and
the logic to do so should be centralized to QWindowsWindow::setWindowLayered,
so that we don't have divergence.

This fixes an issue where child windows would only support transparency
if they had Qt::FramelessWindowHint set, as the QWindowBackingStore had
a different idea about when to enable WS_EX_LAYERED than QWindowsWindow.

Task-number: QTBUG-122590
Task-number: QTBUG-135859
Pick-to: 6.9 6.8
Change-Id: I453967a5a2ce8974cdd1dbf6e36327e97384c33d
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Zhao Yuhang <2546789017@qq.com>
Reviewed-by: Pavel Dubsky <pavel.dubsky@qt.io>
2025-05-18 00:37:05 +02:00
Tor Arne Vestbø
369d975c90 Add QPlatformTheme::ScrollSingleStepDistance theme hint
The hard coded value of 20 used in various QAbstractScrollArea
subclasses does not represent the default behavior on all of
our platforms. On macOS e.g. the native NSScrollView has a
default line scroll value of 10 pixels.

The default value isn't changed for macOS in this patch, as it
has to be done in coordination with other changes to make the
behavior change atomic.

Task-number: QTBUG-130667
Change-Id: I532dbd3e2e946a00f426475adfa851d35a656c1b
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2025-05-18 00:37:02 +02:00
Thiago Macieira
498ae026e9 QCharacterSetMatch: extend it to support larger ranges
An array of 1 or 2 quint64 will be the typical case for ASCII searches.

Change-Id: Ic144352cbb5746c1a353fffd410ffad4168684d1
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-17 08:37:04 -07:00
Inho Lee
c3c572b108 wayland textinputv3: reset cursorRect when enableSurface
When enabling a surface(including entering a surface),
set_cursor_rectangle can be missing if the previous value
is the same as the current one.

Moved from 31762ec9b7ee9de84d85cb9be77c9f50a3c8d2e7

Done-by: lilydjwg li
Fixes: QTBUG-135341
Change-Id: I2356a24fcc44a71211b53a3a8c73192895a0de02
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-05-17 11:40:38 +02:00
Tor Arne Vestbø
16916d9290 iOS: Update RLIMIT_STACK when running with user-main stack
When running the user's main() we retarget the stack pointer to a custom
stack, with half the size of the main thread stack (i.e 512K instead of
1MB). During execution of the user's main() we want code that reads
RLIMIT_STACK to be aware of the limited stack space, as this might impact
where memory guards are placed, or how stack overflow is detected, such
as in the V4 QML engine.

Once we return from the user's main() we restore back to the original
stack size limit. We also handle re-entry into app.exec() as well as
app termination, by always making sure RLIMIT_STACK reflects the available
stack space.

Unfortunately we can't do the same for pthread_get_stacksize_np, as once
the main thread has been created we can't tweak the stack size, and the
pthread_get_stacksize_np function does not query the rlimit on iOS, as
it does in some cases on macOS.

Change-Id: I48e92e762e125cff0f7da2003c7a1e796835d391
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-05-17 11:40:38 +02:00
Artem Dyomin
546192a6fe QGIM: move tree and table implementations to the impl header
It improves readability of the public header significantly.
No functional changes.

Change-Id: I47aee378dddf2c08890d55f8bd617f577eb151bd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-05-17 10:50:13 +02:00
Daniel Trevitz
1cd7e01c90 For qdebug operator<< of pointer types, always check for nullptr
Also, use a consistent syntax for when the pointer is null.

Fixes: QTBUG-135856
Change-Id: I2f5c80a5650b1be6cc0d70cde7cd1e1c1990df9a
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-05-17 04:26:29 +00:00
Oliver Eftevaag
bc20065cf3 windows11style: improve style when using high contrast themes
High contrast themes not only change the colors that native applications
use, but they also make various UI controls look different by adding
additional outlines and other elements.

The following improvements are made in this patch, for users using high
contrast themes:

* Menus have an outline, similar to native applications.
* Selected MenuItem's text and background uses different palette colors,
  in order to look more similar to native applications.
* The ComboBox popup menu will have an outline.
* ComboBox will highlight the outline with the accent color when
  hovering over it with the mouse.
* MenuBarItem's have an outline, similar to native applications.

Pick-to: 6.9 6.8
Task-number: QTBUG-133595
Fixes: QTBUG-134978
Change-Id: Ic99a76a6986bc987e6b6b9f6a6db4d3efc432b33
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2025-05-17 00:21:23 +02:00
Alexandru Croitor
ac02ad23f2 CMake: Include WaylandCompositorMacros for qtbase in-tree tests
Amends 2d790125429123aec4fb3dbee8335732f2d122eb

Change-Id: Ie1c9f10d9fb03cb6397b70470f8671b4c0a5eb26
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-05-16 21:25:01 +02:00
Jarek Kobus
13fcffa4d6 TaskTree: Fix some coverity scan issues (use const ref)
Coverity-Id: 462756 462761 462769 462773
Pick-to: 6.9
Change-Id: I70db1a0084da78bd1d51aa5bdba94675be5757a4
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2025-05-16 20:40:58 +02:00
Kai Köhne
efaca381c9 Doc: Fix broken link in qmake manual
Pick-to: 6.8 6.9
Change-Id: I2d90f450fa9a8bb41a2517022546f561fd7feeeb
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-05-16 16:06:45 +02:00
Magdalena Stojek
8b67e93694 Mark QTimeZone as security-critical:
- qtimezonelocale.cpp: matchOffsetFormat() and findLongNamePrefix()
  dereference potentially untrusted string.
- qtimezoneprivate.cpp: findUtcOffsetPrefix() accesses untrusted string
  data.
- qtimezoneprivate_tz.cpp: loadTzTimeZones() parses POSIX
  zone-descriptor format.

Fixes: QTBUG-135197
Change-Id: Ib5ec53ad8210bd872b06be8b1f71459f8b48b2ab
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-16 15:41:00 +02:00
Lu YaNing
0de9b81a8c Client: Optimize set_window_geometry calls by caching last geometry
When a QtWayland client window is initialized or resized, set_window_geometry
may be called multiple times with the same geometry, resulting in redundant
protocol messages to the compositor.

According to: 904a00fc9e8e0547dce3f70b5b205f6c70cfd414

Fixes: QTBUG-136723
Change-Id: I2e993e2b185f30d57503b5a3ce7ab63ba46afec2
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-05-16 16:13:26 +08:00
Eirik Aavitsland
c9ab69d4e3 Update bundled libpng to version 1.6.48
[ChangeLog][Third-Party Code] libpng was updated to version 1.6.48

Pick-to: 6.9 6.9.1 6.8 6.5 5.15
Change-Id: I31762d38fc15db5649623300c3e6ac8c5e79cf67
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-05-16 04:14:51 +00:00
Eskil Abrahamsen Blomfeldt
f17a8ac6fb Upgrade Harfbuzz to 11.2.1
[ChangeLog][Third-Party Code] Upgraded Harfbuzz to version
11.2.1.

Task-number: QTBUG-136745
Pick-to: 5.15 6.5 6.8 6.9
Change-Id: Ie3f67e84447f30579933d92677908f3606e557a4
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-05-16 06:14:33 +02:00
Christian Ehrlicher
e34db561cf Windows11/VistaStyle: pass dpr to QIcon::pixmap()
Pass the correct devicePixelRatio to QIcon::pixmap() to make sure the
best pixmap is used for the current dpr.

Pick-to: 6.9
Change-Id: I70014b649457cee819228fa0ead7beb7de944471
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2025-05-16 00:16:45 +02:00
Joerg Bornemann
ecd63d469f CMake: Fix rpath adjustment when deploying QML plugins
If Qt is configured with a custom value for INSTALL_QMLDIR, e.g. via
"configure -qmldir lib/qml", then we must adjust the rpath for QML
plugins. Otherwise they won't be able to load Qt libraries.

We had general code that adjusts the rpath for plugins, but that only
triggered if INSTALL_LIBDIR was different from the user project's
CMAKE_INSTALL_LIBDIR.

Now, we always adjust the rpath of plugins on Linux. The operation is
cheap, and I don't quite see how to add a robust condition for all
desired cases.

Pick-to: 6.8 6.9
Fixes: QTBUG-125223
Change-Id: Ib511fbc2b733deac804191773e56be9b6adf5e68
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-05-16 00:16:45 +02:00
Volker Hilsheimer
7869593119 QDockWidget: don't emit visibilityChanged while in destructor
Amends 2c67d47ea15c6dc34cc20d8fbdb406efb19f11d7, after which we emitted
the signal, as the setParent(nullptr) call in the destructor would call
back into the QDockWidget::event override.

That change was correct, but we are now emitted signals while in the
destructor, after a potential subclass destructor was already completed.
This crashed applications that had slots connected to those signals.

While arguably an application problem (PMF connections need to be
disconnected explicitly), we can avoid this regression by blocking
the emission of that signal when already in the destructor.

Fixes: QTBUG-136485
Pick-to: 6.9.1 6.9 6.8 6.5
Change-Id: I6d5e98136beedc94c22287ccfd1198dd80f4f95e
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-05-16 01:16:45 +03:00
Thorbjørn Lund Martsum
5b33c4e84c QLayout - Introduce vertical and horizontal layout constraints
In most situations the simple setSizeConstraint is
sufficient to get the sizeConstaint the user wants.
However in certain other situations the QLayout size constraint
demanding same vertical and horizontal behavior could simply
be extremely annoying.

This patch fixes a design-flaw as it makes perfectly sense
to have a fixed sized or minimum size constraint in one
orientation and having it something else (e.g minMax) in
the another.

Likely the old logic was that the user could use
setMinimumWidth and setMaximumWidth on the widget itself
(and similar for height) to get this behavior, but on 2+ monitor
systems with different DPR that is not really an option
(at least not a good one).

[ChangeLog][QWidgets][QLayout] Introduced a vertical and horizontal
size constraint in layout as the size constraint behavior can depend on
the orientation.

Fixes: QTBUG-17730
Change-Id: I8aefcd2b4df228494604b41e8ab7319e9f599d07
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-05-15 23:55:03 +02:00
Axel Spoerl
bf38ab9990 qdockarealayout.cpp: add comments to apply(bool aninmate) bool traps
apply() of various classes sadly take a boolean argument, to indicate
whether an animation should be triggered.
Removing this bool trap would require central enumeration.

At least document in apply() calls, what the boolean argument is for.

Task-number: QTBUG-136716
Pick-to: 6.9 6.8 6.5
Change-Id: I5de59fb2813207c09d9de3cfb9ca147c18d943de
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-05-15 19:38:47 +02:00
Axel Spoerl
ca41ace357 Improve code readability of QDockAreaLayout::separatorMove()
Constify variables where possible.
Store conditions in const booleans with meaningful names.
Rename local variable "index" to "dockPosition" and type it
accordingly.
Add code comments to explain code paths for internal and
external separators.

Task-number: QTBUG-136716
Pick-to: 6.9 6.8 6.5
Change-Id: I21b950f6790cfa49c822dcd4de2eaadfa2ffdce9
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-05-15 19:38:47 +02:00
Samuli Piippo
b2985828a3 CMake: use configured paths for deployment defaults
The deployment api was using hardcoded paths for qml and plugin files
by default. This led to problems when deploying to embedded linux where
those paths were configured differently ('lib/qml' instead of 'qml').

Pick-to: 6.9 6.8
Fixes: QTBUG-136678
Change-Id: I2c3eb10858350062c86cea62fc812f095796527e
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-05-15 17:38:47 +00:00
Piotr Wiercinski
0cd3be36ba fusion: Implement high contrast style
Change-Id: I9bafda9058e2e48b8040f4d43c68b3eeac476594
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: MohammadHossein Qanbari <mohammad.qanbari@qt.io>
2025-05-15 17:58:11 +02:00
Tor Arne Vestbø
33d1ac4095 Windows: Detect lack of WS_CLIPCHILDREN when adding child windows
The lack of WS_CLIPCHILDREN will cause drawing artifacts, so ensure
we have WS_CLIPCHILDREN in our native window manual tests, and warn
if users inadvertently end up reparenting windows into a HWND that
doesn't have WS_CLIPCHILDREN set.

Change-Id: Ic4dac83882167562599d63f46232071c8c21b617
Reviewed-by: Zhao Yuhang <2546789017@qq.com>
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Pavel Dubsky <pavel.dubsky@qt.io>
2025-05-15 07:54:00 +00:00
Karim Pinter
312215ba87 Remove VxWorks DKM check from QThreads
Qt doesn't support VxWorks DKM since 4.8, removing DKM specific check,
so it is the same as in Qt for VxWorks 5.15.

Pick-to: 6.8 6.9
Task-number: QTBUG-136722
Change-Id: I86cf54e8eadbb78365b7c58cb72b0675714fb37a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-15 10:11:34 +03:00
Alexei Cazacov
72becc7c12 Doc: QLatin1StringView documentation misses string literals namespace
QLatin1StringView documentation assumes knowledge of string literals
namespace. This commit adds a 'using' statement to the code samplles
that use string literals.

Fixes: QTBUG-135945
Pick-to: 6.9 6.8
Change-Id: I17971d343d9dad132394b91d93ac045c2c8d019f
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-05-15 01:08:03 +00:00
Alexandru Croitor
c20d7bcb86 CMake: Adjust CMP0156 policy handling for Apple platforms
Backstory.

1) Starting with Qt 6.8, the prebuilt Qt for iOS SDK is built as
static framework bundles instead of static libraries. That is done so
that we can embed a privacy manifest into each framework bundle.

2) Up until CMake 3.28, CMake would not attempt to de-duplicate static
libraries (or frameworks) on the command line. Starting with CMake
3.29, the CMP0156 policy was introduced to allow such de-duplication.

3) Since a while ago, Qt had its own policy handling for CMP0156,
which it force sets to OLD, to disable any de-duplication. That was
done to avoid possible regressions on platforms where link order
matters.

4) A developer might add the -ObjC linker flag to a project, to ensure
the linker retains all Objective-C categories it encounters in all the
static libraries that were provided on the link line. Retaining in
this case means that the /whole/ object file of a static library will
be linked to the final executable.

5) The Apple ld linker (both the legacy and the new ld_prime one)
can't cope with duplicate static frameworks on the link line when the
-ObjC flag is used.
It ends up throwing duplicate symbol errors, from trying to link the
same object file from the same static framework more than once.
The linker works just fine if the link line contains duplicate static
libraries, rather than static frameworks.

6) When a project links against Qt6::Gui and Qt6::Core, the link line
will contain Qt6::Core twice. This gets even more involved, when
linking plugins, which cause static framework cycles, and thus a
framework might appear multiple times.

Thus, we have the situation that Qt forces the CMP0156 policy to OLD,
Qt6::Core appears multiple times on the link line, no de-duplication
is performed, the project adds the -ObjC flag, and the linker throws
duplicate symbol errors.

We can fix this by force setting the CMP0156 policy to NEW when
targeting Apple platforms and using CMake 3.29+.

A potential workaround for a project developer is to set the policy
to NEW manually in their project.
Unfortunately that doesn't work for older Qt versions.
That's because CMake applies the policy value when add_executable is
called, and the policy value in qt_add_executable is the one that is
recorded when the function is defined. And the recorded policy is
always OLD, because Qt6Config.cmake calls cmake_minimum_required with
VERSION up to 3.21, which resets the policy value to OLD.

So we have to force set the policy in qt_add_executable /
qt_add_library via the existing __qt_internal_set_cmp0156 function.

The __qt_internal_set_cmp0156 had some diagnostics to show a warning
when the user modifies the policy themselves, but this never worked
because of reason stated above: the policy value was always overridden
in Qt6Config.cmake.

To actually make the diagnostic work, there is now new code to save
the policy value in the current directory scope, before Qt resets
it.
This only works if a project uses the find_package(Qt6 COMPONENTS Foo)
signature. It won't work with a find_package(Qt6Core)-like signature.

The policy value is not modified for platforms other than Apple ones
for now.

Amends 9702c3c78b2c16db6a9d0515d7d7698d9b064cd8

Pick-to: 6.5 6.8 6.9
Fixes: QTBUG-135978
Change-Id: I4d6e6c2a01e7092b417fc669d2aea40cf2dca578
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-05-15 03:08:03 +02:00
Alexandru Croitor
15178c9919 CMake: Conditionally pass PATHS to FindWrapHelper package lookup
The setup:
- build Qt with '-static -qt-zlib'
- configure a user project with plain cmake and -DQt6_DIR pointing to
  the Qt6 package

In this case, the implicit find_dependency(BundledZlib) call will
fail with:

CMake Error at lib/cmake/Qt6/QtFindWrapHelper.cmake:120 (message):
  Can't find Qt6::BundledZLIB.
Call Stack (most recent call first):
  lib/cmake/Qt6/FindWrapZLIB.cmake:6 (qt_find_package_system_or_bundled)
  cmake/share/cmake-3.31/Modules/CMakeFindDependencyMacro.cmake:76
    (find_package)
  lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:36 (find_dependency)
  lib/cmake/Qt6Core/Qt6CoreDependencies.cmake:39
    (_qt_internal_find_third_party_dependencies)
  lib/cmake/Qt6Core/Qt6CoreConfig.cmake:42 (include)
  lib/cmake/Qt6/Qt6Config.cmake:233 (find_package)
  CMakeLists.txt:7 (find_package)

For example it would fail for the rasterwindow example configured with:
 cmake ~/qtbase/examples/gui/rasterwindow \
   -DQt6_DIR=$HOME/builds/dev-mac-static/qtbase/lib/cmake/Qt6

The failure happens because we don't pass any additional paths to the
find_package call that looks for BundledZlib, as opposed to how we do
it for module packages.

The project configuration does not fail if it is configured with any
of the following variables:
- Qt6_ROOT or
- CMAKE_PREFIX_PATH or
- the Qt generated toolchain file.

That's because these implicitly add relevant paths where to look for
Qt packages.

This came up in qtdeclarative RunCMake CI tests, where we only pass
Qt6_DIR to the test projects. It didn't come up in qtbase, because
none of the current qtbase RunCMake tests try to find Qt6Core.

To fix this particular case, conditionally pass the same paths that
Qt6Config.cmake uses when looking for module packages, to the
find_package call that looks for the bundled target.

We do it conditionally for bundled targets only, because for system
libraries we want to default looking for the module
FindWrapSystemFoo.cmake files.

Add a RunCMake test which will try to find a few Qt modules solely
based on having only Qt6_DIR set.

Pick-to: 6.8 6.9
Change-Id: I4d4e548f4c10370c4964ab8968b5772e26855dd4
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-05-15 03:08:03 +02:00
Even Oscar Andersen
57191901d7 wasm: a11y - Use <div> for StaticText
VoiceOver reads the readonly textarea as
"Multiline text field, read-only, double tap to edit”

Fixes: QTBUG-136665
Change-Id: I809a842795a18bcd0756d39b0f6240981b762ef9
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-05-15 03:08:03 +02:00
Tor Arne Vestbø
7cb1cacd97 Merge "Merge Wayland client from qtwayland repository into qtbase" 2025-05-14 20:58:39 +02:00
Axel Spoerl
883afddd1e QDockWidgetGroupWindow: Copy window icons to tabs
If a QDockWidget has a window icon, copy it to the respective tab of
the group windows.

[ChangeLog][Widgets][QDockWidget] When grouping dock widgets in tabs,
the dock widgets' window icons are now used in the tab bar.

Fixes: QTBUG-136624
Fixes: QTBUG-814
Change-Id: I59c393e864a7bd3e52e376778257aff0dc8aea4b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-05-14 18:50:43 +00:00
Frédéric Lefebvre
26fc2b4ebf ensurePositionTopLeft - always return true on Android
Due to synchronous position handling, it is not necessary to wait for
event based geometry updates.

Always return true on Android.

Change-Id: Iad1da66e38b2ec1193c5569b4d1764c7202ea319
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-05-14 19:00:09 +02:00
Wladimir Leuschner
6273e2e0ed WindowsQPA: Make custom titlebar respect swapped mouse buttons
Custom titlebar input handling is done on WM_NCHITTEST, which is handled
at the WinAPI level. The WinAPI does not take into account the swapped
mouse buttons when querying the state of VK_LEFTBUTTON and
VK_RIGHTBUTTON with GetAsyncKeyState, so this behavior has to be
implemented manually. In case of swapped mouse buttons,
GetSystemMetrics(SM_SWAPBUTTON) will return true. This patch inverses
the meaning of Right and Left buttons in case
GetSystemMetrics(SM_SWAPBUTTON) returns true.

Pick-to: 6.9
Change-Id: Ie46e130dc0bb49de318c8d04a3cc426f7a346b5b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Zhao Yuhang <2546789017@qq.com>
2025-05-14 19:00:09 +02:00
Ivan Solovev
a7d8d3ecdd Clarify QFuture::isValid() docs
It was not clear that the function will return true even when the
result is not yet ready, so mention it explicitly.

Amends 44ceb56455c82df3e6b1c9a2fa373cac14a039f8.

Fixes: QTBUG-136530
Pick-to: 6.9 6.8 6.5
Change-Id: I03b79f2b28c4bb755e6f56147cc7af1413ed4e57
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-14 18:48:52 +02:00
Even Oscar Andersen
8391685185 wasm: set focus to m_canvas instead of m_window
Setting focus and contentEditable on m_window causes
innerHTML to build up with characters.

This does not happen when using the m_canvas

The downside is that m_canvas is aria-hidden, but this
should, in principle, not be a problem since
m_canvas should not be focused when a11y is in
effect.

Later aria-hidden might be set only if a11y is in
effect.

This is a candidate for manual cherry-picking to
6.9 6.9.1

Task-number: QTBUG-136687
Change-Id: I08a9db2c39f9b0b0038c75fd06d3504b736ea031
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-05-14 17:40:08 +02:00
Alexandru Croitor
3db537ee8e CMake: Fix showing exit code when SBOM NTIA verification fails
The code was missing an escaped dollar sign.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I51bff0a128546085e9418682b540d92eacfdbbe4
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-05-14 10:38:35 +02:00
Ahmad Samir
2be51c6923 QSslCertificate: add fromFile() method
QSslCertificate::fromPath() does some extra work:
- matching wildcard glob or regular expression patterns
- checks if the string it's called on is a file or a dir

That extra work isn't needed when you already have the path to a
specific certificate file.
E.g. qtlsbackend_openssl.cpp:systemCaCertificates() used to call
fromPath() on *.pem/*.crt files that it got from iterating over system
certifcates dirs.

This also de-duplicates the code in fromPath().

[ChangeLog][QtNetwork][QSslCertificate] Added fromFile() method.

Change-Id: I92ab358e4711866dd4510da42c47905c7dae58b1
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-05-14 04:41:13 +03:00
Ahmad Samir
2875c4358b QSslCertificate: fromPath(): check the path arg isn't empty
`path` may contain wildcard glob patterns or regular expression ones,
so this method tries to get a path prefix without those special
characters, but that prefix could end up being empty, to counter
that, "." is used as a prefix. This led to iterating over the
current dir, which isn't the intended behavior. If the current dir
has many files, this could end up slowing things down (which is what
happens in the bug report).

Fix the issue by returning early if `path` is empty.

Amends 49f143e19ca11ef48260a3aaaa4ddbe490cf81ab.

[ChangeLog][QtNetwork][QSslCertificate][Important Behavior Changes]
fromPath() no longer accepts an empty path, which would previously
result in searching the current directory.

Fixes: QTBUG-134419
Pick-to: 6.9 6.8 6.5
Change-Id: I29224c3a47794b4095db5feae32a964dd9b854ff
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2025-05-14 04:41:13 +03:00
Ahmad Samir
6dcf148394 qtlsbackend_openssl: optimize QDirListing usage
Internally QDirListing uses the name filters to create
QRegularExpression objects which are then used to do the matching. Here
we are looking for files that have ".pem" or ".crt" extensions, so basic
string matching should work the same and is inherently faster.

Pick-to: 6.9
Change-Id: Ib19b1eb8717b21c3b96a52e7036665c40fb24caf
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-05-14 04:41:13 +03:00
Ahmad Samir
4a3e7bb1fa qtlsbackend_openssl: use QFile::decodeName()
... instead of reyling on the QByteArray to QString implicit conversion.

Pick-to: 6.9
Change-Id: Ia9e8026f2962009d9deac044e42b18f6333cfec1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-05-14 04:41:13 +03:00
Ahmad Samir
6952cfe7a0 QSslCertificate: fix PatternSyntax enum value
Regexp was renamed to RegularExpression.

Amends 813111689629a71e51d7d149a5f689b2961f2716.

This looks like a "dead" code path, QT_FEATURE_regularexpression is
most likely always enabled.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I99af481bb41a197a0b7d00c750440a93d8e6a3fe
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-05-14 04:41:13 +03:00
Jarkko Koivikko
270d59f65b Android: Skip restoring bundle state on process restart
When the app process is restarted (e.g. after revoking a permission), Qt
isn't running yet, so we must not restore the saved bundle state.

Fixes: QTBUG-136497
Fixes: QTBUG-136077
Fixes: QTBUG-135961
Pick-to: 6.9.1 6.9 6.8
Change-Id: I5ec594ec93dd3ba13b088d63ec77a3649e21d798
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-05-13 22:36:54 +00:00
Piotr Wiercinski
47e3a5b804 wasm: Migrate WasmSuspendResume functions from EM_JS to C++
There is a problem with generating functions signature by Emscripten for
functions defined with EM_JS. This break dynamic linking when these
functions are imported from SIDE_MODULES.
This commit works around that issue by porting these functions to C++
which fixes their signature generation.

Task-number: QTBUG-136741
Change-Id: I3356d4dbe89b99e099d9d22327370471dc03c935
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-05-13 23:29:19 +02:00
Kai Uwe Broulik
427bd9a42c qBound: Don't claim it's "equivalent to qMax(min, qMin(val, max))"
While technically true, those don't assert while qBound does,
so it gives you a false sense of security that
qBound(min, val, max) is safe for unsanitized input ranges.

Pick-to: 6.9 6.8 6.5
Change-Id: Ie26f5eba586a3cd2d3e0cd769427f518e1bc92b9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2025-05-13 21:29:19 +00:00
Thorbjørn Lund Martsum
0d61e8ec53 Fix QHeaderView auto section resize corner case
In some situations where the model is set sufficient late
an auto resize would never be applied. See bug report for
further details.

This is solved by moving to the normal memory model when
the global resize mode is changed to resizeToContents or stretch.

Fixes: QTBUG-136453
Pick-to: 6.9
Change-Id: Ie0448042a7d23b059eaf7464a662f0f551d89fd9
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-05-13 14:10:15 +02:00
Even Oscar Andersen
a89ac4b881 wasm: handle changes in inputMethodAccepted()
The result of inputMethodAccepted() function might switch after
setFocusObject()/showInputPanel() has been called. End result it
was not picked up and not acted upon.

It turns out update() is called after this flag is set, so
check for changes in the update() function.

Task-number: QTBUG-136687
Change-Id: I585cc82f2a177bb7708627102d3074a627d0f024
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-05-13 14:10:15 +02:00
Tor Arne Vestbø
27e4762903 embeddedwindows: Build app as GUI app on Windows
Change-Id: Ib5289e11ef3d53d038e01e17c76be6e14e48bf80
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-05-13 12:10:15 +00:00
Frédéric Lefebvre
5358c833c4 Unblacklist tst_qComboBox::popupPositionAfterStyleChange on Ubuntu
tst_qComboBox::popupPositionAfterStyleChange is no longer flaky on
Ubuntu.

Fixes: QTBUG-129029
Pick-to: 6.9 6.8 6.5
Change-Id: I3581fe73516d21d599dfb520fe53a0d855c811f6
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-05-13 12:10:12 +00:00
Frédéric Lefebvre
8875e88b61 Unblacklist tst_qWidget_window::mouseMoveWithPopup on Ubuntu
tst_qWidget_window::mouseMoveWithPopup is longer flaky on Ubuntu.

Fixes: QTBUG-129568
Pick-to: 6.9 6.8 6.5
Change-Id: Iae9155e21de91ba8068dde622bbd41f3e454dbe2
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-05-13 12:10:12 +00:00
Frédéric Lefebvre
3393d85108 Unblacklist tst_qWidget::saveRestoreGeometry on Ubuntu
tst_qWidget::saveRestoreGeometry() is no longer flaky on Ubuntu.

Fixes: QTBUG-126495
Pick-to: 6.9 6.8 6.5
Change-Id: I65e12e958aa028237f56a9e7b3824e9aa837b799
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-05-13 14:10:12 +02:00
Frédéric Lefebvre
cb1c184ee8 Unblacklist tst_qFileSystemModel::sort() on Ubuntu
tst_qFileSystemModel::sort() is no longer flaky on Ubuntu 24.

Pick-to: 6.9 6.8 6.5
Change-Id: I5a96cd06c78e2ff95d3d043cb6b11254946e5e19
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-05-13 12:10:12 +00:00
Samuli Piippo
406d5c6315 CMake: Allow skipping the fake install prefix for examples
Add CMake variable to allow use of DESTDIR when installing examples
in a standalone example build and skipping the fake prefix that would
be otherwise used. Similar variable is already used for tests.

Pick-to: 6.9 6.8
Change-Id: I427cbb5c198f8e89b1685792b7c1d90413213254
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-05-13 05:16:40 +00:00
Liang Qi
2d79012542 Merge Wayland client from qtwayland repository into qtbase
The qtwayland repository has been filtered for commits relating
to the Wayland client, via the following git-filter-repo command:

 git filter-repo --paths-from-file wayland-move.txt --force --refs HEAD

And then merged into the qtbase repository via

 git merge --allow-unrelated-histories

The following git-filter-repo instructions have been used:

src/CMakeLists.txt
src/CMakeLists.txt==>src/platformsupport/wayland/CMakeLists.txt
src/configure.cmake
src/configure.cmake==>src/platformsupport/wayland/configure.cmake
src/client/Qt6WaylandClientMacros.cmake
src/client/Qt6WaylandClientMacros.cmake==>src/tools/qtwaylandscanner/Qt6WaylandClientMacros.cmake
src/compositor/Qt6WaylandCompositorMacros.cmake
src/compositor/Qt6WaylandCompositorMacros.cmake==>src/tools/qtwaylandscanner/Qt6WaylandCompositorMacros.cmake

src/3rdparty/
src/3rdparty/patches/==>src/3rdparty/wayland/patches/

src/3rdparty/protocol/ivi/REUSE.toml==>
src/3rdparty/protocol/ivi/ivi-application.xml==>
src/3rdparty/protocol/ivi/ivi-controller.xml==>
src/3rdparty/protocol/ivi/qt_attribution.json==>

src/3rdparty/protocol/
src/3rdparty/protocol/==>src/3rdparty/wayland/protocols/

src/extensions/qt-shell-unstable-v1.xml==>
src/extensions/
src/extensions/==>src/3rdparty/wayland/extensions/

src/client/
src/client/==>src/plugins/platforms/wayland/

src/global/
src/global/==>src/plugins/platforms/wayland/globalprivate/

src/shared/
src/shared/==>src/plugins/platforms/wayland/shared/

src/plugins/decorations/adwaita/==>
src/plugins/decorations/
src/plugins/decorations/==>src/plugins/platforms/wayland/plugins/decorations/
src/plugins/hardwareintegration/client/
src/plugins/hardwareintegration/client/==>src/plugins/platforms/wayland/plugins/hardwareintegration/
src/plugins/platform/
src/plugins/platform/==>src/plugins/platforms/wayland/plugins/platform/
src/plugins/shellintegration/qt-shell/==>
src/plugins/shellintegration/ivi-shell/==>
src/plugins/shellintegration/
src/plugins/shellintegration/==>src/plugins/platforms/wayland/plugins/shellintegration/
src/plugins/CMakeLists.txt
src/plugins/CMakeLists.txt==>src/plugins/platforms/wayland/plugins/CMakeLists.txt

src/qtwaylandscanner/
src/qtwaylandscanner/==>src/tools/qtwaylandscanner/

tests/auto/client/iviapplication/CMakeLists.txt==>
tests/auto/client/iviapplication/tst_iviapplication.cpp==>
tests/auto/client/shared/iviapplication.h==>
tests/auto/client/shared/iviapplication.cpp==>
tests/auto/client/
tests/auto/client/==>tests/auto/wayland/
tests/auto/cmake/test_waylandclient/
tests/auto/cmake/test_waylandclient/==>tests/auto/cmake/test_waylandclient/

Done-with: Alexandru Croitor <alexandru.croitor@qt.io>
Done-with: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Task-number: QTBUG-133223
Change-Id: I46c325724141fdbfcc117d12fb5f92852613e72a
2025-05-13 01:50:43 +02:00
Christian Ehrlicher
d205844e51 Windows11Style: make QPushButton a little bit wider
The spacing betwen the border and text in a QPushButton is a little bit
to small because the CE_PushButtonBevel is drawn with 4px less than the
size hint due to the rounded border. Therefore add the 4px for
CT_PushButton.

Pick-to: 6.9 6.8
Fixes: QTBUG-126515
Change-Id: Ie64225ad4734399b5da8bc4e73738592f32a7982
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2025-05-13 00:39:35 +02:00
Liang Qi
834d92a7ad cmake: add INSTALL_SHAREDIR
For Wayland protocols, "/usr/share/wayland-protocols/" is used on
Ubuntu/Debian derived, and same for arch. The share directory is
different with data and archdata directories.

Change-Id: I3bdd5bdc60bd4f66de66aecc943893978c86f19b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-05-12 20:01:57 +02:00
Laszlo Agocs
8fc3bc67df Modernize and fix frame sync in QVulkanWindow
Follow 24d62ffd720b5bec5d07b07b8d2c9dda7635f3c0 for QVulkanWindow.
The Vulkan backend of QRhi has diverged from QVulkanWindow even
before that recent fix, having many changes over the years that
are not present in QVulkanWindow.

Introduce some of these now, to make things work with the newer
validation layer bundled with the Vulkan 1.4 SDKs.

Task-number: QTBUG-135645
Change-Id: Ic630e9a57c344843c171871b5a0386ed18027b22
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-05-12 15:27:00 +02:00
Karim Pinter
53756dcfbc Add POSIX Pipe feature to VxWorks
VxWorks has POSIX pipe2 functions, but doesn't pass threadsafe-cloexec
because it doesn't have threadsafe-cloexec dup3. By default on VxWorks
POSIX pipes are used, but now it's possible to switch to PipeDrv
pipes using "configure -feature-vxpipedrv ...".
dup3 and accept4 test are now separated from threadsafe-cloexec test.

Task-number: QTBUG-132889
Pick-to: 6.8 6.9
Change-Id: I9e4514e2795917e8f3685a1760ea82a0022e9ca2
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-12 12:35:00 +03:00
Lorn Potter
5ff542493d wasm: stop removing all html and wasm files on distclean
moves setting QMAKE_DISTCLEAN to wasm/=.prf and only
remove files we create.

Fixes: QTBUG-134110
Done-with: Morten Johan Sørvig <morten.sorvig@qt.io>
Pick-to: 6.9
Change-Id: I4b62cd423fe7814f8a39d67ae98bb61111b0618e
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-05-12 15:46:57 +10:00
Tor Arne Vestbø
2db64357fa iOS: Use Q_CC_CLANG to determine if we should disable -Wvla-cxx-extension
Pick-to: 6.9 6.8
Change-Id: Ic0f460fec800384e4300365f4836f012060bfa55
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-05-12 00:31:12 +02:00
Christian Ehrlicher
a3b24c2842 Windows11/VistaStyle: Simplify painting icon for CE_MenuItem
Use QIcon::paint() instead retrieving a QPixmap from the icon and paint
it 'manually'.

Pick-to: 6.9
Change-Id: I4e8e47bf8d7fdffa8e65f93e3b8501074d831c43
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-05-11 21:13:53 +02:00
Christian Ehrlicher
7951eba61e QCommonStyle: use media icons from Qt Icon Library
Replace all standard media icons with the icons from Figma/Qt Icon
Library.

Pick-to: 6.8
Task-number: QTBUG-128665
Change-Id: I8e3944f6536cac81a415e4891dcd2e0203fc2863
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-05-11 21:13:51 +02:00
Christian Ehrlicher
9eddf930a2 QIcon/QPixmapIconEngine: render svgs with the given size
Currently scalable images are rendered with the default size set in the
image and not the size they were added with QIcon::addPixmap(). This
might give scaling artifacts when the both sizes do not match at all.
Therefore set the wanted size through QImageReader::setScaledSize() when
(and only when) the reader supports this. Setting it unconditionally
will also force the scaling of pixel-based formats which is not what we
want.

Pick-to: 6.9
Task-number: QTBUG-135652
Change-Id: I2dc78587854b4c7c32438e0386385e980a9c4059
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-05-11 19:13:49 +00:00
Matthias Rauter
1c0f02f368 Remove U+00A0 character from file
QtCreator automatically removed this symbol when saving the file,
polluting my patch.

Therefore I put it into its own patch. As a driveby, I remove another
space at the end of the line.

Pick-to: 6.9 6.8
Change-Id: I407f9ebe5fb6c8bfa0285c0fcba929c8866b2251
Reviewed-by: Magdalena Stojek <magdalena.stojek@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-11 19:13:48 +00:00
Christian Ehrlicher
bdf9d70394 QWindowsCursor: compile without feature_imageformat_xpm
Fix compile with feature_imageformat_xpm = OFF

Pick-to: 6.9
Change-Id: Id84c2050f27bbe43ae9710f4e23c52cc24dd3370
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-05-11 21:13:46 +02:00
Christian Ehrlicher
4599903eed SQLite: Update SQLite to v3.49.2
[ChangeLog][Third-Party Code] Updated SQLite to v3.49.2

Pick-to: 5.15 6.5 6.8 6.9 6.9.1
Change-Id: I9f16deebdcfc223005a5b6731b71b7c885ad17f2
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2025-05-11 17:40:31 +02:00
Joerg Bornemann
731d9a1395 CMake: Make generated pkgconfig files relocatable
Don't write an absolute prefix into generated .pc files but one that's
relative to ${pcfiledir}. This makes the files relocatable, and we don't
have to patch them in the Qt online installer.

Pick-to: 6.8 6.9
Fixes: QTBUG-136210
Change-Id: I5c2f9398917be03f6c63286e553c87ff52971285
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-05-11 07:38:11 +00:00
Thiago Macieira
e30774649a QLoggingRegistry: replace QTextStream and QFile with <stdio.h>
This is to avoid the need to use QFile (which is a QObject) in this
early code, especially since QObject itself may use category-logging.

Task-number: QTBUG-135326
Change-Id: Idc05974d06c2c0a973f6fffdadcc0ecbf76c5cbc
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-10 09:46:00 -07:00
Thiago Macieira
b99671c945 QLoggingRegistry: don't use QTextStream for the QT_LOGGING_RULES env var
We can use the existing QStringView-based rules parser. Additionally, we
can make this even better by avoiding the QString::replace() call and
simply tokenize on the semi-colon character (';').

Change-Id: I89d3890da482fc684abafffdd56ec17cad908f21
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-05-10 09:45:58 -07:00
Magdalena Stojek
c08766abf2 QXmlStreamWriter: Refactor writeEscaped() to use switch
The character escaping logic in writeEscaped() previously relied on a
long if/else cascade to handle escaping and error detection.
This change replaces the cascade with a switch statement, improving the
control flow. The loop now exits when a non-null replacement is set.
To support this, cases that previously raised an error without assigning
a replacement now assign an empty, non-null string to trigger the break.

Fixes: QTBUG-136681
Change-Id: I4a584738bcda741f881712547af12abd35e2fd0a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-10 13:03:17 +02:00
Mårten Nordheim
f958056701 Http2: check if stream was RSTed w/ bespoke function
We have a function to check if a stream was locally reset - we should
realistically only process HEADERS on RSTed streams for a limited amount
of time. I forgot we had this mechanism in place already, let's update
to use it for the recent fix.

Amends 9224fdd3f4cccce7a8123ab398f6ff8745d759ce

Pick-to: 6.9.1 6.9 6.8
Change-Id: I4826100704542f681341ceb84c4f85332f8ae03d
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
2025-05-10 03:13:51 +02:00
Thiago Macieira
c05ae82efb qHashMulti: switch to passing the seed to the qHash() function in 7.0
Amends 707129fd5a7c6390fbdf4270119226df2a427fcd.

This is much better for our string types because qHashBits() has a
faster implementation when seed!=0. The algorithm is the same, except
that QHashCombine now separates the seed from the combined hash, not
merging the two unrelated concepts together.

We can't fix it in Qt 6.x because it changes the hashing algorithm of
existing types that used qHashMulti(), which will have been inlined
throughout user code.

The deprecated constructor is there only until the rest of Qt is fixed.
Since this is a private class, that won't stay for long.

Task-number: QTBUG-134683
Fixes: QTBUG-134690
Change-Id: I2167e154f083089d12a1fffd61c1ab8670731156
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-09 16:54:13 -07:00
Thiago Macieira
b10c7b1680 qtbase: use qHashMulti & qHashRange instead of QHashCombine
If we have no specific need for the private QHashCombine class, use the
front-end functions. For headers, we do have a need: we prefer
QHashCombine because it compiles faster.

Change-Id: I73578ea802d3b905a53bfffd504c20af0ca96cf8
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-09 16:54:13 -07:00
Thiago Macieira
4647940e88 QMetaType/Doc: sort the lines for the other Types
That's all non-primitives, except for QString, QByteArray and QChar.

Change-Id: I51d12ccdc56c4ad2af07fffd172bce38cc1a7998
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-05-10 01:54:13 +02:00
Jacek Poplawski
01961aea8b update tst_QFile::supportsMoveToTrash for VxWorks 25.03
On VxWorks 25.03 AT_FDCWD is defined but the POSIX at* APIs needed for
trash support are still missing. Update tst_QFile::supportsMoveToTrash
to verify that QFile::supportsMoveToTrash() returns false on
Q_OS_VXWORKS, regardless of AT_FDCWD.

Fixes: QTBUG-136693
Change-Id: I33f418984887d87e42ecda494cd5b101c42d55e6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-09 22:00:54 +02:00
Aurélien Brooke
dee6c21fe0 rhi: fix QByteArray static uploads
QByteArray is implicitly convertible to void* (!) so the void*
staticUpload overloads were accidentally selected, creating a deep copy
and defeating the purpose of QByteArray.

Fix this by calling the staticUpload functions with the correct number
of arguments.

Amends 5d857ed3bce64e4a7bdc5247c7dd9ca4495fb10b.

Change-Id: I5ab0baa53b764162ca44a3dd1dc6b1d5c68c7925
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-05-09 22:00:44 +02:00
Tor Arne Vestbø
1b435685be iOS: Don't release QMacAccessibilityElement on invalidate
The release is handled by the cache now.

Amends b1ed5f656f064e553b33752f8e87d2f5b9553e38.

Pick-to: 6.9 6.8
Change-Id: I1d4e13bbdffc732247f08a3d87dae6298155ba58
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-05-09 18:14:55 +02:00
Juha Vuolle
464e9298e2 Remove unnecessary widgets linking from autotests
Unconditional linking breaks build when widgets are disabled.
tst_localfileapi, tst_qwasmwindowstack, and tst_qwasmwindowtreenode
tests link against Qt::Widgets, but does not use them => remove.

Task-number: QTBUG-136101
Pick-to: 6.9 6.8
Change-Id: I6d895b5ddd85b3ace98e0e398d034006aee236e0
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-05-09 10:06:51 +03:00
Mitch Curtis
441a4ac1bc Doc: link to "Which string class to use?" on all string pages
This section has very useful flowcharts. The question "Which string
class to use?" is exactly what most users will want the answer to when
faced with all of the different string types we provide.

Task-number: QTBUG-135947
Change-Id: I2ae79803e205693d6c7ee8f50cad5d057c4d24ea
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-09 03:40:03 +00:00
Thiago Macieira
1dae56833b QFSFileEngine: remove unused internal functions
Everyone is just using the QFileSystemEngine API directly.

Change-Id: I74ccbe72cd091c667b39fffd22822c231bc02e90
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-05-08 22:33:35 +02:00
Matthias Rauter
8643ae7a76 Add Qt styling, ids, and classes to string overview graphics
While many graphics in core use a light blue color, it does not fit to
Qt and to the general styling of the documentation. This patch changes
the color to the Qt green.

In the long run, I would like to have styling switching between light
and dark mode. This patch applies ids and styling so that it could be
switched from outside, if the html document this is embedded into
sets the correct tags. This will probably require some features in qdoc.

Task-number: QTBUG-133882
Change-Id: Iadce79a5f5a99014abe97c19d9e76efac3d49dad
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-05-08 21:03:34 +02:00
Artem Dyomin
878381473c QGIM: fix columnCount for tree model
If static_column_count is 0 (one_dimensional_range) columnCount
should return 1.

Change-Id: I96a1f83d3d5880e16b6553c515a619ff93f7d2a3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-05-08 19:13:14 +02:00
Cristian Le
6ccee802a9 Fix check for aliases
Amends 4bbd324a0a4a488b9ff4272888cc6b7f516d78ff

Change-Id: I1b887c17a442398695fdebc20c7b54b068061f24
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-05-08 19:13:14 +02:00
Frédéric Lefebvre
36d92169f3 Unblacklist tst_qcompleter::QTBUG_14292_fileSystem on openSuSe
tst_qcompleter::QTBUG_14292_fileSystem is no longer flaky on openSuSe.

Pick-to: 6.9 6.8 6.5
Change-Id: Ie2ad7d99ca9afd75a91a0e47c7420cfd470d3a25
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-05-08 14:23:28 +00:00
Frédéric Lefebvre
d1fea2f70e Unblacklist tst_qwidget_window::paintEventOnSecondShow on openSuSe
tst_qwidget_window::paintEventOnSecondShow is no longer flaky on
openSuSe.

Pick-to: 6.9 6.8 6.5
Change-Id: I4ceae71dc3d8a01b0b421bba2968f35dc66383bd
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-05-08 14:23:28 +00:00
Frédéric Lefebvre
ab1569f643 Unblacklist tst_qopenglwidget on openSuSE
tst_qopenglwidget is no longer flaky on openSuSe

Pick-to: 6.9 6.8 6.5
Change-Id: I42d31853d50938590e4cb1ba9ca6f009fe612279
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-05-08 14:23:28 +00:00
Frédéric Lefebvre
c02a02b6ab Unblacklist tst_qudpsocket::readyReadForEmptyDatagram on openSuSe
tst_qudpsocket::readyReadForEmptyDatagram is no longer flaky on
openSuSe

Pick-to: 6.9 6.8 6.5
Change-Id: If0f846d1d7ed4cc094e201cf4ef29579508da0bf
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-05-08 14:23:28 +00:00
Thiago Macieira
97f3d41fa1 Replace uses of std::is_trivial with its underlying definitions
C++26 deprecated it[1]. Like the paper, we don't need the trivial
default constructibility for most uses. Even some of the
QTypeInfo::isComplex checks don't need it.

[1] https://wg21.link/p3247

Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-136083
Change-Id: I0caafc5a15df732b9640fffd72fb1c598563a91b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-05-08 06:37:21 -07:00
Even Oscar Andersen
5fc167739d wasm: Fix keyboard popping up on cell and tablets
The fix for text/button broke cellphones and tablets.
(QTBUG-136562)

The fix is reverted on 6.9, and fixed here on 6.10

The fix is to set inputMode so that it matches the focus.

Change-Id: I88b0a32787ff97b6f5b057e4ebd240f565b5a284
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-05-08 13:37:29 +02:00
Tor Arne Vestbø
cb65dc8f93 iOS: Only set LD_ENTRY_POINT for qmake projects if entrypoint is enabled
Fixes: QTBUG-136609
Pick-to: 6.9 6.8
Change-Id: I48360b201299faeb854d76cc98fa21f5b758bd55
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-05-08 13:37:29 +02:00
Tor Arne Vestbø
bfd844a42c Update Apple Clang/LLVM version mapping
Pick-to: 6.9 6.8 6.5
Change-Id: I4d79b44f440a70ce650240f3c16519aa4964094f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-05-08 12:52:32 +02:00
Antti Määttä
cf037274d1 Add UAVs for fragment stage on DX11
Add support for UAV's in fragment stage. UAV's are required to implement
order independent transparency.

Task-number: QTBUG-130332
Change-Id: Ia539ff3f94df43d3276d1d242091d55eafcbfadb
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-05-08 08:28:50 +03:00
Oliver Eftevaag
d8ac4cd869 Add constant property QStyleHints::accessibility
This property bundles together accessibility settings that can be used
by styles to change how they draw different widgets and/or controls.

The only property that it contains currently is contrastPreference.
This property can be used to determine if the user has enabled a high
contrast setting on the platform that the Qt application is running on.

We might add more *accessibility* settings, like color blind hints, to
QAccessibilityHints in the future.

[ChangeLog][Gui][QStyleHints] Added class QAccessibilityHints, which can be
accessed from QStyleHints. This singleton contains a single property
contrastPreference which can be used to determine if the platform has
enabled a high contrast setting or not. More accessibility settings
might be added to QAccessibilityHints in the future.

Task-number: QTBUG-133595
Change-Id: I93c6be81d29f65058eeda00328f4d9e966921de6
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-05-07 22:22:49 +02:00
Christian Ehrlicher
e808b38d4b QHeaderView: fix logic in setOffset()
Fix the logic in setOffset() which was accidentally reversed during
fixing of UB during signed overflow.

Amends 49fcac99deea390901000a74deea1c0c690b6ae2.

Coverity-Id: 479557
Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-136362
Fixes: QTBUG-136477
Change-Id: Ifc9c80346355b0a9e516effe2ff8b60b1966d67a
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
2025-05-07 17:53:31 +00:00
Juha Vuolle
c39136ed4f Make QProcess::splitCommand() available without process feature
QProcess::splitCommand() is a static function that is used at
least by Qt for Android without needing rest of the
process-feature support (QProcess).

Declare a simple QProcess class when the process-feature is not
enabaled. This class makes the static splitCommand() function
available.

Fixes: QTBUG-135655
Change-Id: I97dc054c3007e98bd786cbe092ffc78e3cc201e5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-07 19:14:36 +03:00
Michal Klocek
d531d31e1d Adjust webengine resources deployment
In case of debug build install debug resources.
The change reflects qtwebengine's deployment change:
qtwebengine/76d317c082b2492cc1fe1fcf2afad26be5369d3f

Task-number: QTBUG-131897
Pick-to: 6.9 6.8
Change-Id: I58fa8a36e88369dd29f03fb16060b88ba08abd86
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-05-07 16:09:50 +00:00
Even Oscar Andersen
d817747f8d wasm: a11y - refactor set/get attribute/property
Add setAttribute, setProperty, addEventHandler functions to reduce
linelength and improve readability.

Task-number: QTBUG-134657
Change-Id: I7deb1ac13872291b848c191198d741669d852e3a
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-05-07 10:26:35 +02:00
Edward Welbourne
591dccddbb Forward-port a test I've just added to 5.15
Ammends commit 61343b5a3f10f5b9166729176d4b95a4c538c278 (which was too
big a change to back-port to 5.15), checking narrow != short in
Chinese month names.

Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-10506
Task-number: QTBUG-84877
Change-Id: Ib9c26df751c0add517bc94218db04d32d8d135eb
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-05-07 10:25:23 +02:00
Edward Welbourne
8c086ce832 Correct value of Avogadro's constant used in a test
It doesn't matter at all, but it's now got a defined value, so use it.

Change-Id: Id8e734cd81624a3d4c139b2639381e3f0b162db4
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
2025-05-07 10:23:37 +02:00
Mårten Nordheim
9224fdd3f4 Http2: process HEADERS on RSTed streams
If we RST a stream then we may still have to process HEADER frames for
those streams (at least for a while) that was likely already in-transit.
This is due to HPACK, which manages header compression state. Missing a
frame desynchronizes the server and client, eventually leading to an
error where one party is referring to a header the other party doesn't
have.

Fixes: QTBUG-135800
Pick-to: 6.9 6.8
Change-Id: I5b4b510225ce6737fec7128c4bad38219404b196
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2025-05-06 21:50:34 +02:00
Joerg Bornemann
22b7d198ce CMake: Fix file names of metatypes JSON files
The file names included the build type in the case of a single-config
build. The intention was to include the build type in multi-config
builds to make those more robust. This is not necessary since the
metatypes JSON files are independent of any configurations.

Fixes: QTBUG-136574
Change-Id: I4925e37c784f678e0d311fa9aba9f195b3270f94
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-05-06 20:34:14 +02:00
Artem Dyomin
9f4d74ece8 QGIM: add static assert for optional model and rows
In C++26, std::optional has range semantics, so it's better to
prohibit using this, and decide later on how it should behave.

Change-Id: Ia0dc4b124e74d817ff08ee0db1ce8a54caa83724
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-05-06 17:37:54 +00:00
Edward Welbourne
ed934ec497 Tweak a regex to only match what it's meant to
It's testing for either a .qm extension or the end of the file-name;
but it shouldn't match a .qml extension, so it should test the .qm is
at the end.  Thus it's a test for .qm-or-nothing at the end.
Amends commit 1f2ab46745af12e4776695c1b1a2523ac170368e

Change-Id: I3e47691bb7f576d21d61ce4988fc476421615add
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-06 19:37:54 +02:00
Edward Welbourne
dabc113cc8 Add QTranslator test for script-incompatible language truncation
Amends commit 0278a80d6876f38bb37f1d504e6b24a3512efb7a - I developed
the new test as part of adapting the earlier change to 6.8.

Pick-to: 6.9
Task-number: QTBUG-131894
Change-Id: I711e62db7e35fa26c396498354ffbb5aa23920a8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-06 19:37:54 +02:00
Artem Dyomin
4eb5c735aa QGIM: access m_itemModel through getter
- improves internal encapsulation
- allows moving a bunch of private stuff to the impl header.

Change-Id: I04d73559568e43c15ff6b80c8a0a89d8748c74c8
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-05-06 19:37:54 +02:00
Artem Dyomin
55e86d53c8 QGIM: fix typo in QGIMImpl::childrenOf
Change-Id: If7ff1080a75a380184aea11a2e6abae44c8d0102
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-05-06 19:37:54 +02:00
Joerg Bornemann
c248dc1e9e CMake: Fix -no-gui -developer-build
Doc snippets failed to configure due to missing Qt6::Gui target. Don't
explicitly link against Gui. We already link against Widgets if that's
available. That will pull in Gui too.

Change-Id: I08278c8f3bd0a07c4eb9ac60031a6aa1c45f2f1d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-05-06 19:24:14 +02:00
Kai Köhne
3ab63875e5 Doc: Warn about loading of untrusted .qm files
Pick-to: 6.9 6.8
Change-Id: I0cc99ef285335fc244ba33f08bf0e322c7597a75
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-05-06 06:53:46 +00:00
Kai Köhne
095cacd668 Do not treat the installation of an empty QTranslator as an error
The return value of installTranslator() should indicate whether
the _registration_ was successful. Apart from merely logging
the result, the only sensible action the calling code might
take is to delete the QTranslator object that failed to register.

The old behavior of installTranslator() for empty QTranslator
objects was to store the pointer for further use, but still return
false. This might lead to hard-to-detect memory corruption.

The patch changes behavior to _not_ consider installing empty
QTranslator objects as an error.

This has the following reasons:

* As translations are often done later in the SW development process,
it is common to replace empty .qm files with translated
ones in a very late stage. But having different code paths based on
this can be surprising.

* The other parts of the QTranslator toolchain do not treat
empty translations in a specific way, either.

While at it, also remove the now unused QT_NO_TRANSLATION_BUILDER
macro (left over from Qt 4).

[ChangeLog][Core][Behavior Change] QCoreApplication::installTranslator()
will now return true even for empty translators
(QTranslator::isEmpty()). This makes it explicit that empty QTranslator
objects are registered and queried, and therefore deleting the object
prematurely might result in undefined behavior.

Change-Id: Ia0531afcf5c72aa837406cf5de2cf73052014445
Reviewed-by: Masoud Jami <masoud.jami@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-06 06:53:31 +00:00
Kai Köhne
6ff833c04a Doc: Remove mentioning of 'stripped' translator files
The concept of stripped vs unstripped files in the API
stems from Qt 3, but got abandoned already in Qt 4.

Pick-to: 6.9
Change-Id: I449ddfd7ff3b8b3d50ab0252fabcab974d83a5ed
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Masoud Jami <masoud.jami@qt.io>
2025-05-06 08:53:27 +02:00
Magdalena Stojek
53622aca2a QXmlStreamWriter: add error-handling API
This change introduces QXmlStreamWriter::Error enum and three related
functions to enable error reporting during XML writing operations:
- error(): returns the current error state of the writer.
- errorString(): returns the corresponding error message.
- raiseError(): allows applications to raise custom write errors.

This complements the existing hasError() method and aligns the writer
with QXmlStreamReader's error handling.

[ChangeLog][QtCore][QXmlStreamWriter] Added error handling API with
QXmlStreamWriter::Error enum, error(), errorString(), and raiseError()
functions.

Fixes: QTBUG-82389
Change-Id: I4d57a9f611a303cf8dc05caf23b6d331a61684f9
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-05-06 08:43:00 +02:00
Michal Klocek
9edcc46906 Fix qmltestrunner executable location and name
As qmltestrunner is not any longer qt tool.
Adjust the executable name and add the way to find
it outside the qtdeclarative.

Reflects the change in:
https://codereview.qt-project.org/c/qt/qtdeclarative/+/642618

Task-number: COIN-1211
Change-Id: I628de79f09cc27fb4d4fc43f297fcfb0c808ee19
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-05-06 08:26:01 +02:00
Martin Storsjö
80c73dc38b Add static casts needed for initializer lists on 32 bit platforms
This fixes build errors like these:

    src/corelib/time/qtimezonelocale.cpp:836:34: error: non-constant-expression cannot be narrowed from type 'Index' (aka 'unsigned int') to 'qsizetype' (aka 'int') in initializer list [-Wc++11-narrowing]
      836 |                         best = { range.size, type, invalidIanaId, row.metaIdIndex };
          |                                  ^~~~~~~~~~
    src/corelib/time/qtimezonelocale.cpp:836:34: note: insert an explicit cast to silence this issue
      836 |                         best = { range.size, type, invalidIanaId, row.metaIdIndex };
          |                                  ^~~~~~~~~~
          |                                  static_cast<qsizetype>( )
    src/corelib/time/qtimezonelocale.cpp:856:34: error: non-constant-expression cannot be narrowed from type 'Index' (aka 'unsigned int') to 'qsizetype' (aka 'int') in initializer list [-Wc++11-narrowing]
      856 |                         best = { range.size, type, row.ianaIdIndex };
          |                                  ^~~~~~~~~~
    src/corelib/time/qtimezonelocale.cpp:856:34: note: insert an explicit cast to silence this issue
      856 |                         best = { range.size, type, row.ianaIdIndex };
          |                                  ^~~~~~~~~~
          |                                  static_cast<qsizetype>( )

Change-Id: Iacb130a8240c56a32d30486180c6900e2c2f526f
Pick-to: 6.9 6.8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-06 09:24:07 +03:00
Aurélien Brooke
8bbdeaef85 qlogging: replace heap buffer with stack in win_outputDebugString_helper
The stack should have room for the 64KB. We don't use std::array to
avoid unecessary zero-initialization.

Amends a049325cc708b483ed1aadc6589419f4d74b19f3.

Change-Id: I0e2ce0a74914010e259ae832995823d382c9276c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-06 08:19:16 +02:00
Tim Blechmann
7d9b930b6f QSocks5SocketEngine: avoid interface as parameter name
`interface` is used by win32 headers. avoiding it fixes unity builds on
windows.

Pick-to: 6.8 6.9
Change-Id: I85c05e70f4986f2f384850458f7a460baacf6baf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-04 08:31:09 +02:00
Joerg Bornemann
86d93cc349 Doc: Show how to pass the -codesign argument to macdeployqt
It's not obvious how to correctly quote arguments with spaces when using
the DEPLOY_TOOL_OPTIONS argument of qt_deploy_runtime_dependencies. Add
an example for the -codesign argument of macdeployqt.

Pick-to: 6.8 6.9
Fixes: QTBUG-136348
Change-Id: Ic7f11c52f234bd3022976289a8facc7627e20c67
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-05-03 09:52:40 +02:00
Ahmad Samir
f8987b2d0a qdataurl: extend the unittests
Check:
- data: urls with a host are treated as malformed
- if the mime type is omitted, it's set to
  "text/plain;charset=US-ASCII" as per the RFC[1]
- the mime type of urls with a `charset` attribute are
  normalized by adding "text/plain;" (Qt implementation detail) if it's
  missing

[1] https://www.rfc-editor.org/rfc/rfc2397.html

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Ifd9736b7808226c8462e3d39798abda7b245c6d8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-02 23:54:37 +03:00
Aurélien Brooke
88f2d7aacb Allow Q_ASSERT macros family to be called outside of the Qt namespace
Using these macros currently leads to the error: ‘qt_assert’ was not
declared in this scope; did you mean ‘TestNamespace::qt_assert’?

Prepend the Qt namespace to fix this.

Change-Id: I17cf429087d431e1b11ea820d37efa1d6d6d6aa2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-02 22:54:37 +02:00
Laszlo Agocs
2be8501123 rhi: d3d12: Add the most basic 3D texture mipmap generator
Change-Id: Ibd79abb3f568c986bd483c2f7f6ab8898bdcb346
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-05-02 19:51:48 +02:00
Laszlo Agocs
69e026f674 rhi: d3d12: Fix up sampling in the mipmap generator
Unclear if the results are different after this. The RenderDoc-based
investigations show the generated mip levels identical at first glance,
but the original logic is doing useless things: trying to rely on
mipmapping is futile when generating the mipmaps, while surely all
mip levels should be exposed to the shader that selects one based
on the level passed in from the C++ side.

(of course, exposing that single level via a view might just make
the level argument ignored or clamped, with the result of
SampleLevel() probably being the same regardless)

Change-Id: Ieae52fd45d19113e2d0bdab1736fb5d78cd55c3f
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-05-02 19:51:48 +02:00
Volker Hilsheimer
84da5450c3 macOS: use correct icon pixmaps in native menus
When creating an NSImage from a QIcon to show the icon of the action in
native menus, then we so far didn't take the state (on/off) or mode
(normal/disabled) of the UI element into account. This resulted in a
menu item showing the Normal/Off icon of an action, even if the
underlying action was disabled or checked.

Icons in menus are not common on macOS, but since we have the
information we need in QCocoaMenuItem, we might just as well use it to
get the right pixmap from the QIcon (even if that pixmap is generated
from the Normal/Off pixmap).

Add an overload to our NSImage::imageFromQIcon helpers that takes a mode
and state, call that from the existing overload, and use it in
QCocoaMenuItem::sync.

Pick-to: 6.9 6.8
Fixes: QTBUG-135934
Change-Id: Ifce73daf49ce34c874fa5bf652d84b3102a06709
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-05-02 19:01:04 +02:00
Joerg Bornemann
25b040acc1 CMake: Don't unconditionally enable the ASM language
CMake MR #10626 doesn't consider the MSVC compiler as valid assembler
anymore, thus unconditionally requiring ASM breaks with CMake > 4.0.1 on
MSVC.

Enable ASM only on non-Android Unix.
Remove the ASM language where it's not needed.

Pick-to: 6.5 6.8 6.9
Change-Id: I5df71edfce0f4920e39262f722e4bf95a735f31b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-05-02 18:13:14 +02:00
Even Oscar Andersen
f016201b6d wasm: Update input field geometry on window geometry change
The location of the input field was wrong leading to empty space
inserted in the user interface.

Fixes: QTBUG-136233
Pick-to: 6.9 6.8
Change-Id: Ic8c9faf5c4dbb8cec43a43c25c1cce8d7809f140
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
2025-05-02 18:13:13 +02:00
Nicolas Fella
81f8eee6a1 QCompleter: Set transient parent on popup
In order to properly show a popup the Wayland QPA needs a parent window.

Currently it has to guess the parent, which might not work in all
circumstances. To address that explicitly set the widget as transient
parent of the popup.

Fixes: QTBUG-130474
Pick-to: 6.9 6.8
Change-Id: I99ea14a1a9ec25ee8a929cf61a6744957a850374
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-05-02 18:13:13 +02:00
Juha Vuolle
197f07b4e7 Compile androidnotifier only if widgets are available
The example links against widgets => add proper build-time
guard.

Task-number: QTBUG-136101
Pick-to: 6.9 6.8
Change-Id: I9e279791de5adf4e8bc86a09cb11e96022f9e1ce
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-05-02 16:51:15 +03:00
Tor Arne Vestbø
ccce91461a Revert "iOS: Replace variable length array in event dispatcher with QVarLengthArray"
This reverts commit be93c06758260b1e0738ab17a2ecc4ee8f90e87e.

The assumption was that using a QVarLengthArray was equivalent to
the existing C-style VLA, as we initialized the QVarLengthArray
with defaultStackSize as the Prealloc template argument.

However we failed to take into account that we adjust the stack
size via Stack::computeSize(), by adding space for our memory
guard, so we would effectively always end up with the user-main
stack on the heap.

This caused problems for Qt Quick's V4 engine, because it checks
for C++ stack overflow by comparing the current stack pointer to
the base and limit given by pthread_get_stackaddr_np and RLIMIT_STACK,
resulting in "RangeError: Maximum call stack size exceeded." errors
and failure to load the QML.

We can't tweak what pthread_get_stackaddr_np reports for an already
started thread, so in practice we can not put the user-main stack
on the heap, so we revert back to the use of C-style variable length
arrays, which should be fine for this specific use-case.

Change-Id: I05a4bd32697abee71aa9e70f9f5a011cc338f915
Pick-to: 6.9 6.8
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-05-02 13:17:52 +02:00
Even Oscar Andersen
981757189c wasm: call "focus" on window, not canvas
This is necessary to have correct focus handling on webassembly/ubuntu
without this change tabbing from text input to f.ex a button would
not work.

Change-Id: I78eaa6202d8bdb87b1195d5c38a3f73570a49c90
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
2025-05-02 11:19:05 +02:00
Juha Vuolle
67ad781c05 Exclude tests that require future, when future is disabled (wasm)
qfuturesynchronizer and qresultstore both rely on QFuture. Guard
their autotests accordingly.

Task-number: QTBUG-136101
Change-Id: I84680fd3383ceaa486bff53ad04b4a39e9e20d51
Reviewed-by: Lorn Potter <lorn.potter@qt.io>
2025-05-02 08:25:10 +03:00
Christian Ehrlicher
aed4307a1f WindowsVistaStyle: misc cleanup of QWindowsVistaStyle::standardIcon()
Clean up QWindowsVistaStyle::standardIcon a little bit by using
separate icons for SP_TitleBarMaxButton and SP_TitleBarNormalButton

Pick-to: 6.9
Change-Id: I876d41f0373268a0a8888f00392a8e32d0f413a1
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-05-01 20:22:58 +02:00
Christian Ehrlicher
dbbe65fb26 SQL/MySQL: adjust check for MariaDB client library
The correct define to check for MariaDB C Connector is
MARIADB_PACKAGE_VERSION_ID, not MARIADB_BASE_VERSION (which is a string
describing the server version the c connector relates to).

Pick-to: 6.9 6.8
Task-number: QTBUG-136550
Change-Id: I844900d9b6622fd3a72db63298e5c34de8a2f3dc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-05-01 20:22:40 +02:00
Even Oscar Andersen
fd09d6f5d5 wasm: a11y - add back incorrectly removed focus handler
Task-number: QTBUG-135024
Change-Id: Ia0b5dba60985e36899a5bee116ab2f6cb05c602c
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-05-01 16:06:39 +02:00
Even Oscar Andersen
7f9a580872 wasm: Make sure cellphone keyboard does not show needlessly
The last fix for QTBUG-136050 did not set inputMode "none"
which causes the keyboard to be visible on cell phones and
tablets.

Fixes: QTBUG-136050
Change-Id: If8c97fb009c10ff5338ce7e6516ca2c5a992d0d0
Reviewed-by: Lorn Potter <lorn.potter@qt.io>
2025-05-01 15:45:15 +02:00
Mitch Curtis
11c171553e Revert "XCB: set devicePixelRatio on backing store QImages"
This reverts commit c70fd79a178a1e9a186cf8b2f78986e0a39845b4.

Reason for revert: causes a regression.

Pick-to: 6.9
Fixes: QTBUG-135867
Change-Id: Ia9a9049da778749d657ab999edd777650e572b86
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-05-01 09:12:21 +00:00
Morten Sørvig
51c7503568 a11y: reduce the number of activation observer calls
Reduce the number of activation calls by calling the
observer callbacks on active state change only, instead
of on each setActive() call.

The accessibility backends typically make setActive()
calls on each accessibility event, which can result
in a large number (100k+) of activation calls if there
are many (hundreds) of installed activation observers.

This change keeps the following behavior compatibilities:

- Each observer is called at least once on setActive(),
  even if the active state has not changed since it was
  installed.
- Going from active to inactive is supported, though
  Qt currently does not appear to do this.

As a drive-by refactor, make it possible to activate
accessibility by calling QAccessible::setActive(), by
making it call QPlatformAccessible::setActive().

Change-Id: Iee17160f153b825be032b441923e3529c2f00242
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-05-01 02:44:18 +00:00
Christian Ehrlicher
e57fff6341 Widgets/Stylesheets: compile without FEATURE_style_stylesheet
Make sure to not compile the stylesheet sources when
FEATURE_style_stylesheet is disabled, also don't include the relevant
headers in this case.

Pick-to: 6.9
Fixes: QTBUG-136341
Change-Id: I4fc2de2fcba004b93140809ef79374401209f14a
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-05-01 02:45:02 +02:00
Christian Ehrlicher
a1612886ba Widgets/Stylesheets: Remove double negations for stylehseet feature
Replace ifndef QT_NO_STYLE_STYLESHEET antipattern by
if QT_CONFIG(style_stylesheet).

Pick-to: 6.9
Task-number: QTBUG-136341
Change-Id: I8f5d5ff0b7b5cce010df167977214bc92a9443b7
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-05-01 02:45:02 +02:00
Christian Ehrlicher
e19607611c Windows11/VistaStyle: use delegating ctor
Use delegating ctor for QWindows11Style and QWindowsVistaStyle to avoid
code duplication.

Pick-to: 6.9
Change-Id: Ia5048d989a1d6556b64a3ffc95da5d05624cd634
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-05-01 00:58:35 +02:00
Christian Ehrlicher
0d4e044165 Widgets: compile without features tabwidget/tabbar/toolbutton
Move the usage of the corresponding QStyleOption classes into a
QT_CONFIG() guard to fix compilation when these options are disabled.

Pick-to: 6.9
Change-Id: I68e791f20bbc8389974878e765b08a97eb347b92
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-05-01 00:58:35 +02:00
Christian Ehrlicher
69053eea3f Widgets: remove some unused includes
Remove some unused includes in source files.

Pick-to: 6.9
Change-Id: I5c43fd10fa1a179664ad8cbf4988f9bdb96d8af8
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-05-01 00:58:35 +02:00
Christian Ehrlicher
29238407af Tests/QTreeView: use QCOMPARE_foo instead QCOMPARE
Replace some QCOMPARE(value > x) with QCOMPARE_GE(value, x) to get
better output on failure.

Pick-to: 6.9
Change-Id: I3f7fc80cf25776adab40cd61c08c58a49f6af0c5
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-05-01 00:58:34 +02:00
Christian Ehrlicher
33c2931429 QLaoyut: remove check for QT_CONFIG(menubar)
Even though the member is named 'menuBar', it's a plain QWidget. Also
the setter are not guarded so the functionality should not be guarded
too.

Pick-to: 6.9
Change-Id: I5fa19ab955d9794aa3d344ba0cfc8a0a3d22b61e
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-05-01 00:58:34 +02:00
Allan Sandfeld Jensen
2b7ecfab7d Fix qRound(inf) assert
In some extreme cases we can return a finite float, and then turn it
infinite when multiplying it to calculate the index positions.

Avoid the whole thing by clamping to a brightness of +-32768 times the
white point standard, which is well within current HDR standards.

Credit to OSS-Fuzz which detected the assert.

Pick-to: 6.9 6.8
Change-Id: If007732a8d59ea27514f17674d318a099a057281
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
2025-04-30 20:51:40 +00:00
Mårten Nordheim
70d3293d72 Http2: Fix 'Received' typo
Missing 'e'.

QHttp2Connection is private API so the API can be changed.
No known external users.

Pick-to: 6.9 6.8
Change-Id: I4f3daab9deff3250ff66066dc3e088edfbbfc5ef
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-04-30 20:03:25 +00:00
Aurélien Brooke
3020aa0a1f rhi: vulkan: set object names on pipelines too
It helps debugging.

Change-Id: Ibb01bf9ebbeb06c05fd4be2ca17277dff8247c5f
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-04-30 21:06:03 +02:00
Aurélien Brooke
a343d5fe58 rhi: vulkan: bail out if device loss occurs during vkWaitForFences()
The NVIDIA driver may become unstable (including kernel lockups) if
Vulkan API calls continue after a device loss.

Ensure we stop frame processing immediately when vkWaitForFences()
returns VK_ERROR_DEVICE_LOST. Also, don't try to vkWaitForFences() when
calling releaseSwapChainResources() after a device loss.

Change-Id: I2c35a7a7ad07830778b6dc4d40f1ce62535e988a
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-04-30 21:06:03 +02:00
Juha Vuolle
cdeb245340 Skip UDP parts of tst_qnetworkinterface if UDP sockets not enabled
Task-number: QTBUG-136101
Pick-to: 6.9 6.8
Change-Id: Ib3be9ae7c3a261c606cf242a15279491304de6b6
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-04-30 19:35:55 +03:00
Juha Vuolle
01e253e77c Put tst_qnetworkproxyfactory behind networkproxy feature
..as it heavily relies on it and fails to build without.

Task-number: QTBUG-136101
Pick-to: 6.9 6.8
Change-Id: Ie2ba55e485cf96d568b0b22f27e19ffa72f48da9
Reviewed-by: Mate Barany <mate.barany@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-04-30 19:35:55 +03:00
Juha Vuolle
6816273f0e Fix tst_dnslookup compilation when udpsocket is disabled
Guard the UDP socket includes and uses with feature flag.

Task-number: QTBUG-136101
Pick-to: 6.9 6.8
Change-Id: I1fe27244e6aa029407b07ebc06de137ec8b280af
Reviewed-by: Mate Barany <mate.barany@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-04-30 19:35:55 +03:00
Juha Vuolle
2f91439d05 Fix tst_noqteventloop compilation if localserver disabled
..by feature-guarding localsocket and localserver uses.

Task-number: QTBUG-136101
Pick-to: 6.9 6.8
Change-Id: Icc6327fa222edda31fe9e88ec38c916dcd359eb0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-04-30 19:35:55 +03:00
Thorbjørn Lund Martsum
3692f14a30 Remove semantic tests in QHeaderView auto (+avoid signed overflow)
When QHeaderView was optimzed+refactored a unittest was requested.
However, since behavior didn't change a semantic test of certain
qheaderview aspects was added instead (to compare to old behavior).
It was suggested as a manual test, but it was decided to merge
it into the unit test.
With the risk of testing something twice, these semantic tests have
now been modified to be actual unit tests. Certain aspects of
behavior in QHeaderView may actually be wrong
(also highlighted by these new unit tests)
and changing QHeaderView for the better
would be difficult having these tests.
Furthermore, the changes were motivated by the test having
integer overflow.

Fixes: QTBUG-135201
Change-Id: Iabfaf9b57de5cb11d98ea27f352b17ab0f6cc613
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-04-30 13:43:40 +00:00
Liang Qi
c5a4ab54c9 client: add some debug info in QWaylandTextInputv2
Pick-to: 6.9 6.8
Change-Id: Ia34ef1bd7093c7aa71b862418595a0882e251131
Reviewed-by: Inho Lee <inho.lee@qt.io>
2025-04-30 15:34:08 +02:00
David Edmundson
1d3de3e8c8 tests: Fix role used by XdgPopups
Change-Id: Iec367da682588f615f9d8a193d912f5367de7ae2
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2025-04-30 15:34:08 +02:00
Shawn Rutledge
b01fe1390c maybeSynthesizeContextMenuEvent: accept mouse event if CME accepted
Prior to 84a5f50c7766c99f62b22bb4388137e0aa8dd13d
QWidgetWindow::handleMouseEvent() did its own synthesis of
QContextMenuEvents. Then we moved it to
QWindowPrivate::maybeSynthesizeContextMenuEvent() and didn't preserve
the code to accept the QMouseEvent if the QContextMenuEvent was
accepted. It turns out that the WASM platform depends on checking
whether the QPA mouse press event was accepted: if not, it closes
all popups, including any context menu that was just opened by a
right mouse press.

Fixes: QTBUG-136241
Change-Id: Ibe01763a6af19d65629dc77eb61ffc1af581efbe
Pick-to:  6.8 6.9
Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2025-04-30 13:00:26 +00:00
Jie Liu
3bd2a2f8ee datacontrolv1: emit clipboard mode changed when selection changed
Pick-to: 6.9
Change-Id: I47508a88d2115ee92521b0499f72faa566e6b3a3
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-04-30 11:19:01 +00:00
David Edmundson
8c0dd12f4b Drop workaround to turn popups into main windows
On Wayland there are additional requirements when making popups to Qt.

In regular cases we can guess what the popup parent should be based on
which window last received input, but as it's a heuristic with obscure
enough timing events this can sometimes fail.

In this situation the current code creates a toplevel instead of a
regular popup, having a popup take focus with a window decoration is
rarely a good UX. Rather than making an incorrect window, the new
approach is to not create a popup over the wire and synthesise an
immediate close event. Application code should be able to handle this as
it's the same path if the popup was denied server side.

Pick-to: 6.9
Task-number: QTBUG-136343
Change-Id: Ia76c36a047e93f2469a8bf0f4b94642f05179124
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2025-04-30 13:18:46 +02:00
David Edmundson
991c83cc96 Set geometry before creating shell window
Otherwise we risk creating the window with one geometry only to immediately
change it.

Fixes: QTBUG-136494
Change-Id: I140b51f895a12c448dee7859b8fb12bb5b60227b
Reviewed-by: David Redondo <qt@david-redondo.de>
2025-04-30 10:09:38 +01:00
Kai Köhne
d1e030f6f5 configure: Bail out early if Xcode is not installed on macOS
Currently, configure fails late with

     Qt requires at least version 15 of Xcode, you're building against
     version . Please upgrade.

Pick-to: 6.9
Change-Id: Ic4f44d37429ac9def785a50909a25b0bcb4b72a5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-04-30 10:54:05 +02:00
Safiyyah Moosa
ae6ba06e55 Doc: Add alt-text for Qt Network examples
QDoc generates warnings for images that do not have an alternate-text
associated with it. Alt-text is required for to increase accessibilty
options.

This patch adds alt-text to images in the Qt Network

Fixes: QTBUG-135122
Pick-to: 6.9 6.8
Change-Id: I690f1d381ef5a9052e189dd1f3906243df557da0
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2025-04-29 22:54:13 +02:00
David Edmundson
a0161a2b78 client: Use separate queue for SHM buffers
With the current setup, clients can try and submit buffers without
waiting for frame callbacks. This can lead to buffers being exhausted.
When this happens we go into a blocking path waiting for buffers to be
freed. The current implementation dispatches all events on the main
queue, which means we can be processing input events in the middle of
our drawing code, leading to obscure crashes.

This code uses a separate queue for shm buffers. This queue is processed
on the main thread manually before trying to re-use an old buffer this
queue is dispatched. If we need to block, we poll, but only dispatch the
one queue.

In addition explicitly dispatching solves a separate race condition.
Frame callbacks are always handled in the frame event thread. Depending
on how threads are woken this can be processed before main event thread
notifies of new events. This can lead the Qt main thread to be
processing drawing before we process the buffer release and consider the
buffer still busy. The end result is clients using one more buffer than
necessary. The explicit dispatching of shm events solves that problem.

Co-authored-by: Vlad Zahorodnii<vlad.zahorodnii@kde.org>
Pick-to: 6.9
Task-number: QTBUG-134234
Change-Id: Id8a84c72f669f187e368fd5ef32e8e4c150f8849
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-04-29 15:29:26 +00:00
Edward Welbourne
2edd9286cf Fix long-form zone parts in date-time strings
Recent changes to date-time formatting arranged for time-zone names to
be localized appropriately. Teach the datetime parser to recognize the
long names that now implies, as well as IANA IDs, and ensure these
last are also used as a fallback when no localized long name is
available. Discrepancies between the platform time-zone backend and
our CLDR-derived name L10n (where needed, due to the backend lacking
it) make the naive approach to this (find any zone that matches,
expect them all to have the same offset history) fail, so take care in
this case to select as canonical an IANA ID for the named zone as we
can find. Add a round-trip test and adapt an existing test to
round-trip when it can.

[ChangeLog][QtCore][QDateTime] The tttt format specifier now uses the
full long name of the zone, falling back to its IANA ID only if this
cannot be determined. Both forms are now recognized when reading a
datetime from a string.

[ChangeLog][QtCore][QLocale] When serializing a datetime, the tttt
specifier now uses the localized full long name of the zone, falling
back to its IANA ID only if this cannot be determined. Both forms are
now recognized when reading a datetime from a string.

Pick-to: 6.9 6.8
Fixes: QTBUG-130278
Change-Id: Ia28529790c0f600930d55c92a606adbcdfa852b9
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-04-29 16:04:33 +02:00
Edward Welbourne
ef5d9702a9 Move system locale later in uiLanguages(), when adding it as fallback
Place it after the last mutually intelligible entry (same language and
script), or at the end if none, rather than at the start. The fact
that we add it at all was prompted by macOS leaving it out, which can
happen if the user has specified custom preferred languages that don't
match what they've specified for locale.

Adapted various test-cases to match the new behavior.

[ChangeLog][QtCore][QLocale] When the system locale itself is missing
from what the system reports as suitable languages into which to
translate the UI, it is now inserted later in the list, where
previously it was added at the front.

Task-number: QTBUG-104930
Change-Id: I378d266d6f8894cb17df9d09e841a266da73ecee
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-04-29 16:04:07 +02:00
Edward Welbourne
55f69018b3 Fix minor details in QLocale::uiLanguages() docs
An illustration missed out an entry.
Technically truncations go after equivalents of their source.

Change-Id: Ia514c3e0991cbc552c6314a26c6d0569b38e9f16
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2025-04-29 16:03:54 +02:00
Juha Vuolle
5776865f7c Compile calendarbackendplugin only if widgets are enabled
The example links against widgets unconditionally => add
proper build-time guard

Task-number: QTBUG-136101
Pick-to: 6.9
Change-Id: I62ea42a04f7ff421753a0fc7a30cd969cfaff6e2
Reviewed-by: Magdalena Stojek <magdalena.stojek@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-04-29 17:00:12 +03:00
Juha Vuolle
3bbe9d8ec7 Fix tst_qlocale compilation when jalalicalendar is disabled
The 'syslocaleapp' test helper application was built only when
jalalicalendar is enabled. The tst_qlocale on the other hand
depends on 'syslocaleapp' if process-support is enabled.

Thus if jalalicalendar was disabled and process-support
enabled, the CMake configure fails because tst_qlocale won't meet
its 'syslocaleapp' dependency.

Fix by building a more limited version of the syslocaleapp when
jalalicalendar isn't supported, and adjust the testcase accordingly.

Pick-to: 6.9 6.8
Task-number: QTBUG-136101
Change-Id: Ic809b0124d47754105ca09b69e2b3c12856ba63a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-04-29 17:00:12 +03:00
Magdalena Stojek
776dbdce7b QXmlStreamReader: add support for retrieving raw inner XML content
This change introduces a new function, readRawInnerData(), that returns
the raw inner XML content of the current element, including nested tags,
comments, CDATA, and processing instructions.

[ChangeLog][QtCore][QXmlStreamReader] Added readRawInnerData() for
retrieving the raw inner XML content of an element.

Fixes: QTBUG-85141
Change-Id: I96dd0790d726cf8a196125384cbf8f8fa2587880
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-04-29 16:00:12 +02:00
Matthias Rauter
9319f79060 Add tests for QUtf8StringView
This is a port from QLatin1StringView to QUtf8StringView.

Some functions of QL1SV have no counterpart to QU8SV:
* first() and last()
* count()
* indexOf()
* toUtf8()
that were not included.

Tests for user defined literals have also been removed. Some tests were
extended for utf8 string literals u8"".

Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-132097
Change-Id: I0ceee00a7457360b430d13c3199f642f8e4c0036
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-04-29 15:11:05 +02:00
Tobias Koenig
e016730b93 Schannel: Fix import of PKCS12/PFX files with CSP bag attribute
Use the PKCS12_ALWAYS_CNG_KSP flag instead of PKCS12_PREFER_CNG_KSP
when importing a PKCS12/PFX file to make sure the private keys are
stored in the Key Storage Provider, so that the
CERT_NCRYPT_KEY_HANDLE_PROP_ID property is set on the associated
certificate and the subsequent query for it succeeds.

Background: If the PFX file contains a Crypto Service Provider (CSP)
bag attribute and PFXImportCertStore is called with the
PKCS12_PREFER_CNG_KSP flag, then the private keys are stored in the
CSP that is referenced in the bag attribute and the key is only
accessible through the deprecated API.

Change-Id: If2ad2fa6a7b20f02e40fc49c98e3a72b68d832f2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-04-29 11:14:10 +02:00
Even Oscar Andersen
a27bc0a70d wasm: Make sure typing with window focus does not produce characters
contenteditable on the window caused characters to be inserted.
Instead create a div as a child element, and set  contenteditable
on that.

Fixes: QTBUG-136050
Change-Id: I4ccf3589ea19876f68bb9c7077c3a13ae5f989e6
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-04-29 06:39:42 +02:00
Tor Arne Vestbø
6f67925799 macOS: Add native interface API to manage visual effect view
NSVisualEffectView is the only supported way to add effects to
views, such as showing a blurred representation of the content
under the window, or within the window.

Now that we render the content of our QNSView into a sublayer
of the view's root layer, we can add NSVisualEffectViews as
child views without obscuring the view's own content, by making
sure that the NSVisualEffectView layer has a lower Z order in
the layer tree of our view's root layer. This works because
adding a layer-backed or -hosted view as a subview will also
add its layer as a sublayer of the view's layer, making the
effect layer and our content layer sibling layers.

Change-Id: Iab822e8462f54025559b3e3f26c7df668c885d75
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-04-29 04:02:52 +02:00
Volker Hilsheimer
db7e2d6fd0 QGIM: fix test coverage for gadgets-that-are-tuples
The test data for SingleColumn and MultiColumn disambiguation types
was incorrectly removed in 7803e6c000cc0fddba392bcbaefdc3a93ff4b26c.

Inserting rows of a MultiColumn wrapper around a pointer doesn't work,
so QEXPECT_FAIL that test for now.

As a drive-by, remove an obsolete QEXPECT_FAIL; we never add a table of
pointers in multiple value categories, as they all reference the same
data.

Change-Id: Ief4750094f8262f01ff81aa41d113971abd37307
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-04-29 03:04:50 +02:00
Volker Hilsheimer
25f5bd5f66 QGIM: simplify new/deleteRow for tables
Conceptually, a table can deal with rows that are a pointer type,
and nullptr. We test for validity before accessing the row element, and
can return gracefully from e.g. data() or setData(). This is also
acceptable for lists, where a newly constructed row will hold a nullptr
element as the item. Client code that wants to initialize new rows
explicitly can provide their own protocol, or connect to rowsInserted()
and rowsAboutToBeRemoved().

However, we might end up violating the requirement that in a table, all
rows have to have the same number of columns: if the row-type is a
pointer to a struct or gadget, and we don't instantiate the element,
then we end up with an index that is de-facto invalid even though
it is in range. setData() cannot do anything but return false, and
data() can only return an invalid QVariant.
And if the row type is dynamically sized, and the new row is inserted
at index 0, then we end up reporting that the model has 0 columns, as we
use row 0 as the reference for the column count.

To fix this, implement new/deleteRow consistently for pointers (and
smart pointers): if the row type is a (smart) pointer holding
a default-constructible object, then we can instantiate a new object.
The deleteRow implementation takes care of deleting raw pointers (as
otherwise the `delete row` expression is invalid); for smart pointers,
the smart pointer takes care of memory management.

All other row types can be instantiated by default constructing. This
covers MultiColumn/SingleColumn wrappers as well, which can hold a
nullptr while still reporting the correct column count.

Remove the special handling from canInsertRows() - if newRow() is
available in the protocol, then we can insert rows.

But one ambiguity remains: if we operate on a copy of a container that
has pointers for rows, then adding new rows might allocate (in the
model's copy), resulting in a mixed situation. The client code can not
delete those new rows (they don't exist in the original container),
while the model must not delete rows it didn't create (those do exist
in the original container and might still be used).

Perhaps that cannot be solved, other than by documenting: either move
your range in the model (then ownership is clear), or pass a reference
or pointer the model (then ownership is also clear); or use smart
pointers for the row type.

Change-Id: I18a2e929473d118dcdb9d1f2ed67a7890f681974
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-04-29 03:04:50 +02:00
Marc Mutz
4d839093b4 qDecodeDataUrl(): fix precondition violation in call to QByteArrayView::at()
It is a precondition violation to call QByteArrayView::at() with
size() as argument. The code used that, though, as an implicit
end-of-string check, assuming == ' ' and == '=' would both fail for
null bytes. Besides, QByteArrays (but most certainly QByteArrayViews)
need not be null-terminated, so this could read even past size().

To fix, use higher-level API (startsWith()), consuming parsed tokens
along the way.

Add a test that would crash in debug mode before the fix.

Amends the start of the public history.

[ChangeLog][QtCore] Fixed a bug in the handling of data: URLs that
could lead to a crash if Qt was built with assertions enabled. This
affects QNetworkManager and links in QTextDocument.

Pick-to: 6.9 6.8 6.5 6.5.9 6.2 5.15
Change-Id: I4331c88051dfbb0a18fe7da4f50858c707785d09
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-04-28 23:54:58 +00:00
Tor Arne Vestbø
0bdbf4688e macOS: Use dedicated content CALayer for Metal/Raster content
By making the content layer a sublayer of the view's root layer (our
container layer) we open up the possibility of manually managing the
z-order between the content and other sublayers of the view's layer,
for example sublayers added as a result of adding NSVisualEffectView
child views to our view.

[ChangeLog][macOS] Metal and Raster windows no longer render
their content directly to the root CALayer of the window's
NSView, but to a sublayer of the root layer. This is an implementation
detail that should not be relied on, but may affect client code
that pokes into the NSView of the QWindow in unsupported ways.
To opt out of the new mode, set QT_MAC_NO_CONTAINER_LAYER=1.

Change-Id: I7053d7530b6966ed7dd4d1a4d1b7e94754767c57
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-04-28 19:52:26 +02:00
Alexey Edelev
d60930be38 Fix typos in qt_internal_add_plugin in the TEST_PLUGIN related warning
Amends 40def717978f832027542dad507e7873ccc0e1f6

Pick-to: 6.9
Change-Id: I807b1b7db8c2d473355759c1db12cc2a9ead802d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-04-28 19:36:26 +02:00
Tim Blechmann
7491628061 Network: avoid interface as parameter name
`interface` is used by win32 headers. avoiding it fixes unity builds on
windows.

Pick-to: 6.8 6.9
Change-Id: I1d3f89a201f44f6e4eed5977d1b80f675078d430
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-04-29 00:09:40 +08:00
Even Oscar Andersen
bc2c963510 wasm: Install cut/copy/paste handlers on window for not chrome
This is how it used to be.
More changes are needed to fix cut/copy/paste.

Change-Id: Ib5073b82a568a391581f0b4d8369eaab57fd8f19
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-04-28 17:27:40 +02:00
Volker Hilsheimer
3c46f2ef96 QGIM: standardise detection of metaobject, also for smart pointers
Change-Id: I01acbfecfad582dd663c9ae2540be277414935db
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-04-28 17:27:40 +02:00
Tor Arne Vestbø
91ec68313a Quote CMAKE_OSX_SYSROOT when checking for simulator SDK
With CMake 4.0 the CMAKE_OSX_SYSROOT is no longer automatically set
based on the CMAKE_OSX_DEPLOYMENT_TARGET or host platform, so the
variable will be empty by default.

Pick-to: 6.9 6.8
Change-Id: Icad8e044a9d58e995882672b27340c83eb0ae0a8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-04-28 12:55:49 +02:00
Topi Reinio
56e0be45c7 Revert "Doc: Modify \tabcontent..\endtabcontent macros"
This reverts commit 5c0b08a20dd14f7fd8632495aa911fe427f58f7f.

After the original commit, DocBook support for tabbed
content was introduced (as format-specific macros). This
means that the original macros will also have to be HTML-format
specific, as macros cannot have both default and
format-specific variants defined.

In addition to reverting, add linefeeds to (end)tabcontent.HTML
macros to solve the same problem that the reverted commit did.

In passing, fix an issue with the tabcontent.DocBook macro; it
takes a single argument, therefore the placeholder for the
value must be \1.

Change-Id: I90ed6bc37d70c10754b3b810198ac44fcd189766
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: David Boddie <david.boddie@qt.io>
2025-04-28 10:28:35 +00:00
Nodir Temirkhodjaev
3982de725a qlocale_win.cpp: Fix unity-build
Error after commit f039077830f41ca7ea7b1d91a4f7ad45a6613ea6:
.../qtbase/src/corelib/text/qlocale_win.cpp(745):
 error C2872: 'Windows': ambiguous symbol

C:\Program Files (x86)\Windows Kits\10\include\10.0.26100.0\winrt\wrl/
client.h(927): note: could be 'Windows'

C:\Program Files (x86)\Windows Kits\10\include\10.0.26100.0\cppwinrt\
winrt/Windows.System.UserProfile.h(890): note: or 'winrt::Windows'

Amends 51e8d3592acc8bacf326fe3933b5dec13bb518e6

Change-Id: Ia32faa86bee6a284a5ad50ed82dcf8f08ab28dfd
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-04-26 01:55:07 +00:00
Tor Arne Vestbø
9a06c8ae8c Bump iOS minimum deployment target to iOS 17
[ChangeLog][iOS] The minimum deployment target is now iOS 17.

Change-Id: Ie00f707a0626bc3ee6007cc7272a5a848efeafca
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-04-25 20:45:42 +02:00
Tor Arne Vestbø
25ba5f5782 Bump macOS minimum deployment target to macOS 13
[ChangeLog][macOS] The minimum deployment target is now macOS 13.

Change-Id: I92f79dd94b8183c8dd4e7a9a69e2312ae0b9cda1
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-25 20:45:42 +02:00
Volker Hilsheimer
3cb5f45dda QGIM: remove unnecessary friend declaration for the test class
We don't need it (for now), and it causes ambiguities with namespaced
builds on MSVC, so remove it. If we need it again, then we need to
forward declare the class in the global namespace first.

Fixes: QTBUG-136136
Change-Id: I96c7d2557a5e84d3fd78eb9098442e19024347b5
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-04-25 19:16:47 +02:00
Alexandru Croitor
9bc8ce6608 CMake: Skip walking empty targets in __qt_internal_walk_libs()
If one of the interface link libraries of a target is
  "$<LINK_ONLY:$<BUILD_LOCAL_INTERFACE:Foo>>"
this will be exported by cmake as
  "$<LINK_ONLY:>"
in the exported INTERFACE_LINK_LIBRARIES property.

When walking the dependent libraries of a target using
__qt_internal_walk_libs(), this value will become empty after
unwrapping the LINK_ONLY genex.

In such a case, we should skip further processing of the library.

Otherwise in some weird unknown conditions, CMake might consider the
empty name to be a valid target, and cause errors when trying to read
properties from it.

Amends ad7b94e163ac5c3959a7e38d7f48536be288a187

Pick-to: 6.9
Fixes: QTBUG-136039
Change-Id: I143dec697e10530379486462697cd299940ee463
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-25 18:14:24 +02:00
Morten Sørvig
f4287c4531 wasm: fix clipboard event handler leaks
Use QWasmEventHandler instead of calling addEventListener()
directly (using QWasmEventHandler also allows supporting
JSPI). The QWasmEventHandler destructor calls removeEventListener(),
which should make sure everything gets cleaned up.

Keep the Chrome-specific global (document) event handler code path,
but register once at startup instead of once per window.

Change-Id: If4314df738afc0dcfdb0f6f1ab9e1f176e1812ac
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-04-25 18:14:23 +02:00
Timur Pocheptsov
d4efce2119 CMake: add Photos.framework to framework helpers
This would allow us using Photos.framework/PHAssets on iOS (instead
of now-deprecated 'Assets' library).

Change-Id: I922e4765e8fdadf872f801b55a1e4ef4368e65b0
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-04-25 18:14:23 +02:00
Morten Sørvig
913829ae4e wasm: use emscripten::typed_memory_view()
Use typed_memory_view() instead to create UInt8Arrays
pointing to an area of the heap, instead of HEAPU8.

Fixes issue on emsdk >= 4.0.7 where HEAPU8 etc are
no longer exported by default.

Change-Id: I2c632b2c54dc1e9947b11ab3d2613d790b994440
Reviewed-by: Lorn Potter <lorn.potter@qt.io>
2025-04-25 16:14:23 +00:00
Ivan Solovev
ab48b4f266 QDataStream:: bump version
It is required to update the serialization of QGeoPolygon
in QtPositioning.

Need to adjust tst_qdatastream as well.

Task-number: QTBUG-135967
Change-Id: I81bf1c011717d5ecd92fd6c81136053b4f06bf49
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-04-25 17:44:43 +02:00
Ivan Solovev
f12115e97c Cleanup tst_qdatastream
Make NColorRoles constexpr and use static_assert() to verify that it
has a proper size.

Pick-to: 6.9 6.8
Change-Id: I40351e4815e248fe8cc07e906099172d5be531d0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-25 17:44:43 +02:00
Edward Welbourne
01eb9297d0 Skip redundant QLocale() argument to QTimeZone::displayName()
It's the default, and wasn't telling us anything illuminating about
the tests, so leave it out and save some line-splits.

Change-Id: I1bcc51db9b71489a3edcf25f4b2c7a90c86399bb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-25 16:39:24 +02:00
Edward Welbourne
5a911f72c6 Check status of QDataStream in QTimeZone tests using it
It makes sense to verify the stream is OK after writing and reading,
so add those tests.

Change-Id: I459856ed0d991bc3bbe4044b6694c97970cf2787
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-25 16:39:24 +02:00
Edward Welbourne
0278a80d68 Correct initialization of justAfter in QLocale::uiLanguages()
It's used to determine whether a non-equivalent prefix of a locale
gets added at the end of the block of equivalent locales, or at the
very end of the list. Thus it should be initialized for each prefix as
it is processed, not before the name is trimmed to its first prefix.

Added the test-case that caught this.
Amends commit cbf49f735e3cca85922a85d6548666816686db78

This should work as-is in 6.9 but may be hard to back-port to 6.8.
None the less, I shall try for the latter, too.

Pick-to: 6.9 6.8
Task-number: QTBUG-131894
Change-Id: I75ab27153133d2608cf57f0bc998c1e3d0d1432c
Reviewed-by: Mate Barany <mate.barany@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-25 14:39:23 +00:00
Mårten Nordheim
29ff5af430 QNetworkAccessManager: Remove unused class member
No alternate backend refers to this cache, and probably hasn't
for quite some time.

Change-Id: Id0e6a652bd58a45d13de8dfc4a3e0d6f35dee5a7
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-04-25 16:39:23 +02:00
Ali Kianian
7b8fd0c410 QBoxLayout: Add ownership info to the QBoxLayout methods
Change-Id: I4fd08588b940dee286fce5c0243404e1a1c3367a
Reviewed-by: Mats Honkamaa <mats.honkamaa@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2025-04-25 14:37:31 +03:00
Shawn Rutledge
66595c3efe QTextMarkdownImporter: spell CRLF literal correctly
Amends eced22d7250fc7ba4dbafa1694bf149c2259d9ea

tst_QTextMarkdownImporter::frontMatter(yaml + markdown with CRLFs)
now does explicit replacement of LF with CRLF: git may convert the file,
so we can't rely on the CI test system checking out a true copy of
yaml-crlf.md; but QFile::open(ReadOnly | Text) ensures that we will
have LF line endings, not CRLF.

Pick-to: 6.8 6.9
Task-number: QTBUG-135284
Change-Id: I7eee5f41e7aea902a59ac06238e591ece016d2d3
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2025-04-25 08:04:53 +02:00
Alexey Edelev
0d41b56eaf Replace _qt_is_android_executable property with _qt_android_target_type
New property is more flexible in terms of further deployment extension.
Currently it only knows the APPLICATION type but will support new types
in the future.

Change-Id: I6bdadfbbe162a990544903b3cbcfae2891114e88
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-04-25 02:22:20 +02:00
Alexey Edelev
44a43b0aba Fold set_property call for Android executables
Small QoL improvement. The folded set_target_properties call looks
nicer.

Pick-to: 6.5 6.8 6.9
Change-Id: Id60e8c346672733a805e09420c754a24bcae82dc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-04-25 02:22:20 +02:00
Alexey Edelev
5c30ae2c9f Add support for _qt_internal_configure_file(GENERATE ... INPUT
Allow generating files from template file. The signature first
expands the '@' wrapped variables in template file and then generates
the resulting file using file(GENERATE command.

Pick-to: 6.8 6.9
Change-Id: I0b4cf557da1d5161ffcde1c44aea98c440427980
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-04-25 02:22:20 +02:00
Tor Arne Vestbø
4280d97719 Silence compilation warning about SecureTransport being deprecated
We know it's deprecated, and have a bug report to track it, so we don't
need a compilation warning on each build.

Task-number: QTBUG-119171
Change-Id: Iea9e45ae154761efb0960acf34a79953518024c1
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2025-04-25 01:25:51 +02:00
Tor Arne Vestbø
04506aa878 Silence a few "No relevant classes found" moc warnings
Ideally we'd have a moc macro/define to opt out of the warning,
but for now this will have to do.

Change-Id: Iffe943191edc553840e1a83dc307926813a5d6f1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-04-25 01:25:51 +02:00
Alexey Edelev
18f491a192 Do not punish users for using dashes in plugin target names
Implicitly convert the target name to a valid C indentifier, so users
may use dash-separated names for their targets. Add warning about
plugin name substitution, for the cases where this might be critical.

Task-number: QTBUG-135860
Change-Id: Ie148424ec182a3b1ce2af2a0e29c2f9eb8d457f1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-04-24 22:43:01 +02:00
Alexey Edelev
086bb48768 [androidtestrunner] Add option for the AndroidManifest.xml
Allow specifying path AndroidManifest.xml from command line.

Change-Id: I4a2301b98befe32c27602ff63b65aea8a4686123
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-04-24 21:10:43 +02:00
Alexey Edelev
ea575585e7 CMake: Fix SBOM PROJECT_COMMENT CMP0174 related warning
We should only pass PROJECT_COMMENT if it has a value.
We also need to escape semicolons, because the project comment might
contain the qt configure line, and that might have passed arguments
like -qpa offscreen\;xcb

Pick-to: 6.8 6.9
Change-Id: I934cf75c376b3466ba91a433d009e6eaa77a60fa
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-24 21:10:42 +02:00
Jerome Pasion
03efecf818 Doc: Add link to Export Controls page in the OpenSSL overview
-A new Export Controls page has a larger overview
-Edited parts of the section

Fixes: QTBUG-134259
Pick-to: 6.9
Change-Id: Iaceb2501eeb848544f8004bfae03a3cdf36908af
Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2025-04-24 20:05:13 +02:00
David Boddie
83383dbbc7 Doc: Restore link to the Ok status value
Change-Id: I630caa2f76ce4fd4476b9027513b55f257d90d4b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-24 20:05:13 +02:00
Marius Kittler
f039077830 Avoid separate qt_…_target call for qlocale_win.cpp
Change-Id: Ib309fbf0c106f8bbc81b4a714994087543494605
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-04-24 19:58:55 +02:00
Marius Kittler
ee8d5453e2 Link corelib correctly against runtimeobject when compiling for Windows
This library is included by mingw-w64 and also needs to be linked against
for code in `qlocale_win.cpp` enabled via the `cpp_winrt` feature flag.

Change-Id: I9f06f3845165afaf305a0fc7771a1093cba08811
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-24 19:58:55 +02:00
Tor Arne Vestbø
5e6308b0f5 Silence NSUserNotification{Center} deprecation warnings
We know it's deprecated, and have a bug report to track it, so we don't
need a compilation warning on each build.

Task-number: QTBUG-110998
Change-Id: Icf5a670532cd923dc90d594621b38dbb6d344e2d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-24 19:58:55 +02:00
Marcus Tillmanns
3fbdb31420 macOS: respect strikeout attribute in menu item fonts
When we draw menu item text with CoreText instead of QPainter, then we
need to translate QFont::strikeOut() explicitly to an entry in the
attribute dictionary.

Task-number: QTBUG-136215
Change-Id: Ic4a895cd10c950c477acffca0078718490f4f0b7
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-04-24 18:35:13 +02:00
Eskil Abrahamsen Blomfeldt
395451e15f Upgrade Harfbuzz to 11.1.0
[ChangeLog][Third-Party Code] Upgraded Harfbuzz to version
11.1.0.

Pick-to: 5.15 6.5 6.8 6.9
Task-number: QTBUG-136054
Change-Id: I388586c887a3ae30ecc7b07bb0b6a5c12d3b6caf
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-04-24 18:22:54 +02:00
Alexandru Croitor
3c80dd518a CMake: Clean up leftover attribution values during SBOM generation
When processing multiple attribution files to collect all attribution
ids, the values of the previous iteration extracted keys were not
reset.

This caused the values to leak to the next processed attribution id
target if the specific id key was empty.

Make sure to clean up the values before parsing the next attribution
key.

Pick-to: 6.8 6.9
Change-Id: I386fc9c09276c49207382b06605efeb0d939b6da
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-24 17:22:54 +01:00
Juha Vuolle
11b54b85ce Fix tst_qnetworkreply compilation when networkproxy is disabled
Add a feature guard for test function relying on networkproxy.

Pick-to: 6.9 6.8
Task-number: QTBUG-136101
Change-Id: I69d97c84fb7d68f33f4b74fc8fd6665b1b8d6717
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-04-24 16:49:22 +03:00
Juha Vuolle
bdacb87cef Make autotests configurable without Widgets on Android
tst_android depends on widgets, and parts of the test
needs to be excluded if Qt is configured without them.

Pick-to: 6.9 6.8
Change-Id: Iaca5b4228c0a7bd7c3a2efe9da04f354ac7e7c1c
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-04-24 16:49:22 +03:00
Juha Vuolle
2542d79281 Add explicit QPalette include to tst_qtextdocumentfragment
Test case relies on transitive include and fails to compile if this
include chain is broken e.g. by disabling features.

Pick-to: 6.9 6.8
Task-number: QTBUG-136101
Change-Id: Id34c9f8ec86468aaf4dda116be8d46591ebd9185
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-04-24 16:49:22 +03:00
Marc Mutz
6079d7cd9c Mark QtPrivate::StreamStateSaver's ctor as [[nodiscard]]
As a RAII class, QtPrivate::StreamStateSaver's ctors should be marked
as [[nodiscard]].

Amends 3c93286f08a80b6e1821d7d63d361742b25c6578, but not picking all
the way back since 959800f6de137f6a77c7d5a2741a5bae0638cbd9
(Q_NODISCARD_CTOR) was only added in 6.6.

QUIP: 19
Pick-to: 6.9 6.8
Change-Id: If39fd79d21c52d60481973a416ae5f7da1858f7a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-24 15:49:22 +02:00
Morten Sørvig
9240b9ace5 Discourage use of QScreen::devicePixelRatio()
Remove line about "common values" which is now not
100% accurate and uses the outdated "retina" term.

Add note which encourages using QWindow::devicePixelRatio()
to get the correct DPR value in all cases.

Task-number: QTBUG-135612
Change-Id: I78e049cb2f0661b62bc3e2520a4b3cbf1fde241d
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-04-24 09:53:23 +00:00
Tor Arne Vestbø
59d77a0162 Disable {position,resize}Automatic on QPlatformWindow creation
Once the platform window has been created it has had its chance to
set a default position and size, which is reflected back to the
QWindow. Destroying and recreating the window after that should
keep the position and size, even when those have been changed by
the end user via the system's window manager.

We were effectively doing this for size already, as initialGeomery
only applied a default size if the size was 0x0, but we were failing
to preserve the position. We now handle both cases explicitly.

[ChangeLog][QtGui] A destroyed and recreated QWindow will now maintain
its position and size, instead of allowing the platform window another
chance at setting a default position and size. Users of QWindow and
its consumers that reuses a single window for many "logical" windows
need to explicitly position and size the window for each "use".

Change-Id: Ib9a395295e6dfdc6db908e2c96be60046f462c30
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-04-24 11:44:32 +02:00
Marc Mutz
2471115715 Remove traces of QDataStreamPrivate
It's no longer used since 9b2835e464748f499758a7eef0d4c49452e7211a.

Pick-to: 6.9 6.8
Change-Id: I8a075e9d645290af3a7fe5b9b2fa7a5a7a7b4909
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-24 09:44:05 +00:00
Giuseppe D'Angelo
eeead68995 Examples: fix a couple of nodiscard warnings from QFile::open
In one case, the code simply checked for isOpen afterwards; refactor
it to use QFile::open's result. In another case, a file was opened
from the resource system, so add a check.

Pick-to: 6.9 6.8
Change-Id: I5f4c22dd5ce678f15c9c1609c4228d50a2b32a1d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-24 10:44:03 +01:00
YAMAMOTO Atsushi
d8f07f43e5 Fix build error when tablet support is disabled
When Qt is configured with -no-feature-tabletevent, QtWayland fails to
build because code referencing QWaylandInputDevice::mTabletSeat is still
compiled, even though mTabletSeat is only available when tablet event
support is enabled.

Pick-to: 6.9 6.8
Change-Id: Iad82ea47cfc64040772429f469d9104b75490891
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Tasuku Suzuki <tasuku.suzuki@signal-slot.co.jp>
2025-04-24 09:15:42 +00:00
Juha Vuolle
323f408be6 Make Qt for Android configurable without 'clipboard' support
Fixes: QTBUG-135675
Pick-to: 6.9 6.8
Change-Id: I844cd96f977bd0b5536606cf0c2449a87502231a
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-04-24 07:03:32 +03:00
Juha Vuolle
f5b5f16bfa Make Qt for Android configurable without 'accessibility' support
The code was already partially behind the feature flag, but not fully.

Pick-to: 6.9 6.8
Fixes: QTBUG-135693
Change-Id: Iad76221837aa37b90b3be998afc41ce9bbc05c55
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-04-24 07:03:22 +03:00
Juha Vuolle
965af8548c Make Qt for Android compile without permissions -feature
The permissions were partially behind 'future' feature flag.
Instead put permission code behind the actual 'permissions'
feature flag, and require 'future' feature if permissions
are enabled.

Fixes: QTBUG-135617
Pick-to: 6.9 6.8
Change-Id: I573cca6a56c19bfc32a3f1df72a009cbe05ad2fb
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-04-24 07:03:12 +03:00
Ahmad Samir
637a2a2983 QMetaObject: remove commented out normalizeTypeInternal() declaration
It is out-of-sync with the actual implementation in qmetaobject_moc_p.
we could change the parameter types, but it will only go out-of-sync
again if the implementation is changed in the future. So just remove the
whole comment.

Amends 916460929d1de315262d4a9ee91280ecaf3f58f1 and
4dbac23e5354638224d8d99ba3342067c015a04b.

Pick-to: 6.9
Change-Id: Id41d2818266cf22765f0ae7f11265c0e840d5af3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-24 00:44:14 +02:00
Marc Mutz
bb38a2929d Mark QtPrivate::StreamStateSaver's ctor as explicit
A QDataStream* is not a faithful representation of a
QtPrivate::StreamStateSaver, so the ctor should be explicit.

Amends 3c93286f08a80b6e1821d7d63d361742b25c6578.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I63f8fa19070960bf70c965ffbc270070d10eacd7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-24 00:29:43 +02:00
Assam Boudjelthia
e8aa9ff638 Android: release deadlock protector from requestPermissions()
Note this would ideally use androiddeadlockprotector.h, but since
it's living under the plugins directory it won't be accessible for
this code without some refactoring.

Fixes: QTBUG-133841
Pick-to: 6.9 6.8 6.5
Change-Id: I9b62e7a9809ba5e0782a82b9c07d122de544aece
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2025-04-23 22:36:36 +03:00
Eirik Aavitsland
25fbbb5612 Doc: QPropertyAnimation does not update target property when stopped
When stopped, an animations's currentValue can change as a result of
changes to the the start- or end value. The target property will not
be updated, however.

Fixes: QTBUG-125586
Pick-to: 6.9 6.8 6.5
Change-Id: Ib03133db80e92b4d73a1140e9a94d6d7a6b68fc4
Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com>
2025-04-23 19:43:27 +02:00
Edward Welbourne
4702868677 Modernise and refine details in tst_QTimeZone
Use constexpr and const where we can.
Use Qt-defined string literals in a few more places.
Include GenericTime in a displayName() test, and make overt that we
are simply discarding the returns, with no further testing.

Pick-to: 6.9 6.8
Change-Id: Id120fdfe66267b01ff019fe13ac80f37390c106f
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-23 19:17:55 +02:00
Edward Welbourne
7983b9bd9a Tidy up some QTimeZone code and comments
Correct a member comment in LocaleMetaZoneLongNames.
Remove a superfluous else in QUtcTimeZonePrivate::displayName().
Add a TODO comment to QUtcTimeZonePrivate::isTimeZoneIdAvailable().

Pick-to: 6.9 6.8
Change-Id: Iddc144a267ca8fb33a6577e8d671ef3da53ca525
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-23 19:17:55 +02:00
Edward Welbourne
bb8c1b85af Fix spacing and indentation in QTimeZone code
Petty tidy-up, just to disentangle it from other work.

Pick-to: 6.9 6.8
Change-Id: Ifa7543585af35e494185be8faf637e3d48670c4b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-04-23 19:17:55 +02:00
Edward Welbourne
023a8d48e2 Isolate an "enough like C locale" test and use consistently
Various checks for whether a locale was suitable for use of ASCII
offset formats were expressed in terms of QLocale::C. One was wrongly
expressed in terms of isDataLocale(), which is meant to be true for
the locale the backend thinks its data is suitable for. Write a new
method of QTimeZonePrivate to check for this, accepting en-Latn-* as a
good enough match, and deploy where it's the right test.

Pick-to: 6.9 6.8
Change-Id: Ieab129eb5c252732b8916fce017ec0a22684eba8
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-23 19:17:55 +02:00
Alexey Edelev
6e536aba73 Ensure that plugin class name is a valid C indentifier
We should prevent using the invalid plugin class names at CMake
configure stage already, so users receive the early error.

Fixes: QTBUG-135860
Change-Id: I259539f6cce70a035ccf458a62d9e5a02f238ef8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-04-23 18:49:53 +02:00
Even Oscar Andersen
6295e78ade wasm: fix warning in createDirectoryWithParents for "/"
Change-Id: I6cd17ef9dd7ba26cbb8969817f2bcf83cc0ec24d
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-04-23 18:25:50 +02:00
Juha Vuolle
3f5023aada Fix tst_qtextmarkdown compilation when textmarkdownwriter not available
Place the calls to QTextDocument::toMarkdown() behind the same feature
flag as toMarkDown() function itself.

Pick-to: 6.9 6.8
Task-number: QTBUG-136101
Change-Id: I7468f6172cab613695504d7c50075169b46c4bc9
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2025-04-23 18:56:45 +03:00
Juha Vuolle
262a92244b Fix tst_qimage compilation when deprecations are removed
Put both declaration and definition of tst_qimage::mirrored() behind
the same deprecation flags.

Pick-to: 6.9
Task-number: QTBUG-136101
Change-Id: Ib54ee21f7944f1e2b7f9fe35aea9fd8d9e908f95
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-04-23 15:56:45 +00:00
Juha Vuolle
8f940ca197 Fix namespace build when cssparser is disabled
The QT_BEGIN_NAMESPACE was inside "#if TEXTHTMLPARSER" code block,
whereas the QT_END_NAMESPACE was inside a nested "#if CSSPARSER"
block.

Therefore if cssparser was disabled, the file will effectively
have just QT_BEGIN_NAMESPACE, and the build will fail (if it's an
actual namespace build).

Pick-to: 6.9 6.8
Change-Id: Ibd750a71c154cb9596a7227327b7d5b3ab307001
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-04-23 18:56:45 +03:00
Tor Arne Vestbø
2e6032188f Don't stop QPlaformWindow updateRequest timer until after delivery
Delivery of the update request may be circumvented temporarily by the
platform window, or the user may request another update during the
delivery, so wait to stop the timer until we know we don't need it
anymore.

Pick-to: 6.9 6.8
Fixes: QTBUG-135950
Change-Id: Ie6d1f0f726b66ab6a8036f281b46e525084d90e8
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-04-23 15:41:06 +02:00
Morten Sørvig
61be342d02 wasm: set aria-hidden for input context element
This element is not a part of the accessibility implementation,
and should not be visible to the screen reader.

Change-Id: Ifb8c404f7dd5a916cd42856b1f6b4529f2fb3ae0
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
2025-04-23 12:48:00 +00:00
Eskil Abrahamsen Blomfeldt
09805f355c directwrite: Fix embedding fonts in PDF
For a reason still unclear to me, the PDF engine refuses to
embed fonts if the file name is empty (so fonts that are loaded
directly from byte arrays typically). It could be that this in
itself is outdated.

However, embedding fonts that are loaded from the file system has
worked so far, but in Qt 6.8 we moved to the DirectWrite engine on
Windows and this stopped working there.

The reason is that our custom file loader did not support tracking
the file name and thus it would always be empty. This is experienced
as a regression and can only be worked around by manually selecting
the GDI engine instead (with the limitations that implies).

We fix this by implementing the loader as a IDWriteLocalFontFileLoader
instead, which supports the API which we currently use to retrieve the
paths of system-wide fonts.

Pick-to: 6.8 6.9
Fixes: QTBUG-134695
Change-Id: I1411b0617fd1c113c7c28154968c234920f5289e
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-04-23 11:32:40 +02:00
Christian Ehrlicher
616d33c87a Windows11Style: simplify subControlRect for CC_ScrollBar
The branches for SC_ScrollBarAddLine and SC_ScrollBarSubLine were
identical so avoid code duplication and merge them into one.

Pick-to: 6.9
Change-Id: I77a1303badb500a8d8ada3355b34a42a93fb069a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-23 06:19:29 +02:00
Christian Ehrlicher
5b6cbb9c4e SQL/MySQL: Add milliseconds in formatValue()
MySQL does understand ISO 8601 formatted datetime strings with
milliseconds so use Qt::ISODateWithMs instead Qt::ISODate within
formatValue().

Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-95071
Fixes: QTBUG-136042
Change-Id: I182475c706c8eda0e3f97e23d98d3f91e372244a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-23 06:19:15 +02:00
Christian Ehrlicher
105ddadffe QDateTimeEdit: Unify height of QDateTimeEdit
After 0a1c1711453697a88eee7fdb6f4cf082bfd433e2 a QDateTimeEdit with and
without a popup has different heights in some styles. Fixing the styles
may break existing layouts so we only get the needed width when the
popup is enable from CT_ComboBox and let the height being calculated
by CT_SpinBox to make sure both variants have the same height.

Pick-to: 6.9 6.8
Fixes: QTBUG-135029
Task-number: QTBUG-11967
Change-Id: I01c6f598d34a0b73125e60650c61a84b27d79ac8
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-23 04:19:13 +00:00
Christian Ehrlicher
3208ad494c SQL/OCI: do not shadow QSqlCachedResultPrivate::sql
Rename QOCIResultPrivate::sql to QOCIResultPrivate::stmtp to avoid
shadowing of the sql member from base class.
Remove some useless casts as a drive-by.

Pick-to: 6.9
Task-number: QTBUG-136024
Change-Id: I2a5951991039c4de7aecc29f9161dede7b4f3473
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-23 06:18:27 +02:00
Christian Ehrlicher
87bbcddb1d SQL/OCI: Fix usage of QOCIResult::d_ptr
The refactoring in 82681fd8a2af1113da5bd13875ba71c1efd45afb added a
d_ptr of type QOCIResultPrivate. This shadowed the d_ptr from
QSqlCachedResult and an unitialized QOCIResult::d_ptr variable which in
the end made the whole plugin unusable.
Fix it by removing the unneeded d_ptr member.

Pick-to: 6.9
Fixes: QTBUG-136024
Change-Id: I5ecacba8079eadbfae25a32720b43b4465c096d8
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-23 06:18:21 +02:00
Christian Ehrlicher
78ae4177fa Widgets: pass dpr to QIcon::pixmap()
Replace the last occourences of QIcon::pixmap() which do not pass the
current devicePixelRatio with the correct calls.

Pick-to: 6.9
Change-Id: I440944f784a991a88a8c6bb42e4c79f112bab8f6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-23 06:18:20 +02:00
Thiago Macieira
83d964ea70 QUrl: change the default action for spaces to decoded
That matches the QUrl::ComponentFormattingOptions flags and avoids
modifying the memcpy'ed action table for the default. This applies to
everything we set, since we keep decoded spaces in the strings in
QUrlPrivate.

Amends commit 1b7e9dba75f18342911bc6954be3e754322f091f ("Change the
component formatting enum values so the default is zero") which changed
from DecodeSpaces to EncodeSpaces. And amends the previous commit.

Task-number: QTBUG-135949
Change-Id: I2a9e4ffc62ca4a75f675fffd366204c0a4ee7337
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2025-04-22 21:18:13 -07:00
Thiago Macieira
d3758ce9b0 QUrl: fix mismatch of encoded/decoded spaces in setXxx
Amends commit d064c26d2c1fb1f78013031a83b661ef6f74ce21, which introduced
qt_encodeFromUser(). As far as I can tell and test, only the space
character was an exception, due to this code in qt_urlRecode():

    if (!(encoding & QUrl::EncodeSpaces))
        actionTable[0] = DecodeCharacter; // decode

That meant that encoded spaces was an opt-in, not an opt-out, but is not
the default in the defaultActionTable. This was missed in the new
function.

Fixes: QTBUG-135949
Change-Id: Ic8d2adac5c32f858748bfffd5654aac3c7a2f782
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2025-04-22 21:17:59 -07:00
Thiago Macieira
756766eaa0 QUrl: use universal/forwarding references for QUrlPrivate::setXxx
This avoids an extra copy of the QString provided by the user in the
public API. Amends commit 31207b539a19182b48c4b3b8413190d505633eea,
which said it wanted to "copy the input QString if it is a QString", but
we only want to copy once (onto the QUrlPrivate).

Change-Id: Id77d3646196e52202f07fffd964bca4683d83769
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2025-04-22 21:17:47 -07:00
Tor Arne Vestbø
006329964d Use NSSavePanel.allowedContentTypes instead of allowedFileTypes
The latter has been deprecated as of macOS 12.

Change-Id: I5282ce7a42922e91813c21ebe163dde44a40c6a6
Reviewed-by: Doris Verria <doris.verria@qt.io>
2025-04-23 04:19:59 +02:00
Michael Weghorn
3224b2fb14 wasm a11y: Fix typo in comments
This amends 593c7b9be40f3fa876ffadd7518795a333dc5b74.

Change-Id: Iae1e46cb9b85eb1c47e02b286aa832d2e3b92dac
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-04-23 01:54:09 +02:00
Marc Mutz
3651442e6b Mark QRegularExpression* classes as security-critical
These classes, too, are usually in the first line of defense, used to
check tainted data for validity before anything else gets to see the
result of validation. In fact, in Perl, retrieving regex matches is
the main way to untaint data.

Amends 8df072fc8006510c9b743e8ffedaaf51a876883a.

QUIP: 23
Task-number: QTBUG-135195
Pick-to: 6.9 6.8
Change-Id: I1716f3c95ef110d5e20f3cdb303d4e70db16a6f1
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
2025-04-22 23:03:18 +00:00
Marc Mutz
25cc585a13 Mark QCryptographicHash and QMAC as security-critical
If these classes aren't security-criticial, what is?

Amends 8df072fc8006510c9b743e8ffedaaf51a876883a.

QUIP: 23
Task-number: QTBUG-135198
Pick-to: 6.9 6.8
Change-Id: I50f4ab8139948be57107d27eb2a0b7eb9f898e32
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
2025-04-22 23:03:17 +00:00
Marc Mutz
ef8d3e91d8 Mark QByteArray and QString as security-critical
These classes are usually the first line of defense, containing
tainted data before anything else had the chance the verify it.

Amends 8df072fc8006510c9b743e8ffedaaf51a876883a.

QUIP: 23
Task-number: QTBUG-135195
Pick-to: 6.9 6.8
Change-Id: I91413e022b9794e21b6816b80962f5169ce8cd78
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
2025-04-22 23:03:17 +00:00
Alexey Edelev
bfdedb260e Add the explicit include of qpixmapcache.h to qlabel.cpp
The include is required since code now accesses the respective types.

Amends 7a238e1225f49b81772516ed5d0a5a4f4f2e9268

Fixes: QTBUG-136079
Pick-to: 6.9
Change-Id: I3c8fb8cd5b46875613b866bcb9c6bf7cded926a3
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-04-22 22:07:36 +02:00
Giuseppe D'Angelo
aca7fd4ee7 QKeyValueRange: make sure it is a viewable range
QMap/QHash::asKeyValueRange() returns a QKeyValueRange, which is a
range, but in some cases it doesn't satisfy viewable_range:

https://eel.is/c++draft/range.refinements#6

This causes reasonable code to fail to compile:

  map.asKeyValueRange() | std::views::transform(...)

The reason for this is that, when called on a lvalue map,
asKeyValueRange() returns QKeyValueRange<Map<...> &>. This isn't a
viewable range: it's not a view itself, it's not a lvalue reference to
range, and it's not movable.

The last bit is actually a mistake, because QKeyValueRange<Map<...> &>
contains a reference, and thus it's not assignable. Fix it by making it
contain a pointer instead.

In principle this has ABI implications because we're making the type POD
(from non-POD), and this would allow usage of the tail padding on
Itanium. I am 100% sure that no-one is inheriting from QKeyValueRange.

We can also go a step further and decide to make QKeyValueRange a range
*view*, because it is -- it satisfies all the semantic concepts.
To elaborate, there are two different QKeyValueRange implementations,
one for lvalue maps (stores a pointer to the map) and one for rvalue
maps (moves the map into the range). Conceptually, they map to ref_view
and owning_view in the standard library.

For now I'm only making the QKeyValueRange<&> specialization for lvalue
maps a view. The other one in principle may satisfy the range view
requirements (as the containers are COW, so copy is actually O(1)) but
this is more questionable. A possibility would be to make it move-only,
but that's an API break.

To make QKeyValueRange<&> a view I'm inheriting from view_base, which an
empty class and thus doesn't affect ABI. (I'm not inheriting from
view_interface in order to avoid changing the API between the two cases
above.)

This work unveiled two problems in the implementation of QKeyValueRange.
The first was that the the deduction guides were actually unused for the
const-lvalue argument.  This is because user-defined deduction guides
are added on top of the ones implictly generated by the compiler. The
primary template constructor was used to synthesize a deduction guide
that deduced a non-reference qualified T; the result was that a const
lvalue map would yield a mutable range over a copy of the map (!).
Fix this by getting rid of the deduction guides and explictly specifying
the template arguments of QKeyValueRange.

This fix in turn adds a problem for const rvalue maps (unlikely). The
idea in this case would be to move the map into the QKeyValueRange: the
range stores a map object, initialized by moving the source map.
For a const map source, the stored map should be const as well. But that
makes the range not movable (this is the point of things like
movable-box in the std), and therefore not a view. Since this is a
fringe case, I'm dropping the const for the inner stored map, so one can
effectively realize a mutating iteration over a const rvalue source map.

Task-number: QTBUG-105465
Change-Id: I70161029799376fd369e0332461a8a50e6062892
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-22 22:07:36 +02:00
Ahmad Samir
3a1f4f718d MOC: don't create unnecessary QByteArray copies
To avoid changing the ref count and the associated atomic operations.

Change-Id: I4195383bc15b36be564909bbdbc0abebc3b00787
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-04-22 18:21:34 +00:00
Tor Arne Vestbø
05e59e37c8 macOS: Always override NSApp.appearance on requestColorScheme
We can't compare to the effective appearance, as we'll then fail to
set an explicit appearance if the requested appearance matches the
current appearance, which results in the requested appearance not
sticking when the system appearance changes.

Pick-to: 6.9 6.8 6.5
Change-Id: Ibd8f7825051f1a67bed25a0abb2f1a13356f32d8
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2025-04-22 20:21:34 +02:00
Tor Arne Vestbø
fb555ff7df macOS: Lazily recreate theme palette on theme change
QCocoaTheme::palette() lazily creates the system and role palette
when needed, which we rely on for the initial palette values, so
there's no need to recreate them explicitly during theme change,
as the reset should be enough to recreate them the next time they
are needed.

Change-Id: I14f127e93554b8f97c06f1b88e6216be59124811
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2025-04-22 20:21:34 +02:00
Tor Arne Vestbø
48f161e129 Remove qt_mac_applicationIsInDarkMode in favour of QStyleHints::colorScheme()
Now that we have the information available in QStyleHints we don't
need to expose it as a dedicated helper function, and definitely not
in QtCore.

Change-Id: If5ad3991d78810457b51a30aadc3bf3af593940c
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-22 20:21:33 +02:00
Even Oscar Andersen
a7136c3e7b wasm: Reduce usage of the id attribute
It is not always required, limit it to the cases where it is
explicitly given, or if it is necessary.

Fixes: QTBUG-135024
Change-Id: I451379d86543e2297574d4cda09ef825736f9c5d
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-04-22 13:31:36 +02:00
Juha Vuolle
b27820fbf8 Add clarifying comment on fileenginehandler registration
The instantiated file engine handlers inherit from the private
QAbstractFileEngineHandler class, instantiation means also registration
(~RAII) for Qt file engine classes. This may not be obvious, so
perhaps a clarifying comment is welcome.

Change-Id: Ie8793060a62559e7550d4f808dec947fd5f09ca7
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-04-22 14:29:10 +03:00
Juha Vuolle
8d659669b2 Fix namespace build when networkproxy is disabled
The QT_BEGIN_NAMESPACE macro was inside the "#if networkproxy" code
block, whereas the QT_END_NAMESPACE was outside of it.

When networkproxy feature is then disabled, the file will only
effectively have the QT_END_NAMESPACE macro. This fails to compile
when the build is an actual namespace build.

Pick-to: 6.9 6.8
Change-Id: Ic0b0fd2d086811664a4f66e2c46424d370641355
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-04-22 14:29:04 +03:00
Juha Vuolle
40595f8063 Suppress unused lcQtGuiDrawHelper warning
Put lcQtGuiDrawHelper logging category declaration behind the same
feature flags as its users, to suppress a warning when neither
feature is defined:
qdrawhelper.cpp:38:27: warning: unused function 'lcQtGuiDrawHelper'

Pick-to: 6.9 6.8
Change-Id: Id6eab4e9ab7313475eedfeb20d8d29f84a47f291
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-04-22 14:28:56 +03:00
Juha Vuolle
581e39b35f Allow configuring Qt without highdpiscaling on Windows
When highdpiscaling feature is disabled, a default dummy
QHighDpiScaling class is compiled in. This dummy class missed
the roundScaleFactor() method used by qwindwswindow.cpp, causing
a compilation error.

Pick-to: 6.9 6.8
Fixes: QTBUG-135893
Change-Id: I754878b9bbd55f68f07a19618fc275f89f7f839f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-04-22 14:28:53 +03:00
Juha Vuolle
4790a06b16 Allow configuring Qt without clipboard on Windows
Most feature guards were already in place, this commit adds the
missing ones.

Pick-to: 6.9 6.8
Fixes: QTBUG-135890
Change-Id: I1fbfad6552b2896d867a29134a2add693dbd136f
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2025-04-22 14:28:50 +03:00
Juha Vuolle
a66c73d95e Allow configuring WASM without draganddrop
Pick-to: 6.9 6.8
Fixes: QTBUG-135874
Change-Id: I84459af06d34682ca3bed1e2e1dab773c77bbcae
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-04-22 14:28:46 +03:00
Juha Vuolle
0bf2fafd38 Allow configuring WASM without clipboard
Pick-to: 6.9 6.8
Fixes: QTBUG-135875
Change-Id: Ibf0a51ff0e1268f32d32511dff64003c28137795
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-04-22 14:28:32 +03:00
Axel Spoerl
4748d4303b Blacklist tst_QDnsLookup::lookupRoot() on macOS and Linux
Blocking CI; Blacklist until solved.

Pick-to: 6.9
Task-number: QTQAINFRA-7130
Change-Id: Id420bfd9afcbe23555052ca9c3c8f3703b937bca
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-04-22 08:06:00 +00:00
Christian Ehrlicher
298e811922 Windows11Style/WindowsVistaStyle: don't modify SE_ItemViewItemDecoration
The windowsvista style increased the width for SE_ItemViewItemDecoration
by 4 pixels which lead to a non-square area for the decoration item.
Since the item is painted centered on the given area, this did not
change anything for squared pixmap-based icons. But when using a svg,
the image is automatically stretched to fill the complete area.
Therefore a svg is not painted quadratic but stretched which is not what
a user expects. Looking for other usages of SE_ItemViewItemDecoration
did not reveal another usecase for this so it should be safe to remove
the handling within windowsvista style.

Pick-to: 6.9
Fixes: QTBUG-131955
Change-Id: I65f8e2afd1c2fb310d6a23b1405a920adcbf42c3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-18 21:58:09 +00:00
Marc Mutz
fb7670f193 QMainWindowLayout: de-pessimize ~QMainWindowToolBar
As the code comment says, ~QMainWindowTabBar will removeOne(this) from
QMainWindowLayout::unusedTabBars. It doesn't assert that it was
included in it, or something special like that.

So we can optimize the whole thing by making sure that
~QMainWindowTabBar doesn't find anything to remove here, avoiding a
detach from the copy 'bars' and potentially also avoiding quadratic
behavior, as we delete the items in order.

Found by Coverity, but it only saw this as an optimization opportunity
because it doesn't understand that the copy is needed.

Amends 23357e59bb4dc54e76a237b290aa64a620db2ea1.

Pick-to: 6.9 6.8 6.5
Coverity-Id: 479705
Change-Id: I6c31e028c0c39813768e8c71076471b39bd8ef5a
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-18 15:14:16 +00:00
Alexey Edelev
7ce4a8a8c9 Avoid using the $<CONFIG> based directory in .rc paths
The use of '/$<CONFIG>/' component in .rc path leads to undefined
behavior caused by CMake internal conflicts. Replace the path component
with the filename suffix.

Fixes: QTBUG-136019
Pick-to: 6.5 6.8 6.9
Change-Id: I73ae7f89ac65d00661148fcf41c973945bd2cc4f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-04-18 09:01:38 +00:00
Even Oscar Andersen
53ff8897c5 wasm: a11y - Use aria-label for QAccessible::Name
innerHTML does not work too well with type input. Instead
use attribute 'aria-label'

Task-number: QTBUG-135590
Change-Id: Ibec36a133c650bb51b1f1a84580a5ce35531c137
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-04-17 07:38:01 +00:00
Shawn Rutledge
30fd101b55 Make F11 the fullscreen keyboard shortcut on Gnome (as on KDE & Windows)
This seems to agree with current Gnome documentation.

[ChangeLog][Platform Specific Changes][Linux] The fullscreen keyboard
shortcut is now F11 on Gnome, not Ctrl-F11.

Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-135854
Change-Id: I8ee0bd34152ce8ef112fd3226d17adc89f2a408e
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-04-16 21:12:56 +00:00
Marc Mutz
54865833c5 QAbstractSlider: remove duplicate update() calls from setOrientation()
The sliderChange() base implementation already calls update(), and the
only reason we left the update() call in when we added the missing
sliderChange() call to setOrientation() was to play it extra safe in
the face of misbehaving overrides.

For 6.10, make sure to not penalize correct programs anymore.

[ChangeLog][Important Behavior Changes][QtWidgets][QAbstractSlider]
setOrientation() now relies on sliderChange() to call update(). This
was already the case for setRange(), setSingleStep() and
setPageStep(), and setOrientation() was only handled specially because
of QTBUG-135597.

Task-number: QTBUG-135597
Change-Id: I71ec5caf61bc656c2ef3421b4de696eac8623e8e
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-16 17:49:12 +02:00
Kai Uwe Broulik
e2035be13d gtk3theme: Honor gtk-cursor-blink for whether blinking is on
gtk-cursor-blink-time is in an interval 100..2500ms, GTK uses a
dedicated boolean to determine whether blinking is on in the first place.

Pick-to: 6.9 6.8
Change-Id: I8a5dff70b6b3fbeeab599cf50402532052afe8b7
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-16 17:33:12 +02:00
Ali Kianian
124f05bd10 AssetDownloader: Provide network errors and SSL errors
Network errors and SSL errors are provided as invokable methods.
The end user can collect the errors after download is finished.

Task-number: QTBUG-136035
Pick-to: 6.9 6.8
Change-Id: Ic8bd9b84d331752c096998683b44b85be3cd6b10
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2025-04-16 18:11:38 +03:00
Volker Hilsheimer
b50a2761e7 Widget effects DRY: replace manual pointer handling with unique_ptr
Instead of repeatedly resetting of the static pointers after (or before)
calling deleteLater(), use a unique_ptr with a custom deleter.

Since we use deleteLater(), nothing will happen if one of those widgets
does leak to the point where static objects are destroyed; we'd at most
call deleteLater() at this point, which won't do anything (if we enqueue
a DeferredDelete event at all, then it will never be processed).

Pick-to: 6.9 6.8
Task-number: QTBUG-135976
Change-Id: I36a4780093eafd064dcb1a72696c1d9b21483b77
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-16 14:50:16 +02:00
Marc Mutz
c35f6851bf QAbstractSlider: fix missing "emission" of SliderOrientationChange
QAbstractSlider::sliderChange() is not a signal, but a protected
function, carrying an enum (also protected) to inform subclasses about
changes in the base class.

A user reported (QTBUG-135597) that in 5.15 the function was not
called for SliderOrientationChange. A prior test addition confirmed
that this bug is in all active branches.

Add the missing call in setOrientation().

This _should_ replace the update() call, because the default
sliderChange() implementation already calls it (and setPageStep(),
e.g., relies on this behavior), but since SliderOrientationChange was
not emitted since Qt 5.0, I minimize regression risks and keep the
update() call, just in case a user wrote code where they forgot to
call Base::sliderChange() for SliderOrientationChange (and this never
showed because we never "emitted" that, up to now). The duplicate
update() calls will be merged by Qt's event loop, so are harmless.

A dev-only follow-up change will remove the update().

[ChangeLog][QtWidgets][QAbstractSlider] Fixed the missing "emission"
of protected sliderChange(SliderOrientationChange).

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Fixes: QTBUG-135597
Change-Id: I4545d47d315a98a9a51134901a00fa369f720754
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-16 08:53:24 +02:00
Marc Mutz
49fcac99de QHeaderView: fix more UB (signed integer overflow) in setOffset()
We fixed the first line of defense in
03d1e81516be9af37fa08900f9a2d88d34abc4df, but that commit didn't rule
out ndelta == INT_MIN, in which case -ndelta overflows a few lines
below.

Coverity pointed this out.

Add a check that exposes this problem to ubsan, and avoid the overflow
by using qMulOverflow<-1>()¹ and not scrolling when it overflows, but
emitting a qWarning().

¹ There's no qNegateOverflow()...

When state == QHeaderViewPrivate::ResizeSection, we assume that
everything happens on the actual screen, which has physical limits to
the setOffset() argument, and therefore these arithmetic operations
don't need to be protected.

I fully expect that this will just be a rat's tail, one we can only
hope to control by using Peppe's safe integers everywhere, at which
point we've probably blown our executable code size out of any
proportions. So leave it at this, for the time being.

Amends 03d1e81516be9af37fa08900f9a2d88d34abc4df.

Coverity-Id: 479557
Pick-to: 6.9 6.8 6.5
Change-Id: I2e31fc9be21e7d59563b67f3cd26c29dcea61b55
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-16 06:52:38 +00:00
Marc Mutz
f6d878d5ce qcompare.h: standardize on Coverity-friendly ctors
Coverity complained that the Qt::strong_ordering(std::strong_ordering)
ctor may leave m_order uninitialized, which is true if you assume that
'stdorder' could be anything else but {less, greater, equal}, which,
however, should not happen™.

Standardize on the pattern that QPartialOrdering(Qt::partial_ordering)
was using: init m_order to equivalent, and then check for the other
possible states.

I would have preferred adding 'else Q_UNREACHABLE()', but these are
constexpr functions, so we'd need the GCC 8 protection, and then the
else would have a body longer than one line, and I don't know whether
violating the coding style and adding {} only on the else would fly
with reviewers, so that's done in a follow-up.

Amends several changes (this code has seen a lot of churn over time).

Pick-to: 6.9 6.8
Coverity-Id: 475148
Change-Id: I3d88cdaaffbdfb8720161470b5f89046a3a15088
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-16 07:52:17 +01:00
Marius Kittler
5cabaaecf0 Fix errors due to disabled exceptions with cpp_winrt support
The winrt headers use exceptions so code using them must be compiled
with exceptions enabled. Otherwise one runs into compile errors with
mingw-w64 12.0.0 and GCC 14.2.0.

Change-Id: I216f65b260062ff2020f8a288ddda78c3e9fc3c9
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2025-04-15 22:40:05 +02:00
Thiago Macieira
750a0b5ef6 QList: implement operator<=> for iterators
This fixes an annoying warning with MSVC where it did already compile
  iterator <=> iterator
by way of the deprecated operator*(). GCC and Clang did not compile the
above, though they do compile the other ordering operators.

Fixes: QTBUG-120924
Change-Id: Ie13bf48bc506e7dd719efffdeae55f0735148976
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Rym Bouabid <rym.bouabid@qt.io>
2025-04-15 12:27:05 -07:00
Laszlo Agocs
3f55ac90fc rhi: Remove runCleanup function
The rest of the framework uses cleanup callbacks in a way that implies
that manually triggering the callbacks will lead to problems:
components such as QQuickWidget register cleanup callbacks to get
notified about the destruction of the QRhi. These callbacks should
not be invoked at arbitrary times.

There is no usage of this function anywhere in Qt. Remove it.

Slightly extend the autotest by exercising the keyed registration
functions as well.

Change-Id: I88f1a1e9bc5a642b8e8b6238fe198f123bd55978
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-04-15 21:27:05 +02:00
Frédéric Lefebvre
10f94fe497 Blacklist tst_QFileDialog::completer on vxworks
Blacklist tst_QFileDialog::completer on vxworks as it is preventing the
integration of other patches by failing too often.

Task-number: QTBUG-135963
Change-Id: Ie127801fc02d7c74ae0de4602ee0ea4b9e5c14c2
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-15 16:31:47 +00:00
Morten Sørvig
593c7b9be4 wasm: port a11y event handling to suspendresumecontrol
The accessibility code uses a shared event handler
installed on several elements. Register the event handler
in the constructor and then add it to the a11y elements
as needed.

Change-Id: I9bfc49a3358f15cc62de9c8140cab96cf0b23161
Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@qt.io>
2025-04-15 18:31:47 +02:00
Morten Sørvig
f5231e2dbb wasm: implement promise handler using suspendresumecontrol
This is required to make sure we resume the wasm instance
when a promise resolves. As a bonus QWasmSuspendResumeControl
already implements the JS -> C++ callback mapping, and
we can removed the fixed-4 ThunkPool which the current
implementation is using.

The implementation is straightforward, where the only
snag is that cleanup must be done in the finally callback.

Implement Promise::all by calling JS Promise.all(). This
function returns a new Promise, which we can adopt.

Make two changes to the test:

- remove throwInThen(): We no longer support propagating
  JS exceptions from the then() handler to the catch function.
  (catching a rejected promise still works). As far as
  I can see this functionality is not used in qtbase.

- In finallyWithThen(), change shared_ptr<bool> to plain
  pointer. This works around a (mysterious) issue where we
  were not getting the correct value when reading from the
  shared_ptr.

Change-Id: I8fb11b66ecba74f80708bd39eeeac59bb62f3786
Reviewed-by: Lorn Potter <lorn.potter@qt.io>
2025-04-15 18:31:47 +02:00
Tor Arne Vestbø
03699cc0ff Remove forward declaration of dead QUnifiedToolbarSurface
The class does not exist anymore.

Change-Id: Ifb3d7624b22c86b4b460a595834e956bc458dc44
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-15 15:39:26 +00:00
Tor Arne Vestbø
68a9c5fe51 Remove QWindow argument from QWindowSystemInterface::handleThemeChange
The QPlatformTheme, and consumers on top such as QStyleHints, are app
global, so it doesn't make sense to notify that a single window has
changed its theme.

None of the QPA plugins pass a QWindow to the function today, after
the Windows plugin was taught a few new tricks in a preceding change.

[ChangeLog][QPA] QWindowSystemInterface::handleThemeChange no longer
takes an optional QWindow.

Change-Id: Ia761c95559a56a00763bd3cb95332f377e8de483
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-15 17:31:29 +02:00
Tor Arne Vestbø
fdfed82675 Handle Windows theme changes in central theme listener
Instead of having each window listen for theme changes we
now have a single theme listener window, similar to the
way we handle screen management.

This reduces the amount of redundant callbacks to QWSI
for theme changes somewhat, but Windows still emits
several redundant events even for a single window.
We want the theme change event to be synchronous, so
there is no obvious way to debounce these events,
besides the clearing of the message queue that we
already do in this patch.

Since we don't know exactly what part of the theme
changed we can't bail out of the theme change event
to QWSI based on the color scheme being the same, as
the accent color or other parts of the theme might
have changed.

Change-Id: I827fa50effadf8a8e674a03ddc72958c60310f48
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Zhao Yuhang <2546789017@qq.com>
2025-04-15 17:31:29 +02:00
Kai Uwe Broulik
4468b53645 QWaylandXdgSurface: Always use XDG Dialog for modal windows
Even when it doesn't have a transient parent Qt knows about.
The surface might get a parent assigned externally through XDG Foreign.

Change-Id: I21dbfd00aa0ff78e26ce4c111fe260f18b9dc905
Reviewed-by: David Redondo <qt@david-redondo.de>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-04-15 14:15:37 +00:00
Kai Uwe Broulik
b964195096 client: Include unistd.h
It's needed for write.

Change-Id: I0533ed01c5325c1b8313db1eeef0163bbf8c166c
Reviewed-by: David Redondo <qt@david-redondo.de>
2025-04-15 15:30:17 +02:00
Michael Weghorn
745bbca004 tst_reconnect: Include <unistd.h>
This fixes this build error seen in a local -no-pch
clang 19 build:

    [17/19] Building CXX object qtwayland/tests/auto/client/reconnect/CMakeFiles/tst_wl_reconnect.dir/tst_reconnect.cpp.o
    FAILED: qtwayland/tests/auto/client/reconnect/CMakeFiles/tst_wl_reconnect.dir/tst_reconnect.cpp.o
    /usr/bin/ccache /usr/bin/clang++ -DQT_CORE_LIB -DQT_EXPLICIT_QFILE_CONSTRUCTION_FROM_PATH -DQT_GUI_LIB -DQT_NO_AS_CONST=1 -DQT_NO_CONTEXTLESS_CONNECT=1 -DQT_NO_FOREACH -DQT_NO_FOREACH=1 -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_QASCONST -DQT_NO_QEXCHANGE -DQT_NO_QSNPRINTF -DQT_OPENGL_LIB -DQT_STRICT_QLIST_ITERATORS -DQT_TESTCASE_BUILDDIR=\"/home/michi/development/git/qt5/qtwayland/tests/auto/client/reconnect\" -DQT_TESTCASE_SOURCEDIR=\"/home/michi/development/git/qt5/qtwayland/tests/auto/client/reconnect\" -DQT_TESTLIB_LIB -DQT_WAYLANDCLIENT_LIB -DQT_WAYLANDGLOBAL_LIB -D_GLIBCXX_ASSERTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I/home/michi/development/git/qt5/qtwayland/tests/auto/client/reconnect/tst_wl_reconnect_autogen/include -I/home/michi/development/git/qt5/qtwayland/tests/auto/client/reconnect -I/home/michi/development/git/qt5/qtbase/include -I/home/michi/development/git/qt5/qtwayland/tests/auto/client/shared -I/home/michi/development/git/qt5/qtbase/include/QtGui -I/home/michi/development/git/qt5/qtbase/include/QtCore -I/home/michi/development/git/qt5/qtbase/mkspecs/linux-clang -I/home/michi/development/git/qt5/qtbase/include/QtOpenGL -I/home/michi/development/git/qt5/qtwayland/src/client -I/home/michi/development/git/qt5/qtbase/include/QtWaylandClient/6.10.0 -I/home/michi/development/git/qt5/qtbase/include/QtWaylandClient/6.10.0/QtWaylandClient -I/home/michi/development/git/qt5/qtbase/src/corelib -I/home/michi/development/git/qt5/qtbase/include/QtCore/6.10.0 -I/home/michi/development/git/qt5/qtbase/include/QtCore/6.10.0/QtCore -I/home/michi/development/git/qt5/qtbase/src/gui -I/home/michi/development/git/qt5/qtbase/include/QtGui/6.10.0 -I/home/michi/development/git/qt5/qtbase/include/QtGui/6.10.0/QtGui -I/home/michi/development/git/qt5/qtbase/include/QtWaylandGlobal -I/home/michi/development/git/qt5/qtwayland/src -I/home/michi/development/git/qt5/qtbase/include/QtWaylandGlobal/6.10.0 -I/home/michi/development/git/qt5/qtbase/include/QtWaylandGlobal/6.10.0/QtWaylandGlobal -I/home/michi/development/git/qt5/qtbase/include/QtWaylandClient -I/home/michi/development/git/qt5/qtbase/include/QtTest -D_GLIBCXX_DEBUG -g -std=gnu++17 -fPIE -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -fPIC -fcf-protection=full -ftrivial-auto-var-init=pattern -fstack-protector-strong -fexceptions -MD -MT qtwayland/tests/auto/client/reconnect/CMakeFiles/tst_wl_reconnect.dir/tst_reconnect.cpp.o -MF qtwayland/tests/auto/client/reconnect/CMakeFiles/tst_wl_reconnect.dir/tst_reconnect.cpp.o.d -o qtwayland/tests/auto/client/reconnect/CMakeFiles/tst_wl_reconnect.dir/tst_reconnect.cpp.o -c /home/michi/development/git/qt5/qtwayland/tests/auto/client/reconnect/tst_reconnect.cpp
    /home/michi/development/git/qt5/qtwayland/tests/auto/client/reconnect/tst_reconnect.cpp:123:65: error: use of undeclared identifier 'dup'
      123 |     m_comp.reset(new DefaultCompositor(CoreCompositor::Default, dup(socketFd)));
          |                                                                 ^
    /home/michi/development/git/qt5/qtwayland/tests/auto/client/reconnect/tst_reconnect.cpp:130:65: error: use of undeclared identifier 'dup'
      130 |     m_comp.reset(new DefaultCompositor(CoreCompositor::Default, dup(socketFd)));
          |                                                                 ^
    2 errors generated.
    ninja: build stopped: subcommand failed.

Change-Id: I2bf139ec582f90e2b447223c3092836c79483156
Reviewed-by: David Redondo <qt@david-redondo.de>
2025-04-15 15:30:15 +02:00
Volker Hilsheimer
3a21b4bcaf Blacklist tst_Android::orientationChange
The test fails almost daily.

Task-number: QTBUG-119205
Pick-to: 6.9 6.8
Change-Id: Ice5d14701cc72cd6b0a0fb73bf85b5edddd019f6
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-15 14:10:13 +02:00
Frédéric Lefebvre
b760967a93 Blacklist tst_QFileDialog::clearLineEdit() on vxworks
Blacklist tst_QFileDialog::clearnLineEdit() on vsworks as it is
preventing the integration of other patches by failing too often.

Task-number: QTBUG-135966
Pick-to: 6.9 6.8 6.5
Change-Id: I9a2b9596a9d4783bcc7307c31c5faf8353f49257
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-15 07:22:49 +00:00
Thiago Macieira
4216ba7c37 QSqlDatabase: make evident the name of the driver that failed to load
Tell me this isn't confusing:
 Got keys from plugin meta data ("QMYSQL3", "QMYSQL", "QMARIADB")
 QSqlDatabase:  driver not loaded
 QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3

This also merges the two messages into a single line, which is nicer for
rich logging environments.

Pick-to: 6.8 6.9
Change-Id: Ieb80c6571213dddc518bfffdb6c86632df8f932c
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-04-14 18:09:48 -07:00
Marc Mutz
48959f7e5b QStringConverter: widen nameForEncoding()'s contract
Coverity apparently mixes bootstrap and non-bootstrap builds: it
complains that Encoding::Latin1 indexes encodingInterfaces[]
out-of-range (apparently taking the size of the latter from a
bootstrapped and the value of the former from a non-bootstrap build).

That should somehow be fixed in the Coverity configuration, but it
highlighted the fact that we have a narrow-contract function in this
security-critical class that can trivially have a wide contract, so
widen the contract by returning nullptr for invalid Encoding values.

Consequently, mark the function as noexcept.

As a drive-by, mark it also as Q_DECL_PURE_FUNCTION.

[ChangeLog][QtCore][QStringConverter] The nameForEncoding() function
now returns nullptr for an invalid Encoding value. Before, such a call
resulted in undefined behavior.

Pick-to: 6.9 6.8 6.5
Coverity-Id: 480251
Change-Id: Ie1c5c9df6881147a1ff44fe549e50748b2f5b7da
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-14 18:59:49 +00:00
Antti Määttä
07255301ea Fix recursion in QLoggingRegistry
QLoggingRegistry relies on any Qt code it uses not having category
logging in it, because it causes a global variable to be recursively
initialized. This has been the case so far, but with CTF tracing
enabled, there is Qt code that uses category logging if the first
tracing event originates from a logging category, causing the tracing
library to be loaded.

It is undefined behavior to recurse into the initialization.

Here is the backtrace of the situation:

QGlobalStatic<QtGlobalStatic::Holder<()::Q_QGS_qtLoggingRegistry> >::instance
QGlobalStatic<QtGlobalStatic::Holder<()::Q_QGS_qtLoggingRegistry> >::operator()
QLoggingRegistry::instance
QLoggingCategoryWithEnvironmentOverride::registerOverride
QLoggingCategoryWithEnvironmentOverride::QLoggingCategoryWithEnvironmentOverride
QtPrivateLogging::qt_lcDebugPlugins
locatePlugin
QPluginLoader::setFileName
QPluginLoader::QPluginLoader
loadPlugin
initialize
_tracepoint_enabled
QtPrivate::trace_QObject_ctor
QObject::QObject
 ...
QFile::QFile
loadRulesFromFile
QLoggingRegistry::initializeRules
QLoggingRegistry::QLoggingRegistry
(anonymous namespace)::Q_QGS_qtLoggingRegistry::innerFunction
QtGlobalStatic::Holder<::Q_QGS_qtLoggingRegistry>::Holder
QGlobalStatic<QtGlobalStatic::Holder<::Q_QGS_qtLoggingRegistry> >::instance
QGlobalStatic<QtGlobalStatic::Holder<::Q_QGS_qtLoggingRegistry> >::operator()
QLoggingRegistry::instance
QLoggingCategory::setFilterRules
main

Add a recursion guard in the QLoggingRegistry that causes
QLoggingRegistry::instance to return null if recursion occurs.
The internal code appears to handle nullptr well, while external code
should always receive a non-null pointer.

Fixes: QTBUG-135326
Pick-to: 6.8 6.9
Change-Id: I91f1ff341b096031930004cca8421f2ee0bab9b1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-14 19:41:41 +03:00
Volker Hilsheimer
7ffa6f1dd5 QMenu: show when QWidget::childrenRect is not empty
Amends 353ce5344fbde5a6cecbdd2c131e1cf0f4b7f383 after which QMenu::popup
returned early and without showing the menu if none of the actions had a
valid geometry in the menu.

This broke use cases where QMenu was used as a regular container widget
with child widgets (possibly in a layout). To fix this, take the result
of QWidget::childrenRect() into account, and only return early if that
rect is also empty.

Task-number: QTBUG-129108
Fixes: QTBUG-135933
Pick-to: 6.9 6.8
Change-Id: I05977044411df236146bb81dc08a30c176dfb6cb
Reviewed-by: David Faure <david.faure@kdab.com>
2025-04-14 18:41:41 +02:00
Xu Shitong
be2729cd7c QGuiApplication: Prevent double-click recognition across different windows
Two consecutive clicks on different windows should not be recognized as
a double-click event. Add window tracking to ensure double-clicks are
only detected when they occur within the same window.

Changes:
- Add static QWindow tracking for last pressed window
- Add window equality check in double-click detection logic
- Update window tracking after each mouse press event
- Add test auto test case

Fixes: QTBUG-134721
Change-Id: I0ca8460a447ca27b04f3d545176d478c90f6b830
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-04-14 16:41:41 +00:00
David Faure
71dedf56d7 QWaylandWindow: fix data race on mFrameCallbackTimedOut
WARNING: ThreadSanitizer: data race
  Write of size 1 at 0x7b5000008aa0 by thread T51 (mutexes: write M1, write M2):
    #0 QtWaylandClient::QWaylandWindow::waitForFrameSync(int) qtwayland/src/client/qwaylandwindow.cpp:784 (libQt6WaylandClient.so.6+0xdd6a9)
    #1 QtWaylandClient::QWaylandGLContext::swapBuffers(QPlatformSurface*) qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp:393 (libQt6WaylandEglClientHwIntegration.so.6+0xc706)
    #2 QOpenGLContext::swapBuffers(QSurface*) qtbase/src/gui/kernel/qopenglcontext.cpp:783 (libQt6Gui.so.6+0x80c6df)
    #3 QRhiGles2::endFrame(QRhiSwapChain*, QFlags<QRhi::EndFrameFlag>) qtbase/src/gui/rhi/qrhigles2.cpp:1984 (libQt6Gui.so.6+0x85bbda)
    #4 QRhi::endFrame(QRhiSwapChain*, QFlags<QRhi::EndFrameFlag>) qtbase/src/gui/rhi/qrhi.cpp:7689 (libQt6Gui.so.6+0x58faf0)
    #5 QSGRenderThread::syncAndRender() qtdeclarative/src/quick/scenegraph/qsgthreadedrenderloop.cpp:748 (libQt6Quick.so.6+0x7bb88a)

  Previous write of size 1 at 0x7b5000008aa0 by main thread:
    #0 QtWaylandClient::QWaylandWindow::timerEvent(QTimerEvent*) qtwayland/src/client/qwaylandwindow.cpp:1480 (libQt6WaylandClient.so.6+0xdc079)

Pick-to: 6.9 6.8 6.5
Change-Id: Ieb8819c5a273e6581975b258d4728bb6f3325da6
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
2025-04-14 14:37:50 +02:00
Magdalena Stojek
3265f40939 Refactor QXmlStreamWriterPrivate constructor to modernize initialization
Apply NSDMI and move initializations to the constructor initializer list

Fixes: QTBUG-135897
Pick-to: 6.9 6.8
Change-Id: I7adff41fa006669677df457704d20c02f1af7197
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-04-14 14:05:10 +02:00
Volker Hilsheimer
920a490d65 Silence code checker warning about unused std::unique_ptr::release
We don't need the pointer, as it's the same as "this", we just don't
want the event to own the object anymore.

Nevertheless, silence code checker warning about the unused return.

Amends 96ef0004111b47cec239846b169942bbc885c181.

Pick-to: 6.9 6.8
Change-Id: I6a3c73e971f1b9e10f5754018a1fa5941dca6172
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-14 14:03:32 +02:00
Michael Weghorn
3dc73f701b client: Include <signal.h>
This fixes build errors like the following seen in a
local -no-pch clang 19 build:

    2/16] Building CXX object qtwayland/src/client/CMakeFiles/WaylandClient.dir/qwaylandprimaryselectionv1.cpp.o
    FAILED: qtwayland/src/client/CMakeFiles/WaylandClient.dir/qwaylandprimaryselectionv1.cpp.o
    /usr/bin/ccache /usr/bin/clang++ -DQT_ASCII_CAST_WARNINGS -DQT_BUILDING_QT -DQT_BUILD_WAYLANDCLIENT_LIB -DQT_CORE_LIB -DQT_DEPRECATED_WARNINGS -DQT_EXPLICIT_QFILE_CONSTRUCTION_FROM_PATH -DQT_GUI_LIB -DQT_MOC_COMPAT -DQT_NO_AS_CONST=1 -DQT_NO_CAST_TO_ASCII -DQT_NO_CONTEXTLESS_CONNECT=1 -DQT_NO_EXCEPTIONS -DQT_NO_FOREACH -DQT_NO_FOREACH=1 -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_QASCONST -DQT_NO_QEXCHANGE -DQT_NO_QSNPRINTF -DQT_NO_STD_FORMAT_SUPPORT -DQT_STRICT_QLIST_ITERATORS -DQT_USE_QSTRINGBUILDER -DQT_WAYLANDGLOBAL_LIB -DWaylandClient_EXPORTS -D_GLIBCXX_ASSERTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I/home/michi/development/git/qt5/qtwayland/src/client/WaylandClient_autogen/include -I/home/michi/development/git/qt5/qtbase/include -I/home/michi/development/git/qt5/qtbase/include/QtWaylandClient -I/home/michi/development/git/qt5/qtwayland/src/client -I/home/michi/development/git/qt5/qtwayland/src/client/../shared -I/home/michi/development/git/qt5/qtwayland/src/client/global -I/home/michi/development/git/qt5/qtwayland/src/client/hardwareintegration -I/home/michi/development/git/qt5/qtwayland/src/client/inputdeviceintegration -I/home/michi/development/git/qt5/qtwayland/src/client/shellintegration -I/home/michi/development/git/qt5/qtbase/include/QtWaylandClient/6.10.0 -I/home/michi/development/git/qt5/qtbase/include/QtWaylandClient/6.10.0/QtWaylandClient -I/home/michi/development/git/qt5/qtbase/include/QtCore -I/home/michi/development/git/qt5/qtbase/mkspecs/linux-clang -I/home/michi/development/git/qt5/qtbase/include/QtGui -I/home/michi/development/git/qt5/qtbase/src/corelib -I/home/michi/development/git/qt5/qtbase/include/QtCore/6.10.0 -I/home/michi/development/git/qt5/qtbase/include/QtCore/6.10.0/QtCore -I/home/michi/development/git/qt5/qtbase/src/gui -I/home/michi/development/git/qt5/qtbase/include/QtGui/6.10.0 -I/home/michi/development/git/qt5/qtbase/include/QtGui/6.10.0/QtGui -I/home/michi/development/git/qt5/qtbase/include/QtWaylandGlobal -I/home/michi/development/git/qt5/qtwayland/src -I/home/michi/development/git/qt5/qtbase/include/QtWaylandGlobal/6.10.0 -I/home/michi/development/git/qt5/qtbase/include/QtWaylandGlobal/6.10.0/QtWaylandGlobal -D_GLIBCXX_DEBUG -g -std=gnu++17 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -fPIC -Werror "-Wno-error=#warnings" -Wno-error=deprecated-declarations -Wno-error=deprecated-enum-enum-conversion -Wno-error=deprecated-copy-with-user-provided-copy -Wno-error=unused-but-set-variable -fcf-protection=full -ftrivial-auto-var-init=pattern -fstack-protector-strong -fno-exceptions -MD -MT qtwayland/src/client/CMakeFiles/WaylandClient.dir/qwaylandprimaryselectionv1.cpp.o -MF qtwayland/src/client/CMakeFiles/WaylandClient.dir/qwaylandprimaryselectionv1.cpp.o.d -o qtwayland/src/client/CMakeFiles/WaylandClient.dir/qwaylandprimaryselectionv1.cpp.o -c /home/michi/development/git/qt5/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
    /home/michi/development/git/qt5/qtwayland/src/client/qwaylandprimaryselectionv1.cpp:121:26: error: variable has incomplete type 'struct sigaction'
      121 |         struct sigaction action, oldAction;
          |                          ^
    /home/michi/development/git/qt5/qtwayland/src/client/qwaylandprimaryselectionv1.cpp:121:16: note: forward declaration of 'sigaction'
      121 |         struct sigaction action, oldAction;
          |                ^
    /home/michi/development/git/qt5/qtwayland/src/client/qwaylandprimaryselectionv1.cpp:121:34: error: variable has incomplete type 'struct sigaction'
      121 |         struct sigaction action, oldAction;
          |                                  ^
    /home/michi/development/git/qt5/qtwayland/src/client/qwaylandprimaryselectionv1.cpp:121:16: note: forward declaration of 'sigaction'
      121 |         struct sigaction action, oldAction;
          |                ^
    /home/michi/development/git/qt5/qtwayland/src/client/qwaylandprimaryselectionv1.cpp:122:29: error: use of undeclared identifier 'SIG_IGN'
      122 |         action.sa_handler = SIG_IGN;
          |                             ^
    /home/michi/development/git/qt5/qtwayland/src/client/qwaylandprimaryselectionv1.cpp:126:19: error: use of undeclared identifier 'SIGPIPE'
      126 |         sigaction(SIGPIPE, &action, &oldAction);
          |                   ^
    /home/michi/development/git/qt5/qtwayland/src/client/qwaylandprimaryselectionv1.cpp:127:26: error: use of undeclared identifier 'write'; did you mean '_IO_cookie_io_functions_t::write'?
      127 |         ssize_t unused = write(fd, content.constData(), size_t(content.size()));
          |                          ^~~~~
          |                          _IO_cookie_io_functions_t::write
    /usr/include/x86_64-linux-gnu/bits/types/cookie_io_functions_t.h:58:28: note: '_IO_cookie_io_functions_t::write' declared here
       58 |   cookie_write_function_t *write;       /* Write bytes.  */
          |                            ^
    /home/michi/development/git/qt5/qtwayland/src/client/qwaylandprimaryselectionv1.cpp:127:26: error: invalid use of non-static data member 'write'
      127 |         ssize_t unused = write(fd, content.constData(), size_t(content.size()));
          |                          ^~~~~
    /home/michi/development/git/qt5/qtwayland/src/client/qwaylandprimaryselectionv1.cpp:129:19: error: use of undeclared identifier 'SIGPIPE'
      129 |         sigaction(SIGPIPE, &oldAction, nullptr);
          |                   ^
    /home/michi/development/git/qt5/qtwayland/src/client/qwaylandprimaryselectionv1.cpp:131:5: error: use of undeclared identifier 'close'
      131 |     close(fd);
          |     ^
    8 errors generated.
    ninja: build stopped: subcommand failed.

Change-Id: Iee791fa5bc83184a597e95ae6424f42bfe2efd25
Reviewed-by: David Redondo <qt@david-redondo.de>
2025-04-14 10:43:52 +02:00
Karim Pinter
fd73b22089 Fix VxWorks POSIX access() behavior
On VxWorks POSIX access() returns always false if it is called on file
which is not on POSIX file system, like DOSFS for example. Qt for
VxWorks 5.15 had similar patch omitting all access() calls and returning
true. This fix takes it a step further and checks if the file is on
POSIX filesystem or if it is DOSFS with read-only setting or not,
in case omitting access() call and returning true. Failure became
visible using QTranslator::load() method on DOSFS mmc card.

Task-number: QTBUG-134627
Pick-to: 6.8 6.9
Change-Id: I9c257d3cba1a2b976f2775ad129aae0e09f68ffd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-14 09:38:59 +03:00
Ahmad Samir
ce38df4461 Use QByteArray overloads of QString::from{Utf8,Latin1}
Fixes the build with QT_NO_CAST_FROM_BYTEARRAY.

Pick-to: 6.9 6.8 6.5
Change-Id: I7d26235cbb9d26dc4b6d12a68a5ae494574b82a2
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-04-13 16:48:29 +00:00
Ahmad Samir
f7db58335b QInternalMimeData: avoid a QString redundant allocation
By using QStringView.

Drive-by, explicitly use QBA::constData() to fix the build with
QT_NO_CAST_FROM_BYTEARRAY.

Pick-to: 6.9 6.5
Change-Id: I57bcd877048f3b9889ab8d638979f893857af396
Reviewed-by: David Faure <david.faure@kdab.com>
2025-04-13 15:17:31 +02:00
Aurélien Brooke
10d7de1f5c QVarLengthArray: call sizedFree() with the capacity and not the size
Using the size accidentally worked since most of the time Qt adds
elements one by one to QVLAs.

Amends 03d5daf9437d8b46db2e89e3a9763ea701fa681c.

Change-Id: I9ee6500b758f2ebf6dcc5ae8e898d3241f10af41
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2025-04-12 20:34:49 +02:00
Christian Ehrlicher
0b668c2f55 tst_qgraphicslinearlayout: avoid duplicate data tags in removeAt()
Avoid the duplicated data tags in removeAt() tests by adding the
orientation to the tag.

Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-135294
Change-Id: If31d719e4a9b1c90e591cedc149848bbb9c99657
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-12 16:45:49 +02:00
Johannes Grunenberg
0a281beaa7 Ensure Qt builds with -no-feature-shortcut on Windows
Building without shortcuts would fail due to a missing QKeySequence.
This was already handled in the implementation but required an ifdef in
the header.

Change-Id: I12c92ca480d0abdb518aae00b5b7e259133ef9ca
Pick-to: 6.5 6.8 6.9
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2025-04-12 14:25:00 +01:00
Zhao Yuhang
a0484f629c core: don't export unnecessary symbol in static build
User binary has this export when Qt is build statically,
we should only export it in shared Qt builds.

Change-Id: Iaa08e2a668bee6f094a49f20a0033c5eecdc1cbc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-12 12:10:01 +00:00
David Faure
687422abde QItemSelectionModel: document danger with setData from selectionChanged
Got two independent bug reports where people got hit by that and had
to do a long and difficult debugging session to find out what was
happening (and still thought it was a Qt bug).

Fixes: QTBUG-54484
Fixes: QTBUG-50821
Pick-to: 6.9
Change-Id: I0041fccebbb7070fccf8014288c62d89f117ae7d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-12 08:23:20 +00:00
Thiago Macieira
eb8c09c104 QThreadStorage: make the internal finish() function really private
This class is very old and hasn't been modernized since C++98 became a
thing we could rely on. We hadn't come up with the concept of private
headers yet.

This commit moves the exported QThreadStorageData::finish() function
from the public header to QThreadStoragePrivate in a private header and
no longer exports it. It also removes the need to pass the QList as a
void **.

Task-number: QTBUG-135044
Change-Id: I736cb12a7c29716effd7fffd87c7b086a8cb7e19
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-11 17:09:49 -07:00
Thiago Macieira
81a7a4c2d9 QThreadStorage: ensure global static exists when finish() is called
For the thread that calls ::exit() (usually, the main thread).
Otherwise, depending on construction order, it is possible for the
QThreadStorage's destructor list to have been destroyed by the time
destroy_current_thread_data() → QThreadData::finish() calls our
finish().

Fixes: QTBUG-135044
Pick-to: 6.9 6.8
Change-Id: Ic5a10367ff31e7faa039fffdc2067eba9642fbf9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-04-11 17:09:49 -07:00
Mauro Persano
7dc2532bed Determine screen with initialGeometry when not positioning automatically
Popups aren't automatically positioned, so use the screen at the initial
geometry for scaling. Otherwise we may end up with the wrong geometry on
systems that have multiple screens with different scales.

Pick-to: 6.9 6.8
Fixes: QTBUG-134139
Change-Id: I686b1c8ab6cf458d9b849b529ba247ac8c3be064
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-04-11 20:11:57 -03:00
Volker Hilsheimer
7af5912e61 qgraphicsitem_cast: replace runtime with compile-time check
Specialize the cast template for QGraphicsItem, where we can skip the
runtime comparisons of the type.

In addition, replace the runtime check for QGraphicsItem::Type with a
compile time check in the main template.

We need to do both so that we correctly cast up to QGraphicsItem for
custom item types that don't provide their own Type alias.

Pick-to: 6.9 6.8
Change-Id: Ic1bff3404fe890747865ce1349cddbcfebb3b77b
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-11 21:19:51 +00:00
Volker Hilsheimer
b8de5ad1ed QThread: explicitly clear posted events during destruction
So far, we have been destroying pending posted events during thread
shutdown only as part of ~QThreadData. QThreadData is reference counted,
and ~QThreadPrivate releases the reference count.

However, any QObject living in a thread also holds a reference to the
QThreadData. If any of those objects are only destroyed when a posted
event is processed, then we have a cyclic reference problem.

This might be a problem with DeferredDelete events that are posted after
a QThread has exited its event loop. It does manifest as a problem with
QSingleShotTimer, which is temporarily owned by a posted event object.
As long as that event object is in the queue, the reference count of
QThreadData never drops to zero as the QSST instance holds a reference.
So the event never gets destroyed, and we end up leaking both.

To fix this, explicitly clear all pending posted events during QThread
destruction as well, not only during QThreadData destruction. Once the
QThread is destroyed, nothing will process those events. We still clear
the posted events during QThreadData destruction, as QThreadData might
get destroyed when other objects release their reference count on it.

This fixes a somewhat contrived problem in our test scenario, and the
change is not without risk, so not cherry-picking this to any stable
branch.

Change-Id: I488c1d3137ce83f1c34596e1041c22759825be18
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-11 22:24:06 +02:00
Volker Hilsheimer
96ef000411 QTimer: delete pending single shot timers when receiver's thread dies
QSingleShotTimer instances are usually destroyed when they receive their
QTimerEvent, and otherwise are children of the creating thread's event
dispatcher so that they do get destroyed even if they never fired.

However, if the receiver object lives in a different thread than the
thread that started the timer, then we move the QSST instance to
that thread to make sure that it starts in the right thread. We then
reparented the QSST instance to nullptr (it can't continue to be a
child of the creating thread's event dispatcher), and connected to
QApp::aboutToQuit as a fall-back in case the timer never fires.

This has two problems: if the timer never fires (e.g. because the
receiver's thread stopped before the timeout), then we created a
soft leak (until aboutToQuit). And since the QSST instance was
moved to the receiver's thread, the connection to aboutToQuit()
is always queued, and also never got processed if the thread was
stopped before (especially since we connected to deleteLater(),
which would require another event processing cycle). So in
practice, we ended up with a hard leak.

To fix this, we have to reparent the QSST instance to the event
dispatcher of the receiver's thread. We can do that reliably
once the receiver thread processes events. Simplify the code to
replace a meta-call with a posted event to ourselves, receiving
which starts the timer (or immediately fires timeout if it has
taken long enough to get there). To avoid memory leaks in the
unlikely case that this posted event never gets delivered (e.g.
because the thread is shutting down already), give that event
ownership of the QSST instance until the timer is started.

This turns out to be leaking anyway on most platforms, which
requires further investigation.

To be able to reparent safely away from a parent in a different
thread, clear the sendChildEvents flag first.

Amends 87535e4e4337596066258e361143cb9906e89512.

Fixes: QTBUG-135636
Pick-to: 6.9 6.8
Change-Id: I8188160d54cfb63cb1765c5de8a6c0728dabb7e5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-11 22:24:06 +02:00
Marc Mutz
1fa31be7ce tst_QMetaObject: check a few functions with QVector instead of QList
QVector instead of QList is currently still treated specially, being
considered normalized even if a signature piped through
normalizeSignature() would have changed.

We'd like to get rid of this special treatment, so add some tests for
invokeMethod() + Q_ARG, which we should continue to support.

Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-135572
Change-Id: Ie09c80d2a8603a268859f395797196013efd8c0f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-04-11 21:00:00 +02:00
Marc Mutz
a481a79a97 QMetaObject: don't use QMetaType::fromName() in typeFromTypeInfo()
The former will try to normalize the type name, but everything stored
in a QMetaObject is already in normalized form. So, if the first
lookup fails, the normalized one won't succeed either.

Use qMetaTypeTypeInternal(), which doesn't normalize.

At a minimum, this will fail faster. If we're lucky, the missing
round-trip via QMetaType(int).id() will help the positive case, too.
But if it does, it's lost in the statistical noise of the benchmark.

IOW: no measurable performance impact.

Pick-to: 6.9
Task-number: QTBUG-135572
Change-Id: I23834c201fbcd1780c50e85cf8a15ea5e4a94c74
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2025-04-11 20:59:59 +02:00
Marc Mutz
cac63042b1 Port qMetaTypeTypeInternal() from const char* to QByteArrayView
The only caller of the function, QArgumentType, passes
QByteArray::constData() to it, and the function then goes around and
performs a strlen() in order to feed it into qMetaTypeTypeInternal().

Pass the name as a QByteArrayView, to save the strlen() over a string
we already knew the length of.

No measurable performance impact.

Pick-to: 6.9
Task-number: QTBUG-135572
Change-Id: Ifccea7644ce86308df5fb7063c0269a579785504
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2025-04-11 20:59:59 +02:00
Marc Mutz
1445a33b6f QMetaObject: save a strlen() in typeFromTypeInfo()
QMetaType::fromName() takes a QBAV, so don't feed it rawStringData()
(a const char*, causing the QBAV ctor to run strlen() on it), but
stringDataView() (a QBAV already, whose length is determined by offset
difference in the string offset table and not by strlen()).

No measurable difference in runtime speed.

Pick-to: 6.9 6.8 6.5
Change-Id: I583bea9d818deeaac6f62803f7ac5ab4766cb8a5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-11 20:59:59 +02:00
Marc Mutz
5d2164382c QEventStorage: fix comment about slicing
QEventStorage<E> will slice if you call store(e) where typeid(e) !=
typeid(E). But if they are the same, no slicing occurs.

So change the code comment from "always slices" to "may slice".

Amends dd264cc9c00e09eb995f1c6f9b1fd651f1d4b2f4.

Pick-to: 6.9
Task-number: QTBUG-99563
Task-number: QTBUG-133321
Change-Id: Ic69d2d3e6b5491c2d3e61d8da131f4bda628fe95
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-04-11 20:59:59 +02:00
Morten Sørvig
df0885dc6a wasm: remove stray qDebug()
Change-Id: Ieddd4b6a0e948c65679cc66ba1f4ea22c9ec5fc5
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
2025-04-11 20:09:23 +02:00
Morten Sørvig
0f5690c5a2 wasm: port rest of input context event handlers
Follow-up to 13e92283, change the clipboard event handlers
to use QWasmEventHandler as well.

The removed addEventListener calls set capturing to false,
but this is already the default (also for QWasmEventHandler),

Change-Id: Ibecaa22099fecd371a5d243cf391d3ce6f562400
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
2025-04-11 20:09:23 +02:00
Even Oscar Andersen
a4aac362cf wasm: a11y - synchronize focus between Qt and a11y
Listen for "focus" javascript events..
Listen for QAccessible::Focus a11y events.

When receiving QAccessible::PopupMenuStart set
focus to first item.

Task-number: QTBUG-135096
Change-Id: I676e53e77169cc1643765210318b460193042c53
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-04-11 19:18:36 +02:00
Frédéric Lefebvre
5ced648feb tst_QSizeGrip::hideAndShowOnWindowStateChange is flaky on Ubuntu
tst_QSizeGrip::hideAndShowOnWindowStateChange is flaky on Ubuntu where
the widget is not set to fullscreen when it should. Wait for the the
widget to be exposed when shown the first time.

Fix flakiness on Ubuntu 24.04

Pick-to: 6.9 6.8 6.5
Change-Id: I9f5ea9ebb58c7505f841e5420dd2c15e5f0f2799
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-11 15:43:43 +00:00
Robert Löhning
d1b88f8b73 Return early if qt_mapFillRect will return empty QRect
Credit to OSS-Fuzz, this fixes issue 406541912. When rendering the svg
image from that report, an integer overflow happend while calculating a
QRect which is empty anyway. To avoid that, return an empty, default
constructed QRect instead of calculating further.

Picking back to 6.5 which is the oldest maintained version which
contains this function.

Pick-to: 6.9 6.8 6.5
Change-Id: I1a0d1310c55f7be613a6292f36481ac7c7e5b56f
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-04-11 16:02:25 +02:00
Edward Welbourne
53ad78a636 Clean up "Qt Standard Time" tests
These were using an offset of 123456 seconds = UTC+34:17:36, which is
outside our supported range. This wasn't actually causing a problem,
as it wasn't being checked, but we should stay within 16 hours of UTC.
In the process, modernize the use of strings involved in its tests and
change an initial value to something further from what shall overwrite
it, rather than a neutral value.

Pick-to: 6.9 6.8
Change-Id: Ife4e082f1f00665d3203641508f5d30b34aaae75
Reviewed-by: Magdalena Stojek <magdalena.stojek@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-04-11 15:01:29 +02:00
Edward Welbourne
fc9a26ea3a Include "is known to ICU" check in QTimeZonePrivate::localeName()
As long noted in the QIcuTimeZonePrivate constructor, we can't trust
ucal_open()'s non-null return to mean it actually recognised the ID we
passed it. So break out the "is available" check to a function in the
QtTimeZoneLocale namespace so the check can be shared with
localeName() when compiled with ICU but some other backend. We were
previously getting GMT as display name for zones unknown to ICU.

Pick-to: 6.9 6.8
Change-Id: I57d57f94d8db7df76f24193a8ef1b5c71b08b0fc
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-04-11 15:01:29 +02:00
Vlad Zahorodnii
fa1fab994e dbusmenu: Skip registration with the registrar on Wayland
The RegisterWindow request expects a window id. The QDBusMenuBar uses
the QWindow::winId() property for that. On X11, the winId() returns
the XID of the window. On Wayland, the winId() returns an integer that
has meaning only to the application, there are no global window ids on
Wayland. The menubar should be registered using other means, for
example using the kde-appmenu protocol, which QtWayland already does.

The QDBusMenuBar can skip synchronously calling the RegisterWindow
request on Wayland because the menu will be registered using a different
api.

Pick-to: 6.9
Change-Id: I6b2968624c5c9ddbdc93807f65eac369dc7a993a
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-04-11 14:54:31 +03:00
Aurélien Brooke
d0df02ad8a qalloc: keep the original capacity if realloc() fails
As a drive-by, fix the copyright headers.

Amends 03d5daf9437d8b46db2e89e3a9763ea701fa681c.

Change-Id: Ie27ecb62097e9bcb33cc0ceb10c97743bce0b0e0
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-11 13:54:31 +02:00
Topi Reinio
39358791f0 Doc: Fix \fn signatures for QFlags equality operators
These are hidden members, and visible under the QFlags class in the
Clang AST - even though semantically they belong to the parent (global)
scope.

Adjust the \fn signatures accordingly and remove the \relates commands
as unnecessary; QDoc recognizes the `friend` qualifier and marks the
functions as related non-members of QFlags automatically.

Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-133923
Change-Id: Iaca74971bde8b313c573e75688bf57d3ff42b59d
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-11 11:54:31 +00:00
Marc Mutz
8e98a3a826 QMetaObject: fix performance regression in methodMatch()
Amends 22ce92f8040183faf9e1ba53c59c6b0b9172fb26, which apparently
changed the method name stored in the moc data from unqualified to a
qualified name. The original commit message doesn't mention it, but
the change in QMetaMethodPrivate::name() suggests as much.

Unfortunately, the search for the colon causes the name() call to
increase to 25% of the total methodMatch() runtime, up from 6.85%
before the change.

Since name() now always strips a possible prefix, re-add the original
name() as qualifiedName() and use that in methodMatch().

This is faster because we don't need to perform an a-priori search for
colons; instead, we can first check for endsWith(), and only if we
have a match, can we a-posteriori check that the match was preceded by
an (optional) colon.

Results on my machine:

  ********* Start testing of tst_QObject *********
  Config: Using QtTest library 6.10.0, Qt 6.10.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by Clang 15.0.3 (github.com:llvm/llvm-project.git 48b23aa469b8cfdb6cde1c55bf3361cabcdef6bc)), ubuntu 20.04
  PASS   : tst_QObject::initTestCase()
  PASS   : tst_QObject::connect_disconnect_benchmark(normalized signature)
  RESULT : tst_QObject::connect_disconnect_benchmark():"normalized signature":
  -    923.542494 nsecs per iteration (total: 461,771,247, iterations: 500000)
  +    880.558792 nsecs per iteration (total: 440,279,396, iterations: 500000)
  -    4,340.832532 CPU cycles per iteration, 4,7 GHz (total: 2,170,416,266, iterations: 500000)
  +    4,093.487614 CPU cycles per iteration, 4,65 GHz (total: 2,046,743,807, iterations: 500000)
  -    13,706.07561 instructions per iteration, 3,157 instr/cycle (total: 6,853,037,807, iterations: 500000)
  +    12,779.02463 instructions per iteration, 3,122 instr/cycle (total: 6,389,512,318, iterations: 500000)
  -    2,201.185595 branch instructions per iteration, 2,38 G/sec (total: 1,100,592,798, iterations: 500000)
  +    2,208.176500 branch instructions per iteration, 2,51 G/sec (total: 1,104,088,250, iterations: 500000)

For a ~5% overall speedup in both ns/iter and instr/iter, keeping in
mind that this data contains the disconnect() call, too.

As a drive-by, remove a second call of QMetaObjectPrivate::get() on the
same object, and reuse the previous call's result.

Pick-to: 6.9
Task-number: QTBUG-135572
Change-Id: Ide253b323e7b826f8fa09d2f5f57496861c12f75
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-04-11 10:13:39 +00:00
Juha Vuolle
cb48788425 Make autotests compile without draganddrop feature
Disable tst_qdrag test itself, and put proper feature
guards in tst_event test.

Fixes: QTBUG-135806
Pick-to: 6.9 6.8
Change-Id: I80e41538488ba1df230551a97f18c8266c01bdb5
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2025-04-11 09:21:04 +03:00
Juha Vuolle
8b5232f4c8 Put emojisegmenter logging category behind feature-flag
To suppress
qtextengine.cpp:30:27: warning: unused function 'lcEmojiSegmenter'
when Qt is configured with -no-feature-emojisegmenter.

Amends: 41199de2d8bb9626e6569a6734ec805f56a5541d

Change-Id: I3c31f7ee3441bc4734bf166304ad6b709fce09c1
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-04-11 09:21:01 +03:00
Thiago Macieira
7cf49085eb QMetaType/QVariant: update docs that canConvert() operates on types
Not on values. That is, it indicates whether there is a conversion path
from origin type to the destination type, not that the conversion will
succeed when attempted. For example:

  QObject *o = new QAbstractItemModel;
  QVariant variant = QVariant::fromValue(o);
  qDebug() << variant.canConvert<QAbstractItemModel*>();

This conversion *will* succeed for this particular value of a QObject*,
so canConvert() must return true for conversions between QObject* and
QAbstractItemModel*, despite not all such conversions being possible.

This is also done in preparation of changes being done to the conversion
routines that may cause some FP->integer conversions to fail depending
on the value of the FP.

Fixes: QTBUG-135619
Task-number: QTBUG-135285
Pick-to: 6.8 6.9
Change-Id: I138e34fb61a8b8772c8bfffdf75787a2e007d847
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
2025-04-10 19:26:04 -07:00
Thiago Macieira
9ffbeae50e tst_Q*Application: suppress warning about using read() with MSVC
MSVC is pedantic that read() (a POSIX function) is not an ISO C function
so insists that we use the underscored version. As if Microsoft followed
that rule for their own APIs...

Amends e6a6757c1485d09a4b7a124d67260f06d8022fef.

Pick-to: 6.9 6.8
Change-Id: If51fd8564a3c415e1f7efffd7fde18a830c97e3b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-04-10 19:26:03 -07:00
Edward Welbourne
1fc5f5b088 Replace a semicolon with {} as loop body
It's what our coding style says we should use, and I'd been confused
because I didn't initially spot that semicolon.

Change-Id: I0eadc53e176776fe6aac8568709aa7b995a10ac9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-04-11 04:26:03 +02:00
Edward Welbourne
2ea404f34c tst_QTextStream: trust QtTest to know how to compare QByteArray
Just comparing the constData() of two QBAs fails to check the sizes
match, and only compares up to the first '\0' byte; but QCOMPARE()
will also check size and checks all bytes. It's also perfectly capable
of comparing a QBAV to a C string literal (by turning the latter into
a QBAV), so save some allocations by doing that. Some tests were
overtly comparing both size() and constData(), but of course the
latter still only compared up to the first '\0' byte, still. So also
replace such pairs with a straight QGA comparison.

One test genuinely used a constData() comparison because it was
testing streaming of the constData(), so hadn't streamed size info and
thus wasn't reading it back again. Record that this is why that one
remains testing constData(), to save future readers wondering.

At the same time, test a QBuffer's (read-only) .data() in preference
to its (mutable) .buffer(), so it's clear (because we use the latter)
when we actually need mutating access to the raw data. (One test does,
with .buffer().clear(), indeed do that.)

Change-Id: I2b565469456bde9c003894abc8128ec5bc38a370
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-11 04:26:03 +02:00
Thiago Macieira
b9faf83fd6 QTextStream: finish porting to qsizetype
Done-With: Eddy <edward.welbourne@qt.io>
Change-Id: I5f7f427ded124479baa6fffd175fc41c3f881349
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-11 04:26:03 +02:00
Edward Welbourne
908b814fcd Convert QTextStream internals to char16_t QChar::unicode()
Pick-to: 6.9 6.8
Change-Id: If11457fbc472b2bc2ff7b76f4456fc87dd0014e5
Reviewed-by: Rym Bouabid <rym.bouabid@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-11 04:26:03 +02:00
Edward Welbourne
a9e2f5d0dc Port QTEXTSTREAM_DEBUG to modern QFlags
Its code was just casting to int, which no longer compiles.
Call toInt() on the fiag first.

Pick-to: 6.9 6.8 6.5
Change-Id: I74971f37841b44879cffdb480a173561798f8fa7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-11 04:26:03 +02:00
Thiago Macieira
e0cdcf66ca QLoggingRegistry: remove use of QDir and merge two strings
We don't need to apply QDir::absolutePath() on the diretory that
QLibraryInfo::path() returns, because that is already an absolute path
(and if it weren't, it wouldn't make a difference anyway). That means we
are only doing path concatenation here. For code this low-level, it's
better to stick to QString.

This commit also rejiggles the string variables so we avoid one of the
memory allocations when calling QStandardPaths.

Pick-to: 6.9
Change-Id: Ic3405877155a15ac4ac6fffdc92463ae0bff0bd9
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-04-10 19:26:03 -07:00
Thiago Macieira
653c73a83c QLoggingRegistry: mark that qtLoggingDebug() is unlikely to be true
Just to nudge the compilers in the right way of optimizing.

Change-Id: I3cf0c3541326c0aec113fffd96a75d3b18f8162d
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-04-10 19:26:02 -07:00
Giuseppe D'Angelo
5e1a178732 Include <QTest>, not <QtTest>
Avoid module-wide inclusions for QtTest. The transitive inclusions
eat a considerable amount of compilation time.

Task-number: QTQAINFRA-7110
Pick-to: 6.9 6.8
Change-Id: Ic1c93b40b638ea5bff739be212f173457bae26aa
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-10 22:52:47 +02:00
Marc Mutz
f2747c62d4 QMetaObjectPrivate: make decodeMethodSignature() return QByteArrayView
... instead of QByteArray.

This is part of a quest to improve string-based connect() performance.

Needed to port a few consumers of decodeMethodSignature()'s result
from QByteArray to QByteArrayView, too. All private API, so doesn't
affect users.

This doesn't change anything in tst_bench_qobject's
connect_disconnect_benchmark:normalized signature, yet.

Task-nunber: QTBUG-135572
Pick-to: 6.9
Change-Id: I1cd5b410ee090ab9c6f3aa8095a4d9efae516ac0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-04-10 18:47:36 +02:00
Marc Mutz
21c9aac20a QDockWidgetLayout: mark the ctor explicit
A QWidget* is not a faithful representation of a QDockWidgetLayout, so
the ctor should be explicit, even if this is but a private class.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Ib69d72540f094542dbcfc0684e2eec5f90aa532a
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-04-10 18:47:21 +02:00
Marc Mutz
2e3d39130c QMdiSubwindow: fix UB (invalid member call) in ControlContainer::removeButtonsFromMenuBar()
The function can be called from ~QMdiSubwindow(), and we checked for
QWidgetPrivate::data.in_destructor before proceeding with the removal
of buttons from the menubar, but we called
QPointer<QMdiSubwindow>::data()->window(), which, at this point in
time, had already been demoted to a QWidget:

Says UBSan:

  qpointer.h:75:14: runtime error: downcast of address 0x6040000aca10 which does not point to an object of type 'QMdiSubWindow'
   0x6040000aca10: note: object is of type 'QWidget'
    00 00 00 00  28 01 99 bc ff 7e 00 00  80 dc 0f 00 90 61 00 00  d8 02 99 bc ff 7e 00 00  00 00 be be
                 ^~~~~~~~~~~~~~~~~~~~~~~
                 vptr for 'QWidget'
       #0 0x7effb955f95a in QPointer<QMdiSubWindow>::data() const qpointer.h:75
       #1 0x7effb955f95a in QPointer<QMdiSubWindow>::operator->() const qpointer.h:79
       #2 0x7effb955f95a in QMdi::ControlContainer::removeButtonsFromMenuBar(QMenuBar*) qmdisubwindow.cpp:795
       #3 0x7effb9563031 in QMdi::ControlContainer::~ControlContainer() qmdisubwindow.cpp:717
       #4 0x7effb9566595 in QMdi::ControlContainer::~ControlContainer() qmdisubwindow.cpp:723
       #5 0x7eff8f4f2b7a in QObjectPrivate::deleteChildren() qobject.cpp:2226
       #6 0x7effb7bf732d in QWidget::~QWidget() qwidget.cpp:1557
       #7 0x7effb95cc02c in QMdiSubWindow::~QMdiSubWindow() qmdisubwindow.cpp:2254
       #8 0x7effb95cc1d5 in QMdiSubWindow::~QMdiSubWindow() qmdisubwindow.cpp:2254
       #9 0x7eff8f4f2b7a in QObjectPrivate::deleteChildren() qobject.cpp:2226
       #10 0x7effb7bf732d in QWidget::~QWidget() qwidget.cpp:1557
       #11 0x7effb7bffba5 in QWidget::~QWidget() qwidget.cpp:1584
       #12 0x7eff8f4f2b7a in QObjectPrivate::deleteChildren() qobject.cpp:2226
       #13 0x7effb7bf732d in QWidget::~QWidget() qwidget.cpp:1557
       #14 0x7effb85f0dc5 in QFrame::~QFrame() qframe.cpp:235
       #15 0x7effb859c747 in QAbstractScrollArea::~QAbstractScrollArea() qabstractscrollarea.cpp:478
       #16 0x7effb93c08a6 in QMdiArea::~QMdiArea() qmdiarea.cpp:1703
       #17 0x7effb93c0e55 in QMdiArea::~QMdiArea() qmdiarea.cpp:1703
       #18 0x7eff8f4f2b7a in QObjectPrivate::deleteChildren() qobject.cpp:2226
       #19 0x7effb7bf732d in QWidget::~QWidget() qwidget.cpp:1557
       #20 0x7effb920a425 in QMainWindow::~QMainWindow() qmainwindow.cpp:338

Fix by deleting the ControlContainer already from ~QMdiSubwindow(),
ie. when we have not yet been demoted to QWidget.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Ia43c857bc1842b2b4957cc79e00f790b045d8f94
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-04-10 18:47:03 +02:00
Marc Mutz
01ced9d45a syncqt.cpp: don't init static variables with non-static data
Static variables are only initialized once, when control passes over
their definition for the first time¹. If they are initialized with
non-static data, like the contents of a non-static data member, or the
address of one, then all following uses of the object will continue to
use the first control pass' data, even if the data members were from
an object that has since been deleted.

This whole construct appears to have worked merely because these
functions are only executed once, or at least not on different
objects. But better remove the dangerous construct while it hasn't
broken something, yet, and before we e.g. make syncqt a library² or
add a mode that makes it scan multiple modules at once.

Requires to capture more variables in the parseArgument() lambda; more
than fits into an explicit capture list, so use a [&] catch-all
instead.

As a drive-by, use CTAD to not have to mention the number of elements
in a std::array, but have the compiler deduce them, and add const,
where it's missing.

Amends b89d63515bb352cecfd87e709320a2db5b6a1906 (and maybe a few
in-between, we'll see when cherry-picking).

¹ Except corner-case like when initialization fails by throwing an
  exception.
² see similar ideas for moc, e.g.: QTBUG-132820

Pick-to: 6.9 6.8 6.5
Change-Id: I65a73059151e3d39341939f613080e6d833a4c30
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-04-10 18:46:01 +02:00
Axel Spoerl
4392e5f4c5 Blacklist tst_QGestureRecognizer::touchReplay() on Linux
Deeper research into recent failure necessary.
Blacklist to unblock CI.

Task-number: QTBUG-129754
Pick-to: 6.9 6.8 6.5
Change-Id: I1f543e35acdac7d91d48215a2130a03b77fd2ac5
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-04-10 16:18:35 +00:00
Axel Spoerl
d3dc9fdeaf QGestureManager::deliverEvents() - improve debug output
qDebug() why no target has been found for a gesture.
Correct wrong function names in debug output.
Use __FUNCTION__ macro instead of spelling function name out.
Adapt QTest::ignoreMessage() calls in tst_gestures.cpp to also use the
correct function name.

Task-number: QTBUG-129754
Change-Id: Ifabf512215934ee984bcb8c9d0c2463342d77c07
Reviewed-by: David Faure <david.faure@kdab.com>
2025-04-10 17:13:05 +02:00
Nodir Temirkhodjaev
c8d20da62a qnumeric.h: include what you use (QMinMax for qBound)
Fixes: QTBUG-135866
Change-Id: Idfa884dad04ed83660ebadd9f23ecc46ef3b14ed
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2025-04-10 18:10:01 +05:00
Aurélien Brooke
a8ae971a95 rhi: vulkan: be nicer when binding empty buffers
vkUpdateDescriptorSets(): pDescriptorWrites[1].pBufferInfo[0].range is
not VK_WHOLE_SIZE and is zero.
The Vulkan spec states: If range is not equal to VK_WHOLE_SIZE, range
must be greater than 0 (https://docs.vulkan.org/spec/latest/chapters/
descriptorsets.html#VUID-VkDescriptorBufferInfo-range-00341)

As a drive-by, fix the wrong union member access.

Change-Id: I511cddd25f91a117ff181fd64b77079e6946c94c
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-04-10 15:10:00 +02:00
Dheerendra Purohit
a95c568908 Doc: Update QTest documentation to reference Qt6Test
The QTest documentation incorrectly referenced
Qt5Test instead of Qt6Test. This has been updated
to reflect the correct module name.

Fixes outdated references in the documentation and
ensures consistency with Qt 6 naming conventions.

Fixes: QTBUG-134395
Change-Id: I254df83ecbea542c1a47b17aa0b756ed8a6f562a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-04-10 13:10:00 +00:00
Oliver Wolff
5ce44934b3 windeployqt: Deploy Qt dependencies of local non Qt dependencies
Before this patch we ignored every non Qt dependency we encountered
while scannig the binaries. That led to missing Qt dependencies for more
complex setups.

With this patch we also take "local non Qt dependencies" into
consideration. One example would be:
- A developer has a project that consists of an executable and a dll,
  where both are built/copied into the same folder before deployment
- The dll has different/additional Qt dependencies

The old approach just ignored these additional Qt dependencies.

The new approach checks for these local dependencies and finds the dll
in the same folder as the executable. In this case windeployqt will
now also scan this dll (and other local dlls) for Qt dependencies and
deploy these as well as their plugins.

[ChangeLog][Tools][Windeployqt] windeployqt now takes local non Qt
dependencies into consideration during deployment.

Fixes: QTBUG-135079
Pick-to: 6.8 6.9
Change-Id: Ia916dea78c6a5707ccecb61d996a0b7490215798
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-04-10 14:35:45 +02:00
Oliver Wolff
f017087214 windeployqt: Make "recursive plugin deployment" the default
5010eda5345bdbfc12e134d6fb3ae5b7370e2185 added a command line options
which made sure that plugins of dependent Qt modules were deployed. As
these plugins are mandatory for proper functionality of these modules,
this should be windeployqt's default. This change reflects this reality.
Deploy plugins of dependent Qt libraries by default.

The command line option was removed as opting out of this functionality
does not make sense

[ChangeLog][Tools][windeployqt] windeployqt now deploys plugins of all
dependent Qt modules by default. "--include-soft-plugins" became default
and the command line option was removed.

Change-Id: Ifc5e4d24803b0398c249461f14f2e58562477c80
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-04-10 12:35:45 +00:00
Jarek Kobus
2ab472f6cb TaskTree: Sync sources
Source sync Creator -> AssetDownloader.

Pick-to: 6.9 6.8
Change-Id: Ic503ba04c272718611a4a266bef40e73517e32fd
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-04-10 13:49:46 +02:00
Ivan Solovev
92c2ebdbcc qdbusxml2cpp: initialize the return value for adapters
If the interface has a method with a specified return value, the
generated adapter will contain a code like:

  bool out;
  QMetaObject::invokeMethod(parent(), "Func", Q_RETURN_ARG(bool, out));
  return out;

In this case Q_RETURN_ARG macro makes sure that the variable `out` is
properly initialized before being returned from a function, but only
if invokeMethod() call is executed successfully.

Update the generator to zero-initialize (or value-initialize) the
return variable, so that it returns some reasonable value even if
invokeMethod() fails.

Extend the unit-tests to make sure that the generated adapters always
initialize the return variables.

Coverity-Id: 479703
Pick-to: 6.9 6.8 6.5
Change-Id: I4d15ccc6844b5ca454ab9f0cf72fd8e3f0c1b704
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
2025-04-10 13:49:46 +02:00
Konsta Alajärvi
1e63707f96 Remove Blacklist entry for tst_QApplication::applicationPalettePolish()
tst_QApplication::applicationPalettePolish() is blacklisted but does
not seem to fail anymore.

Unblacklisting the function.

Fixes: QTQAINFRA-6906
Pick-to: 6.9 6.8
Change-Id: I14b8c4e8e1e94c3ff077f7d91ee8f97c031d5b6d
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
2025-04-10 11:49:46 +00:00
Matthias Rauter
4e3a167579 Exclude one more MSVC version in tst_qcheckedint and tst_qnumeric
I am using version 1943 and some section in the test that have been
marked as not working up until version 1942 are not working with 1943
either. I adjusted the respective sections to also exclude 1943.

Change-Id: I9f0ed1c1dba919d98772d45216f16857983978cd
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-04-10 13:22:47 +02:00
Matthias Rauter
eabbc15a5b Rename QtPrivate::Tok::size to tokenSize
Using MSVC 19.43 in C++20 mode leads to a compile error in
tst_qstringview. MSVC interprets QStringTokenizer as
std::ranges::sized_range because it found size() in the namespace
QtPrivate::Tok. QStringTokenizer is derived from a class in that
namespace.

Naturally this leads to a compile error because QStringTokenizer has no
size member function as required in QtPrivate::Tok::size():

qstringtokenizer.h(118): error C2039: 'size': is not a member of
    'QStringTokenizer<QStringView,QStringView>'
qstringtokenizer.h(232): note: see declaration of
    'QStringTokenizer<QStringView,QStringView>'
qstringtokenizer.h(118): note: the template instantiation context
    (the oldest one first) is
tst_qstringview.cpp(680): note: see reference to function template
    instantiation ...

The problem can be avoided by renaming QtPrivate::Tok::size() to
tokenSize. MSVC 19.43 interprets QStringTokenizer as std::ranges::range
that do not need the size() member function.

Pick-to: 6.9 6.8
Change-Id: Ib94db8e4d840a143bbf693c89e3714e1528a0267
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-10 13:22:47 +02:00
Thiago Macieira
8f89bbaf8e QReadWriteLock: add qYieldCpu() calls to the contended loop acquisitions
We're looping on fastTryLock() (which does testAndSetAcquire()) and a
few other testAndSet()s, so we should yield the CPU between
calls.

Change-Id: I6ba01efc9142f8be2bf1fffddf06c027dde18016
Reviewed-by: David Faure <david.faure@kdab.com>
2025-04-09 22:03:22 -07:00
Tor Arne Vestbø
64e3629cdf Silence AutoMoc for qplatformwindow_p.h on non-Wayland platforms
Wayland is the only platform that declares a native interface
that depends on QObject.

Amends 2acd0078598ed87a76b5ea66b042e8b096ac222f.

Change-Id: If625723e242f5cdb0b8972d90684eea7d86cfb14
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-04-10 06:24:15 +02:00
Thiago Macieira
ecfa7406f1 QXcbWindow: fix build: getpid() is <unistd.h>
Pick-to: 6.9
Change-Id: I3494ac2ce660faa49b72fffdc3b9fbb13df0372d
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2025-04-09 19:54:09 -07:00
Oliver Eftevaag
ef7e5ea616 Fix -no-feature-draganddrop builds
Building tests will still cause build issues, but at least this lets you
build without them.

Change-Id: Iea5c93bf31593a5ee0f66c877da4d5a7ba9b6dc3
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2025-04-10 03:27:00 +02:00
David Faure
253f34082f QPointer: fix data race on ExternalRefCountData
The creation of the ExternalRefCountData was published with
testAndSetOrdered() but the loadRelaxed() would only load the pointer
value, not the effects of the constructor.

Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-135640
Change-Id: I3acbc51e763e8a291be3f7036e0d9cd3965a2ce8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2025-04-10 03:27:00 +02:00
David Faure
22d4f117bd QReadWriteLock: extract method fastTryLock
This removes a little bit of duplication, and reduces the temptation to
remove the first part of tryLockForX as duplicated (it should remain
there for performance reasons).

Change-Id: I7ce102ceeb03b5ab4fe026b56fbba245b4c2f310
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-10 02:25:20 +02:00
David Redondo
677ee0cf7c QGnomeTheme: Prevent leak of QDBusPendingCallWatcher
Otherwise the watcher can outlive the theme and the connected lambda
calls into the already destroyed theme.

Change-Id: I55e7834d1eb806d9f5f1945a4e1016d14b2969b6
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-10 00:55:58 +02:00
Alexandru Croitor
ab7eb492cb CMake: Show the active Apple SDK path when configuring qtbase
Starting with CMake 4.0, CMake doesn't initialize the
CMAKE_OSX_SYSROOT variable with any value when running on a macOS
host and no explicit CMAKE_OSX_SYSROOT or CMAKE_SYSTEM_NAME is set.

CMake expects the platform compiler wrapper /usr/bin/c++ to pass an
appropriate -isysroot flag to the underlying compiler, without CMake
explicitly setting one.

This mostly works, but the configure output will not show anymore the
active sysroot path.

Query the active path from xcrun, and display it in the configure
output.

Pick-to: 6.8 6.9
Task-number: QTBUG-135621
Change-Id: Ic9b9a43e25bb88bb83165dce52356c77ea8fffe1
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-09 19:24:43 +02:00
Alexandru Croitor
c0f0a275b3 CMake: Refactor _qt_internal_get_apple_sdk_version
Introduce two new functions _qt_internal_get_apple_xcrun_output
and _qt_internal_get_apple_sdk_name, to allow reusing them in the
future.

Make sure to set the output variables to empty even
outside Apple platforms.

Show an error when xcrun is called when targeting a non-Apple
platform.

Pick-to: 6.8 6.9
Change-Id: Ic3895f74cfcac337bff069f8e6ec1517aec6c8d0
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-09 19:24:42 +02:00
Joerg Bornemann
87f4f0af6e CMake: Rework deployment of Qt plugins
[ChangeLog][CMake] qt6_import_plugins doesn't have any effect anymore on
plugin deployment with the CMake deployment API on Linux.

[ChangeLog][CMake] qt6_deploy_runtime_dependencies now supports the
following plugin selection flags on Linux: INCLUDE_PLUGINS,
INCLUDE_PLUGIN_TYPES, EXCLUDE_PLUGINS, EXCLUDE_PLUGIN_TYPES.

Before this patch, we were deploying the plugins of every Qt module we
discovered when walking the dependencies of the target to be deployed.

That doesn't work if the target links against a shared library that
privately links against another Qt module, i.e. QtMultimedia like in the
bug report.

We need to take into account the Qt modules that are discovered when
retrieving the runtime dependencies at deployment time and deploy their
plugins.

Also, we now run file(GET_RUNTIME_DEPENDENCIES) and plugin discovery in
multiple passes. Every pass might discover new Qt plugins whose runtime
dependencies must be resolved. We stop if a pass did not discover new
plugins or after a certain number of passes.

Plugin discovery works like this:
- identify the Qt modules within resolved libraries,
- read the plugin types for the module from the corresponding,
  module JSON file in Qt's installation,
- glob the files in Qt's plugins directory,
- select the files according to the plugin types from the Qt modules
  and the INCLUDE.../EXCLUDE... arguments passed by the user.

We also read the default QPA platforms from modules/Gui.json and deploy
those.

Fixes: QTBUG-117731
Change-Id: I62ec96ab6de8327941c4c5a0ba83fd89f1733768
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-09 19:02:07 +02:00
Joerg Bornemann
f2ac985d2f CMake: Add plugin-related arguments to qt_generate_deploy_app_script
[ChangeLog][CMake] Added arguments for selecting Qt plugins to
qt_generate_deploy_app_script.

Change-Id: Ib69dd4674bb85ac59abde2873d0e974c04444bb5
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-09 19:02:07 +02:00
Joerg Bornemann
6014820fe5 CMake: Add options to select / exclude plugins for deployment
[ChangeLog][CMake] Add the arguments INCLUDE_PLUGIN_TYPES,
EXCLUDE_PLUGIN_TYPES, INCLUDE_PLUGINS, and EXCLUDE_PLUGINS to
qt_deploy_runtime_dependencies.

The arguments are only supported on Windows with this patch.
A subsequent patch will add support on Linux.

The arguments are not supported on macOS.
The macdeployqt tool lacks these flags, unfortunately.

Change-Id: I4bacdbd6f15fcf2280d1c7cde051409b6557a008
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-04-09 19:02:07 +02:00
Joerg Bornemann
5766d74ee1 CMake: Add a way to turn off plugin deployment
[ChangeLog][CMake] Add the NO_PLUGINS argument to
qt_deploy_runtime_dependencies. This turns off plugin deployment
altogether.

For Linux, support for NO_PLUGINS is added in a subsequent patch.

Change-Id: Ie822a287f677fdc524ba5b884115e290ea288e67
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-09 19:02:07 +02:00
Christian Ehrlicher
696f9adaa4 Windows11Style: Fix size hint for RadioButton/Checkbox
When the radiobutton/checkbox has no text, the size is to small as the
check rect is enlarged by 2px due to the rounded borders. This is only
visible when they have no text as otherwise there is enough space
between the checkbox and the text.
Therefore add 2px in width when no text is available.

Pick-to: 6.9 6.8
Fixes: QTBUG-135628
Task-number: QTBUG-133117
Change-Id: I8e3342fdc980485ab1494ef7f6df044f42883619
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2025-04-09 15:45:44 +02:00
Tor Arne Vestbø
5dd41d5e30 iOS: Replace variable length array in QIOScreen with QVarLengthArray
Fixes: QTBUG-135609
Pick-to: 6.9 6.8
Change-Id: I3db252a4893ef298f6878fe2f3fac7c93fcf6c3a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-04-09 15:45:43 +02:00
Topi Reinio
8e36dcf4c8 Doc: Qt D-Bus: Add image alt texts
To increase accessibility for the documentation, provide altenative
descriptions for the images.

Pick-to: 6.9 6.8
Fixes: QTBUG-135116
Change-Id: Id2d97251af9af0d4222f0dc15aa5b8e266ca36f4
Reviewed-by: Safiyyah Moosa <safiyyah.moosa@qt.io>
Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
2025-04-09 13:15:35 +00:00
Ali Can Demiralp
351800ace2 Add nodiscard attribute to QtMiscUtils functions
Change-Id: I2039fcaafc478aaac45dce88b5d979a66a2f2424
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-09 15:15:35 +02:00
Axel Spoerl
4076638022 QDockWidget: Fix memory leak when closing floating tabs
QDockWidgetGroupWindow (aka "floating tabs") can have a single
QDockWidget child only, when a second QDockWidget is hovering over it.
When the QDockWidgetGroupWindow detects the disappearance of its second
last child, it reparents the last child to the QMainWindow and makes it
floating. It removes its last dock widget child from its own
item_list and itself from its parent's (the main window's) item_list.
Then the QDockWidgetGroupWindow removes itself by calling its
deleteLater() slot.

A removal from an item_list calls the d'tor of QDockAreaLayoutItem,
which deletes the item's subinfo and placeholder item, if they exist.
It does not delete the item's widgetItem. In fact the layout accesses
the widgetItem member to draw placeholders and decorations.
As a consequence, both the QDockWidgetGroupWindowItem and the
QDockWidgetItem are leaked, when the corresponding record is removed.

Implement QDockAreaLayout::takeWidgetItem(), which transfers ownership
of QDockAreaLayoutItem::widgetItem to the caller by returning a
std::unique_ptr.
Call this method in QDockWidgetGroupWindow::destroyOrHideIfEmpty() and
QDockWidgetGroupWindow::reparentToMainWindow().

As a drive-by, use static_cast<QMainWindow *>() and assert a
qobject_cast in debug mode.

Fixes: QTBUG-135442
Pick-to: 6.9 6.8 6.5
Change-Id: I055c998f515f2bb461518b7516f56db4673687da
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-04-09 15:15:35 +02:00
Axel Spoerl
12dfc8d5ed QDockWidgetGroupWindow: Properly destroy gap items and separators
QDockWidgetGroupWindow::destroyIfSingleItemLeft() cleared the item list
without checking for gap or separator items. When a QDockWidget was
deleted during an active drag, these items were leaked.

Call deleteAllLayoutItems() before clearing the item list.

Amends e6d85cf28bc4f750b69c33b72c006b067ae1190f.

Task-number: QTBUG-135442
Pick-to: 6.9 6.8 6.5
Change-Id: I94dffe162023c12bda1f801236ae4462229601b5
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-04-09 15:15:35 +02:00
Axel Spoerl
b7446b1f5b QDockAreaLayoutInfo::takeAt(): don't greate gap for demoted QDockWidget
In the current implementation, when a dock widget is deleted, the
QWidget destructor triggers a ChildRemoved event to inform the layout
of the widget's removal. During this process,
QDockAreaLayoutInfo::takeAt() is invoked to remove the dock widget from
the item list in its QDockAreaLayoutInfo.

However, the existing logic in takeAt() incorrectly assumes that the
dock widget is either being moved or closed, failing to account for its
destruction. This leads to the construction of a QPlaceholderItem with
a QWidget pointer, despite the widget already having been demoted to a
QObject.

Check QObject::isWidgetType() before creating a QPlaceholderItem,
ensuring that placeholders are only created for active QDockWidgets.

Task-number: QTBUG-135442
Pick-to: 6.9 6.8 6.5
Change-Id: Ie583cff260b62dd07acd473364003a2f04a18f8c
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-04-09 15:15:35 +02:00
Piotr Wiercinski
b8ff842ace wasm: Fix use after delete of QWasmSuspendResumeControl
m_inputContext and other fields depends on the lifetime
of m_suspendResume, but the latter gets destroyed first.
Make sure that m_suspendResume is initialized first.

Fixes: QTBUG-135378
Change-Id: Ifa2d58ec06a1f832549478bece3a8f651276ac8f
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-04-09 13:58:46 +02:00
Volker Hilsheimer
d139d22f7e QGIM: documentation update
Document that we support reference wrappers and smart pointers for the
model. Turn the construction of the model into a dedicated section,
and add relevant snippets. Rename and reorganize sections a bit to
introduce basic concepts (rows, columns, multi-role items) first,
before the rather advanced topic of trees and value/pointer trade-offs
for rows.

Change-Id: Ia622783f9cd7aa345217186b438e5e883b9c25b0
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-04-09 13:58:46 +02:00
Tor Arne Vestbø
2e5a881d34 Account for Qt::AA_MacDontSwapCtrlAndMeta when mapping Latin ⌘-shortcuts
To follow the system we map key events that include ⌘ as if they had
been made using a Latin/Roman keyboard layout. However when looking
for the ⌘-keymap, we were not taking Qt::AA_MacDontSwapCtrlAndMeta
into account, and since the keymap differs whether the attribute is
set or not we ended up pulling the Meta-keymap instead.

Fixes: QTBUG-133963
Pick-to: 6.9 6.8
Change-Id: I32dd06025e1e1d93f3792952e6ad842efc6245a6
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2025-04-09 13:57:42 +02:00
Milla Pohjanheimo
bb69d80975 Add binary compatibility file for 6.9.0
Pick-to: 6.9
Change-Id: Ibc5eb17a045ff4840727ae4d37bbdfae5855e596
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2025-04-09 14:57:42 +03:00
Aurélien Brooke
03d5daf943 Add jemalloc support
Large graphical Qt applications heavily rely on heap allocations.
Jemalloc is a general-purpose malloc(3) implementation designed to
reduce heap fragmentation and improve scalability. It also provides
extensive tuning options.

Add a -jemalloc configure option, disabled by default. When enabled, Qt
and user code link to jemalloc, overriding the system's default
malloc().

Add cooperation with jemalloc for some Qt key classes: QArrayData (used
by QByteArray, QString and QList<T>), QBindingStoragePrivate,
QDataBuffer (used by the Qt Quick renderer), QDistanceFieldData,
QImageData, QObjectPrivate::TaggedSignalVector, QVarLengthArray.

This cooperation relies on two jemalloc-specific optimizations:
1. Efficient allocation via fittedMalloc():
   Determine the actual allocation size using nallocx(), then adjust the
   container’s capacity to match. This minimizes future reallocations.
   Note: we round allocSize to a multiple of sizeof(T) to ensure that
   we can later recompute the exact allocation size during deallocation.
2. Optimized deallocation via sizedFree():
   Use sdallocx(), which is faster than free when the allocation size
   is known, as it avoids internal size lookups.

Adapt the QVarLengthArray auto tests on capacity.

Non-standard functions docs are at https://jemalloc.net/jemalloc.3.html

[ChangeLog][QtCore] Added optional support for the jemalloc allocator,
and optimized memory allocations and deallocations in core Qt classes to
cooperate with it.

Change-Id: I6166e64e66876dee22662d3f3ea3e42a6647cfeb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-09 13:49:11 +02:00
Joerg Bornemann
fc277e3ff6 Fix linker errors when building bootstrap lib on macOS
The bootstrap lib doesn't build qfilesystemengine_mac.mm, and that's
where QFileSystemEngine::supportsMoveFileToTrash and
QFileSystemEngine::moveFileToTrash are implemented.

Make sure that the preprocessor picks up the QT_BOOTSTRAPPED condition
first to define implementations for the two methods.

Pick-to: 6.9
Fixes: QTBUG-135650
Change-Id: Icf7995abfae368b9f5bd5c4ccfcf4c3c6664d519
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-09 13:15:44 +02:00
Joerg Bornemann
86c250d98f CMake: make ccache + pch + clang build more robust
The ccache man page says we have to compile with -fno-pch-timestamp when
using clang and precompiled headers.

"Professional CMake" also recommends this approach, and the ccache
statistics report a marginally better hit rate with this patch.

Task-number: QTBUG-131650
Change-Id: Ic1c17a3977771673ac256674143dbdf8d5ffa28c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-04-09 13:15:44 +02:00
Safiyyah Moosa
7b66c906bf Doc: Add Alt-text to the Qt SQL examples
QDoc generates warnings for images that do not have alt-text associated
with them. Alt-text is used to add context to images for users who use
screen-readers.

This patch applies alt-text to images in the Qt SQL module that do not
have any alt-text associated with them.

Fixes: QTBUG-135114
Pick-to: 6.9 6.8
Change-Id: Iead375852d30219db7dfed12bb1f383eb55713e6
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2025-04-09 07:15:08 +02:00
David Faure
80d01c4ccb QReadWriteLock: fix data race on the d_ptr members
Testcase: ./tst_qreadwritelock countingTest

WARNING: ThreadSanitizer: data race (pid=356186)
  Read of size 1 at 0x7294000000f8 by thread T12:
    #0 contendedTryLockForRead qtbase/src/corelib/thread/qreadwritelock.cpp:230 (libQt6Core_tsan.so.6+0x6c3743)
    #1 QReadWriteLock::tryLockForRead(QDeadlineTimer) qtbase/src/corelib/thread/qreadwritelock.cpp:190 (libQt6Core_tsan.so.6+0x6c347b)
    #2 QReadWriteLock::lockForRead() qtbase/src/corelib/thread/qreadwritelock.h:68 (tst_qreadwritelock+0xb0f0)
    #3 ReadLockCountThread::run() qtbase/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp:597 (tst_qreadwritelock+0xc506)

  Previous write of size 8 at 0x7294000000f8 by thread T2:
    #0 operator new[](unsigned long, std::align_val_t) <null> (libtsan.so.2+0xa78eb)
    #1 allocate qtbase/src/corelib/tools/qfreelist_p.h:135 (libQt6Core_tsan.so.6+0x6c6079)
    #2 next qtbase/src/corelib/tools/qfreelist_p.h:212 (libQt6Core_tsan.so.6+0x6c5915)
    #3 QReadWriteLockPrivate::allocate() qtbase/src/corelib/thread/qreadwritelock.cpp:564 (libQt6Core_tsan.so.6+0x6c5354)
    #4 contendedTryLockForRead qtbase/src/corelib/thread/qreadwritelock.cpp:218 (libQt6Core_tsan.so.6+0x6c364f)

The loadRelaxed() at the beginning of tryLockForRead/tryLockForWrite
isn't enough to bring us the non-atomic write of the recursive bool.
Same issue with the std::mutex itself.

Pick-to: 6.9 6.8 6.5
Change-Id: I6f5e371cf94292b643cb36041d1406b19d22cdbe
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-08 15:14:25 +02:00
Piotr Wiercinski
5e7dc4220f fusion: Remove dead code
Change-Id: Ia61888f9189b3b3284c91ff91bceef0770e6cb5a
Reviewed-by: MohammadHossein Qanbari <mohammad.qanbari@qt.io>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2025-04-08 14:27:50 +02:00
Magdalena Stojek
6551bef9d9 Clarify XML version support and improve documentation for QXmlStream
This updates the documentation for QXmlStreamReader and QXmlStreamWriter
to explicitly state that only XML 1.0 is supported. While the writer
allows specifying arbitrary version strings, it does not implement
XML 1.1 features. The reader strictly enforces XML 1.0 and rejects
unsupported versions.

Fixes: QTBUG-43029
Pick-to: 6.9 6.8 6.5
Change-Id: I771de29e7915d7a4daafe2fe14d600adfbbac4ac
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-04-08 11:25:13 +02:00
Marc Mutz
51cd57116b QPointer: don't cause UB when checking for nullptr
QPointer is used to track whether a QObject is still alive, and so
it's unsurprising that checking whether the pointer is null is
sometimes done in situations where the QObject is already in the
process of being destroyed and therefore already demoted from T, the
QPointer template argument, to some base class.

Because of the way we made QPointer SCARY¹, calling data() will cast
from QObject* to T*, which is UB if the T was already demoted.

It's hard to fix this in the general case, but the various ways to
spell isNull() should all be equivalent to isNull() (which does not
cause UB, because it doesn't cast).

This patch fixes the relational operators against nullptr and adds an
explicit operator bool() so that if (p) and if(!p) no longer have to
go through (implicit) operator T*(). This does not appear to cause
disambiguities, so it's SC.

Don't document the operator, it's an implementation detail (and not
documenting it lets us pick it back). A follow-up will add the
documentation for 6.10+.

Add tests, even for stuff that's currently still UB (but marked by an
early return). A follow-up patch will try to make as many of these
other operations non-UB as possible, too.

¹ Originally 3f7741fbe7ab4140f8f971c0cf88bb04e7feea6b, then changed in
  cc7239da8d1ab95e68e12a64df3ca3051419cb34 and
  351c738fc4586bf354c9363fb78e190bdfca4617.

Amends the commits mentioned in the footnote.

[ChangeLog][QtCore][QPointer] For `QPointer<Derived> p`, `!p` and
comparing `p` to nullptr no longer perform invalid downcasts when the
object held in `p` is in the process of being destroyed and has
already been demoted from Derived to one of its base classes. Before,
these expressions invoked data(), which casts from QObject* to
Derived*, a cast which is invalid.

Pick-to: 6.9 6.8 6.5 5.15
Task-number: QTBUG-135626
Change-Id: I1b59062345e1b6933958c7e030d9253d69e7591c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-08 06:47:56 +02:00
Volker Hilsheimer
2d8a04d753 QGIM: improve test to initialize data of associative containers
When we insert a new row where the row type is an associative container,
the resulting row holds no data, and the QVariant we get from data is
invalid. So far we have QEXPECT_FAIL'ed the test that checks if the data
from a new row is valid. This is misleading; there is a valid map in the
row, which is what we want to test.

Instead, connect to the rowsInserted signal to populate the new row(s)
with (empty, but valid) data.

Change-Id: If89e30c2944581bd0059f908e2dfb956c655f34f
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-04-07 22:45:38 +02:00
Volker Hilsheimer
17ee99ae2d QGIM: unblacklist test for vxworks
The tree tests are passing now, presumably because we instantiate
the model explicitly in 8edabea2a76192788d30afc22e2ebcb560195401.

Change-Id: I08749311034b34ec958b163c1b19105d847309e9
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-04-07 22:45:38 +02:00
Thiago Macieira
3f054d9220 QUrl: move intro string passed by value
Amends commit 31207b539a19182b48c4b3b8413190d505633eea.

Unlike the other setXxx() functions, setUserInfo() has a trimmed() call,
which was retained from Qt 4's QUrl. This is probably wrong, but no one
has complained in the 17 years of public Git history. As a result, the
template function QUrlPrivate::setUserInfo() was getting a copy of the
string, which is inefficient. We can fix that by simply moving the
string and matching a move inside that function too.

Coverity-Id: 480249
Coverity-Id: 480253
Change-Id: I5d9edea3174080822e82fffdd5f1548e8715e510
Reviewed-by: David Faure <david.faure@kdab.com>
2025-04-07 12:29:27 -07:00
Alexey Edelev
52e2a89c63 Default initialize the statep pointer in the resolv compile check
Initialize the variable with the default value, to avoid the type
mismatch warnings.

Fixes: QTBUG-135648
Pick-to: 6.8 6.9
Change-Id: I3ae2c59fb42676b373bcbbe06d3e6636203e283b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-04-07 20:04:12 +02:00
Marc Mutz
0435aaccdc tst_QDockWidget: hot-fix UB (invalid downcast) in titleBarDoubleClick()
Events of type QEvent::NonClientAreaMouseButtonDblClick have to be
QMouseEvent, not just QEvent, as this test function did.

Says UBSan:

  qdockwidget.cpp:1715:36: runtime error: downcast of address 0x7ffea5257d10 which does not point to an object of type 'QMouseEvent'
  0x7ffea5257d10: note: object is of type 'QEvent'
   3d 7f 00 00  c0 2b dc f4 3d 7f 00 00  b0 00 00 00 01 00 00 00  49 c1 02 3b a1 90 45 7c  20 17 03 00
                ^~~~~~~~~~~~~~~~~~~~~~~
                vptr for 'QEvent'
    #0 0x7f3e1bcb0633 in QDockWidget::event(QEvent*) qdockwidget.cpp:1715
    #1 0x7f3e1a262351 in QApplicationPrivate::notify_helper(QObject*, QEvent*) qapplication.cpp:3309
    #2 0x7f3e1a2e374a in QApplication::notify(QObject*, QEvent*) qapplication.cpp:3259
    #3 0x7f3df1e0ca4a in QCoreApplication::notifyInternal2(QObject*, QEvent*) qcoreapplication.cpp:1111
    #4 0x7f3df1e0f453 in QCoreApplication::sendEvent(QObject*, QEvent*) qcoreapplication.cpp:1551
    #5 0x5599b850aeee in tst_QDockWidget::titleBarDoubleClick() tst_qdockwidget.cpp:869

Fix by creating a minimal QMouseEvent instead. This is a hot-fix to
get rid of the UB. I can get away with passing senseless parameters to
the QMouseEvent, because the test worked (except for the UB) for even
a QEvent. A proper fix should use a proper QMouseEvent. Created
QTBUG-135410 to track the issue.

Amends the start of the public history, but not picking back. The
eventual fix for QTBUG-135410 should first revert this hot-fix, and
then pick the proper fix to all then-active branches.

Task-number: QTBUG-135410
Change-Id: I188fb5b7d7bdab0432a4877c1948dc0c384a658a
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-07 20:04:12 +02:00
Marius Kittler
43dbbf67ac Avoid compile errors due to inconsistent use of noexcept
Only with these changes the affected code compiles with mingw-w64 and
GCC 14.2.0.

Change-Id: Ib4c392cd306b4e8b433048af077ae7aeb0459e1f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-04-07 20:04:12 +02:00
Volker Hilsheimer
a92c78784f QGIM: reimplement remaining virtuals
Opens up the option to provide optimized reimplementations of e.g. mime
type handling or sorting, without having to worry about compatibility
implications when adding new overrides.

Also override QObject::event/eventFilter, for the same reason.

Change-Id: I843cfc449770e780fa3dbc2bd9629939f847a26e
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-04-07 19:05:03 +02:00
Volker Hilsheimer
1bb601cc2e QGIM: silence size_t/int conversion warning
Amends 424d6ebf13d594a5d27d98b577a5c3d316c91bbb.

Change-Id: Iba2880c8978389113ff1f83c13777ec95c8d6063
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-04-07 19:05:03 +02:00
Konstantin Ritt
f5a940a34f Client: Improve support of zxdg_output_v1 version 3
by applying recommendations regarding the deprecated events

Change-Id: Ic462b1be83a1241f01f3fc909fa803615781ed2e
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-04-07 19:17:58 +03:00
Konstantin Ritt
0544249ea7 Client: Support wl_output.name of version 4
Change-Id: I937146f571460045ab0a3b8a7e5cd5f3d802ea62
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-04-07 19:17:55 +03:00
Bartlomiej Moskal
1a35a560dd Android tests: Fix for moving file in content URI test
In Android's manual URI content test, there is a test case for moving a
file to another directory. While the function works and the file is
moved correctly, the URI is no longer usable after this operation. The
file must be reopened with a new URI.

This commit updates fileOperations test case to use the new URL after
moving file to another directory

Pick-to: 6.9 6.8
Fixes: QTBUG-134881
Change-Id: I114d76d6851815e7ee3d94ddc28d677d7c1ccea9
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-04-07 13:25:06 +00:00
Tor Arne Vestbø
fc3d0b029b macOS: Remove QT_MAC_WANTS_LAYER remnants from surface-backed views
We only support layer-backed views nowadays.

Change-Id: I900605a50ce513c4de08081200f2946ee08f15c8
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2025-04-07 15:09:54 +02:00
Tor Arne Vestbø
1b5e22be23 macOS: Remove drawRect and use plain CALayer for raster windows
The drawRect callback was used when we were supporting both surface-
backed and layer-backed drawing, but nowadays we only support layer-
backed drawing.

However we couldn't just remove the implementation, as the default
backing layer of an NSView is an NSViewBackingLayer, which in its
override of [CALayer display] checks whether the view implements
drawRect, and if not bails out, which meant we never reached our
displayLayer callback from [CALayer display].

But, we don't need NSViewBackingLayer, as we handle layer updates
and draw callbacks in a more generic way, to support CAMetalLayer,
so instead we now use a plain CALayer as our backing layer for
raster windows.

Change-Id: I5b878ff51ca92dafcb80bf5a686ced13088cfa28
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2025-04-07 15:09:46 +02:00
Eskil Abrahamsen Blomfeldt
98e0a7e0a0 Upgrade Harfbuzz to 11.0.0
[ChangeLog][Third-Party Code] Upgraded Harfbuzz to version
11.0.0.

Pick-to: 5.15 6.5 6.8 6.9
Fixes: QTBUG-135373
Change-Id: If4a530ec43f5992141945d7ad86268e838cc0230
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-04-07 15:09:22 +02:00
Ivan Solovev
f0573e93df Add a separate QT_FEATURE for std::format
We want tst_qfloat16 to be built in C++20 mode, even if Qt itself is
not built in C++20 mode, which means we can't use QT_FEATURE_cxx20 as
check in tst_qfloat16's CMakeLists.txt.

In addition, even if the compiler supports C++20, the standard library
may not support all features we need. Specifically, due to the
deployment target of macOS being 12 we can't rely on std::to_chars
being available, as is only available since macOS 13.4.

This patch introduces a separate QT_FEATURE_cxx20_format, and
adjusts the tst_qfloat16's CMakeLists.txt to use this feature.

Note that we intentionally do not add QT_FEATURE_cxx20 as a
hard condition to the new check, because it might be disabled
during the Qt configuration, but we still want the test to be
built in C++20 mode.

Note also, that we cannot use the QT_CONFIG(cxx20_format)
check in the qtformat_impl.h header, because the std::format
support is header-only, and user project might be compiled
for a different minimal macOS version, so we do not want to
rely on the Qt-specific config.

Pick-to: 6.9 6.8
Change-Id: Ibc43d243dbb24fcb922647fe2d90f61491144eb7
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-04-07 13:03:12 +00:00
Laszlo Agocs
d8fb42bb79 rhi: d3d12: Avoid 1 sec timeout when skipping present
Follow the d3d11 change.

Pick-to: 6.9 6.8
Change-Id: I06ef9e64f37fba72c2ab6adc84ad9058f22ae1e4
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-04-07 12:55:57 +00:00
Alexandru Croitor
ae4f9fe0cf CMake: Fix DESTDIR handling for plugin rpath adjustment on Linux
_qt_internal_set_rpath was using CMAKE_INSTALL_PREFIX instead of
QT_DEPLOY_PREFIX for the destination path, which ends up trying to
adjust the rpath of plugins in the regular install destination, rather
than in DESTDIR.

Change the code to use QT_DEPLOY_PREFIX where appropriate.

Amends 5430fb22439db9fc1ad1df4cbf0319b63346b0a5

Pick-to: 6.8 6.9
Fixes: QTBUG-135620
Task-number: QTBUG-109553
Change-Id: Iea1c0b69ba93fa5e81c463df57f8c2e19703a66a
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-04-07 14:55:54 +02:00
Vlad Zahorodnii
26968c3802 Client: Fix copying shm buffer data with fractional scaling
The QWaylandShmBackingStore computes the device pixels in the source
image manually. But it does not match what the QPainter does one to one.
Visually, it produces artifacts where the contents of an app is
jiggling or moves back and forth by one pixel.

In order to address the issue, the QWaylandShmBackingStore can copy
whole buffers but with a clip region set. That way, the QPainter can
consistently compute the coordinates in the device pixels.

Pick-to: 6.9
Change-Id: Ib4832c4d687f43f6cc1de4a1760c32f1abd2ab03
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-04-07 15:49:58 +03:00
Axel Spoerl
2bbf6aa2b8 Remove double negation ifdefs in QKdeTheme
Replace ifndef QT_NO_DBUS antipattern by if QT_CONFIG(dbus).

Change-Id: I186c779f3c4ed36a1fb082993e792e9c28ee20f0
Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
2025-04-07 03:40:20 +02:00
Axel Spoerl
fa42c281ee Remove double negation ifdefs in QGnometheme
Replace ifndef QT_NO_DBUS antipattern by if QT_CONFIG(dbus).

Change-Id: I7dd44a6f5496e6f12c16ee1ecef3a004e5580d17
Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
2025-04-07 03:40:20 +02:00
Axel Spoerl
f86a0ccdfb Remove double negation ifdefs in QGenericUnixTheme
Replace ifndef QT_NO_DBUS antipattern by if QT_CONFIG(dbus).

Change-Id: Ifca080594358df0d836db25721b43ad31129cf48
Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
2025-04-07 03:40:20 +02:00
Marc Mutz
f4e892d797 tst_QAbstractSlider: add a check for sliderChange() "emission"
QAbstractSlider::sliderChange() is not a signal, but a protected
function, carrying an enum (also protected) to inform subclasses about
changes in the base class.

A user reported (QTBUG-135597) that in 5.15 the function was not
called for SliderOrientationChange.

Add a test that verfies that the function is a) called for all other
enum values and b) add XFAILs for the (still) missing
SliderOrientationChange.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Task-number: QTBUG-135597
Change-Id: I959077f030976937dd279897748025afa06e74dd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-06 23:25:11 +00:00
Christian Ehrlicher
847c0bf076 Windows11Style: Disable shadow for QComboBox inside QGraphicsProxyWidget
A QGraphicsEffect is not rendered inside a QGraphicsView so we must not
set it on a QComboBoxPrivateContainer. We have to do some checks for it
when a stylesheet is set as polish() is then called before the proxy
widget is set on the QComboBoxPrivateContainer. But luckily QComboBox
has the proxy widget already set so do the check there.

Pick-to: 6.9 6.8
Fixes: QTBUG-135340
Task-number: QTBUG-128916
Task-number: QTBUG-128329
Change-Id: I2426701f3aa44a2eb14b66846628dbb9cd16dc9f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-07 01:25:11 +02:00
Tor Arne Vestbø
92a65fdac6 Delete QWindow children during QWindow destruction before ~QObject
Otherwise we run the risk of a child window referencing its parent
as a QWindow, for example via QWindow::screen(), which is UB, as the
QWindow no longer exists as such.

It's the right fix, but it may have fallout from code that (wrongly)
assumed children would live longer than what they will after this patch.
The reason for not picking to 6.9 or earlier is to mitigate this risk.
We can always pick later once it's cooked in dev.

Done-with: Marc Mutz <marc.mutz@qt.io>
Change-Id: Idca3fe09b83c7bcd9335a48877f2f14b304fb0ac
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-06 23:25:11 +00:00
Artem Dyomin
8edabea2a7 QGIM: Unify flat and tree models
Allow both model types to have a policy, and unify the policy API
to always pass the row we operate on by reference (as it must never
be nullptr).

Add test coverage for passing models and rows as pointers, wrapped
references, shared pointers, and unique pointers.

Change-Id: I4797dc4c26fb1676e851df62dae4f8a382cec6fc
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-06 20:05:40 +02:00
Martin Storsjö
6b6ddd377d Windows: Fix using NT APIs on i386
While the MS docs don't include the NTAPI attribute here, these
functions are presented with stdcall name mangling in the ntdll.lib
import library in the Windows SDK (and likewise in the mingw import
libraries). Therefore, add NTAPI (which expands to __stdcall) here
to fix linking.

Change-Id: I7d59b6a3c64823743498497a2ddc869e5556432c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-06 04:47:33 +03:00
Thiago Macieira
d064c26d2c QUrl: merge parseDecodedMode with qurlrecode.cpp algorithms
parseDecodedMode() encoded only the percent ('%') characters ahead of
the standard transformation into the internal format. This is a result
of the decoded mode being retrofitted on top of the original encoded-
only QUrl in commit 53d0624403f7f2ac8fe8364a7c5cd136717d40ed.

That was slightly inefficient: if we needed to perform any additional
transformations, we could end up allocating two strings. It's probably
not a common scenario that the input contains a percent and something we
usually encode for the internal format, but it can happen.

This commit merges the two functionalities. After all, the recode()
function in qurlrecode.cpp has the retryBadEncoding mode.

Change-Id: I6b6d6a0f6a3553748154fffd8afb4900087ad13b
Reviewed-by: David Faure <david.faure@kdab.com>
2025-04-05 18:20:10 -07:00
Thiago Macieira
31207b539a QUrl: restore copying of the input QString in setXxx functions
Complements the previous commit by using templates so we copy the input
QString if it is a QString, duplicate the input if QStringView.

Change-Id: I1646ead1283e16029fc6fffd850daf12b6f6f913
Reviewed-by: David Faure <david.faure@kdab.com>
2025-04-05 18:20:10 -07:00
Thiago Macieira
be0c9e7638 QUrl: use some QStringView internally a bit more
Implemented for the internal QUrlPrivate::setXxxx functions that don't
call setError() (that is, all except setAuthority() and setHost())
because setError() takes the full input to store for the error string.

This temporarily means we won't copy the user's QString when no
modifications are made to store in the PrettyDecoded mode. That will be
fixed in the next commit.

Change-Id: I984e855c964c23c93c4dfffd1a703ca00ed2090e
Reviewed-by: David Faure <david.faure@kdab.com>
2025-04-05 18:20:10 -07:00
Thiago Macieira
7ed94ef2b5 QUrl::adjusted: remove unnecessary temporary variable
We don't need to QUrlPrivate::appendPath() to a temporary variable under
QUrl::FullyEncoded mode and then setPath(). We can simply ask
appendPath() to write to the destination variable once and for all, so
long as we take care to ask it to use the encoding form that setPath()
uses (QUrl::PrettyDecoded, which is 0x0). That avoids the side trip
through FullyEncoded mode.

Pick-to: 6.8 6.9
Change-Id: I7908b9cf75742db07145fffd9499ce3b79492fdb
Reviewed-by: David Faure <david.faure@kdab.com>
2025-04-05 18:20:10 -07:00
Thiago Macieira
f3da9d3c85 QUrl: expand the square brackets encoding to decoded setPath() calls
Amends (reverts) commit 5e936b60fc921e21b8153a83113886a1de333b57, which
forced the encoding of the square brackets ("[]") into their percent-
encoded forms only in QUrl::fromLocalFile(). This commit expands the
functionality to all uses of decoded paths by applying the change
directly to recodeFromUser().

[ChangeLog][QtCore][QUrl] Square brackets ("[]") are now transformed to
their percent-encoded forms ("%5B" and "%5D") when present as inputs to
setPath(), setQuery(), and setFragment() if the parsing mode is
QUrl::DecodedMode (the default).

Pick-to: 6.8 6.9
Fixes: QTBUG-135433
Task-number: QTBUG-134073
See: https://bugs.kde.org/show_bug.cgi?id=502280
Change-Id: Id2b41559af08b5f228e4fffdb9c6f23120f856b5
Reviewed-by: David Faure <david.faure@kdab.com>
2025-04-05 18:20:09 -07:00
Axel Spoerl
565606fc36 Build QDbusListener always when DBus is available
yocto/meta-qt6 builds qtbase with DBus and without XCB/Wayland.
The build failed, because QDBusListener is only built with either XCB
or Wayland.

Change CMake configuration and build QDBusListener always with DBus,
except on Apple platforms, where it is not needed.

Change-Id: Ia50a9a78941362a2c5ece68d50de3b3bddd5d878
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-06 01:25:17 +02:00
Christian Ehrlicher
7fdf7ad7e5 Windows11Style: replace QObject::inherits() with qobject_cast<>
Use qobject_cast<QComboBoxPrivateContainer *> instead
QObject::inherits() as this should be slightly faster and we have access
to the type so no need to use error-prone string comparison.

Pick-to: 6.9 6.8
Task-number: QTBUG-135340
Change-Id: I90ebb2323f21c2f5f9dd65bd7b1beeb32f1a91cc
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2025-04-05 20:17:30 +02:00
Marc Mutz
101427957b tst_QGraphicsItem: check that qgraphicsitem_cast casts correctly
GCC, with ubsan and optimization enabled, issues -Warray-bounds for
the cast from &polygonItem to QGraphicsTextItem*, because the latter
is-a QObject and the former is not, so the cast has to adjust the
pointer value to correct for the fact that QGraphicsItem is not the
first base class of QGraphicsTextItem:

  qgraphicsitem.h:973:56: warning: array subscript -1 is outside array bounds of ‘QGraphicsPolygonItem [1]’ [-Warray-bounds]
    973 |         || (item && int(Item::Type) == item->type()) ? static_cast<T>(item) : nullptr;
        |                                                        ^~~~~~~~~~~~~~~~~~~~
  tst_qgraphicsitem.cpp:3193:26: note: while referencing ‘polygonItem’

Check the implementation is correct in this respect by not just
checking for nullptr or non-nullptr, but checking that the result
matches what dynamic_cast produces.

We can assume dynamic_cast works on QGraphicsItems because QPA is
using dynamic_cast, so both QtGui and QtWidgets need to have been
compiled with RTTI enabled.

This doesn't eliminate the GCC warning, but confirms that it is a
False Positive.

Pick-to: 6.9 6.8 6.5
Change-Id: Ifc262cb6e715e8e68c180855adc2467960da89a1
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-05 17:24:45 +00:00
Marc Mutz
4c610300e3 tst_QPointer: make DerivedParent delete all children
... not just 'derivedChild'.

This doesn't change anything for the test right now, but will enable
an extended test to be added on top.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Id52f785168c97c43433fb15a6a71a9d1fb140036
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-05 19:24:45 +02:00
Marc Mutz
2e0988190f tst_QGraphicsGridLayout: fix memleaks in setGeometry()
The test function created a parent-less QGraphicsWidget, and while it
added a bunch of child objects to it, that initial graphics-widgets
never got an owner so it and all the children were leaked.

Fix by holding it in a unique_ptr. That is the minimally-invasive fix.

Amends the start of the public history.

Pick-to: 6.9 6.6 6.5 5.15
Change-Id: I3ab9db721e1343f2bd8d9fdd0ee6e86733a66da2
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-05 19:24:45 +02:00
Marc Mutz
d21434d187 tst_QGraphicsGridLayout: fix memory leaks in columnCount()
The populateLayout() function adds parent-less QGraphicsWidgets
(RectItems) to the layout. If the layout had a graphics-widget parent,
it would reparent the items added to it onto the parent. But it
didn't, so it didn't.

Therefore, the last part of the test function (as denoted by the
re-creation of `layout`) leaked a lot of items, including `layout`.

To fix, give the layout the existing graphics-widget parent. Then the
layout itself isn't leaked anymore, either.

Amends the start of the public history.

Essentially the same commit for columnCount() that
b9836518a367a31a48027a5bf81c4973b847b442 was for rowCount().

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Ic38dfccfa41049d96eb0cf5811271ac17f2b1f91
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-05 19:24:44 +02:00
Marc Mutz
fe0b29a45c tst_QGraphicsGridLayout: fix memleaks in spanningItem2x3()
The test function creates a bunch of QGraphicsWidgets without parents,
and adding them to the QGraphicsGridLayout doesn't make them owned by
it. Besides, the layout was without a parent itself, so all these
objects were leaked.

To fix, give the layout a stack-allocated QGraphicsWidget parent. Now,
the layout will reparent the widgets added to it to its own parent
widget, which will delete layout and child widgets when it itself is
deleted on all exists from the test function.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I8d80713f4ff6b1055bc396d855f98bc1873aee3b
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-05 19:24:44 +02:00
Marc Mutz
45f317fba0 tst_QGraphicsGridLayout: fix memleak in spanAcrossEmptyRow()
The test function created a parent-less QGraphicsWidget on the heap,
and didn't otherwise transfer ownership of it to another object, so
the object was leaked.

The minimal fix is to hold the graphics-widget in a unique_ptr. This
requires to change the following line, too (as would the alternative,
allocation on the stack), but the rest of the function can stay as-is
(unlike with stack allocation, which would require further s/[.]/->/.

Amends 4f072e2d3d7e429359ff15a615d02712bff7ee51.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Ide305dde7934747dbc3acdb49f5a75e98563828c
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-05 19:24:44 +02:00
Marc Mutz
4d0f979610 tst_QGraphicsGridLayout: fix memleak in removeItem()
The test function contains a negative test where we're trying to
remove an item that isn't in the layout.

Unfortunately, the object we're passing is heap-allocated and has no
parent, so was leaked.

To fix, pass the existing `widget` as a parent. This doesn't change
the test's outcome: Like in QWidget, a graphics-widget is not
automatically added to its parent's layout.

Amends the start of the public history.

Pick-to: 6.9 6.6 6.5 5.15
Change-Id: Ic110ea7b93aa0023c0903c776a30dc5c377ce0c5
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-05 19:24:44 +02:00
David Faure
f197456481 Don't call elapsed() on an invalid QElapsedTimer
It's UB, and it returns garbage.

In QWaylandWindow::timerEvent the value was unused
if the timer was invalid (but that was tested only later).

In QWaylandInputDevice / QWaylandTabletToolV2 however the
garbage value was passed on to wl_cursor_frame_and_duration.

Testcase: running tests/auto/client/client/tst_client
and tests/auto/client/tabletv2/tst_tabletv2 in a UBSAN build.

Pick-to: 6.9 6.8 6.5
Change-Id: Ie0f8610bbca49913942b2247d3e968197e12f47e
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
2025-04-05 12:48:05 +01:00
Nodir Temirkhodjaev
b37f84ba41 QMainWindowLayout: Fix build with -no-feature-dockwidget
Make deletion of unused tab bars conditional to dockwidget and tabwidget
features.

Task-number: QTBUG-135468
Pick-to: 6.9 6.8 6.5
Change-Id: I0ecb55ab20737f401796cdd4ebbc6040e54b5afe
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-05 11:47:42 +00:00
Axel Spoerl
a0e0425a10 Rename QDockWidgetGroupWindow::reparent() to reparentToMainWindow()
Naming the private API "reparent()" was unfortunate. It is ambigous, as
it suggests that the QDockWidget argument may be parented to the group
window. In fact the opposite is the case: It is removed from the group
window and re-parented to the QMainWindow.

Rename the API into reparentToMainWindow(), which is what it does.

Amends e6d85cf28bc4f750b69c33b72c006b067ae1190f.

Task-number: QTBUG-135442
Pick-to: 6.9 6.8 6.5
Change-Id: I6f9f37c190f3550348b1e4e14a8612d8880170dd
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-04-05 09:08:32 +02:00
Ivan Solovev
900d1daaeb QXmlStreamReader: test adding data in different encodings
Currently all the tests are expected to pass because we always
convert everything to UTF-8.
This is a pre-requisite for the follow-up patches that would try to
optimize the internal logic to minimize the number of encoding
conversions.

Task-number: QTBUG-124636
Pick-to: 6.9 6.8 6.5
Change-Id: I0ac9212aeb8ccc768393e80c9e0d704fdc227b56
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-04 22:04:46 +02:00
Ivan Solovev
b6b725aef5 QXmlStreamReader: fix addData() unnecessary conversion to UTF-8
The addData(QASV) overload was unconditionally converting UTF-16 and
Latin1 data to UTF-8.
However, if we already started reading the XML document, and we know
that its encoding is UTF-16 or Latin1, then we know for sure that the
new data has to be added as-is.

Amends 6bc227a06a0d1392d220aa79ddb1cdc145d4f76e.

[ChangeLog][QtCore][QXmlStreamReader] Fixed a bug when
addData(QAnyStringView) was incorrectly recoding UTF-16 and Latin1
data to UTF-8, thus potentially mangling it.

Fixes: QTBUG-135129
Pick-to: 6.9 6.8 6.5
Change-Id: Ie1171a5e5596b72a6f160031a4c5a9df3baae4fd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-04 22:04:45 +02:00
Laszlo Agocs
35dd681f2b rhi: d3d11: Add activeAdapter null check
...to match 6.8 that has this added as part of a backport.

The D3D12 backend has this already. Still, move the
resetting of the variable to the outer scope in that one
too, to cover both code paths.

Pick-to: 6.9
Change-Id: Ie4ba22ff9f2a2f6882dd2d5e3063c4e6701fa95c
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-04-04 21:04:45 +01:00
Laszlo Agocs
f2437c9d8c rhi: d3d11: Avoid 1 sec timeout when skipping present
endFrame(SkipPresent) followed by beginFrame() would sometimes end
up waiting up to a second. We should not wait at all in this case.

D3D12 patch will follow separately.

Pick-to: 6.9 6.8
Change-Id: I3a5605c3fb672f9d68f2afb69645c5c47a5214b3
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-04-04 20:04:45 +00:00
Eskil Abrahamsen Blomfeldt
66fae045cd Make sure Harfbuzz build picks up Qt atomics
We have our own implementation of the atomics API in Harfbuzz
for broader platform support. This is done through the mechanism
in Harfbuzz where you make a file called config.h with the
implementation and then define HAVE_CONFIG_H.

In Qt, we have this in src/3rdparty/harfbuzz-ng/config.h,
next to the CMakeLists.txt.

However, on some platforms, a different config.h has been found
earlier in the include paths and included instead, causing us to
use the default atomic implementation instead on these platforms.

This causes problems with the upgrade to Harfbuzz 11, where the
atomics have been written to depend on some template syntax which
is not properly supported on the Integrity OS compilers yet.

This was also a random inconsistency, so rather than try to work
around the compile issue on Integrity, we add the CMakeLists.txt
directory as the first include path, to make sure the correct
config.h is picked up on all platforms.

Pick-to: 6.5 6.8 6.9
Change-Id: I5fc2d57e740ea0a59700ebe319213fe716f8490e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-04 22:04:44 +02:00
Volker Hilsheimer
8ab3ff746b QGIM: don't try to move from const QVariant
Amends 07804a83c4019dca396adee079ad14e4b9b18cb8.

Change-Id: I5ab75b9e7463334c901019b2b3df330105b32106
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-04 22:04:44 +02:00
Alexey Edelev
1c886724bc Introduce _qt_internal_configure_file
The function is the internal public counterpart of the
qt_configure_file command, but also supports two modes:
GENERATE and CONFIGURE. The CONFIGURE mode is plain replacement
of file(CONFIGURE or configure_file command depending of specified
arguments.

In the GENERATE mode the function allows using the generator
expressions when evaluating the CONTENT. The function doesn't support
INPUT argument as its counterpart(there are no limitations, author left
this unimplemented).

Pick-to: 6.8 6.9
Change-Id: I9bef2265210404113596db95085b6e0d5f03ae13
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-04-04 17:23:42 +02:00
Alexey Edelev
2c8872f381 [androidtestrunner] Add early return if AndroidManifest.xml is missing
Helps to debug deployment issues.

Pick-to: 6.8 6.9
Change-Id: I15909b3ce9e680636e87ec8764bacbd75711e857
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-04-04 17:23:28 +02:00
Sebastian Beckmann
9c966d837f QComboBox: Ignore wheel event when not reacting to it
With the SH_ComboBox_AllowWheelScrolling style hint introduced in [1],
it's possible for combo boxes to not react to wheel scrolling. However,
since the event isn't explicitly ignored, it gets "eaten" by the combo
box instead of propagating up. This leads to upper level scroll areas
not receiving the event (and thus not scrolling).
By ignoring the event, the scroll area now scrolls if the hint is set
to false instead of nothing happening. This feels more intuitive and
mimics system behavior on both macOS (where the hint is set to false by
default) and Windows 11.

[1]: 5e9e4ccdc363297f70d4ebfbbb3e279670eca553

Pick-to: 6.9 6.8
Change-Id: I2207af8aad81fb76f3b1bbe074c3c4fbf22e3eca
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-04-04 16:23:24 +01:00
Alexey Edelev
d9ce5184c2 Dealias the target implicitly in _qt_internal_add_transitive_property
Ensure the target is not an ALIAS target when adding the
transitive properties.

Pick-to: 6.8 6.9
Change-Id: Ic9cb4f1a6e110596e430176cfa9b7f742d2c3446
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-04-04 17:23:14 +02:00
Tor Arne Vestbø
be93c06758 iOS: Replace variable length array in event dispatcher with QVarLengthArray
This does mean that if a custom stack size has been requested which
is larger than the default size, we'll end up with a custom stack
on the heap instead of on the existing stack.

I don't remember exactly why we opted for our custom stack to live
on the stack in the fist place. The commit message for the change
that introduced it (59601e06d96edb5661a3dd91341d74e16dc6b229) does
mention garbage collection as once use-case, but iOS hasn't used
GC itself, and a GC's mark-and-sweep would have to include the heap
in any case.

However, for compatibility we keep the custom stack on the stack
if we can, as we pass the default stack size to QVarLengthArray,
which covers 99,9999% of apps use anyways (GitHub shows no hits
for the QtRunLoopIntegrationStackSize override that would trigger
a heap-allocated custom stack).

In testing on both simulator and device a custom stack size that
results in a heap-allocated custom stack does work, so we should
be good in either case.

Fixes: QTBUG-135609
Pick-to: 6.9 6.8
Change-Id: I86251da005ebca8a1cad5cabd2835e83486b3f8e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-04 14:24:13 +00:00
Artem Dyomin
fffe4f32dd QGIM: do nothing in resetParent if model doesn't hold values
Move the check into the implementation.

Change-Id: I553f4883e9bf7bcccbfc66e009a5f7fc22fb03c5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-04 13:52:54 +02:00
Artem Dyomin
7718dcb53c QGIM: simplify EmptyRowGenerator
Make it constructible without a model so that we can default-construct
entries in flat ranges.

Change-Id: I51a97733a0de0b55d8cdbbca56ff528edd557ba6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-04 13:52:54 +02:00
Artem Dyomin
5898d8da9a QGIM: simplify call-helper
Use the helpers we have to unify calling with either pointer or
reference.

Change-Id: I1f1dec6095d913d9af4d8f427f05d8893a06ef76
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-04 13:52:54 +02:00
Artem Dyomin
0c6c49849d QGIM: reduce code duplication for writing/reading data
Add write/readAt helpers that take care of unwrapping the ranges and
call the lambda to access the correct element.

Change-Id: Ic56a7c987d3178cf9aa6699e37c24c700df9cd75
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-04 13:52:54 +02:00
Artem Dyomin
1f5fc537c1 QGIM: simplify MultiColumn's get<> implementation
Use the refTo helper to unify pointer/reference/value handling.

Change-Id: Ib4d1f142ffd47b843d42cabfbbab82f644d98125
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-04 13:52:54 +02:00
Artem Dyomin
424d6ebf13 QGIM: add reusable concepts for unifying pointer and reference types
Standardize the way to get a reference or pointer to an element, and use
that to implement begin/end helpers that work with values of and
pointers/references to ranges.

This allows us to support copies, references, raw pointers, and smart
pointers holding a range, both as the data itself and as rows of data.

Change-Id: Ief680d87fcfd6fcabcfe2fa4841d3641b49f0c43
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-04 13:52:53 +02:00
Volker Hilsheimer
ec200659da QGIM: implement moveColumns
We can move columns when the row-type is a range (which guarantees
that all columns are of the same type), and if the columns are moved
within the same parent. Otherwise we would end up with different
branches of a tree having different column counts, which we don't allow.
Since we require trees to use statically sized row types, the former
implies the latter anyway.

Change-Id: Iaf9513d3642d6143cd4880937f2c022a0621c70d
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-04-04 13:52:53 +02:00
Volker Hilsheimer
1c44eb8e16 QGIM: implement moveRows
Change-Id: I55cab809cd23ccc2d6ccfb9167df81fd510acbb6
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-04 13:52:53 +02:00
Piotr Wiercinski
8f65024d84 wasm: Add support for contrastPreference detection to WASM theme
Task-number: QTBUG-133596
Change-Id: I4482fe5a3457579867bd870cb2c8d371dd08e1a0
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2025-04-04 13:52:53 +02:00
Eike Ziller
9302945ce3 CMake: Add .js files to Source Files source group
In addition to .qml files

Pick-to: 6.9
Change-Id: I8df7fd9bc997b888213b14c9de8b8d29ea536c1e
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-04-04 10:59:34 +00:00
Eike Ziller
f302a312dc CMake: Do not limit source_group creation to Xcode and VS
source_group is used by various IDEs, including Qt Creator,
so it makes sense to do that for other generators too.

Amends 06ea3e3994b38e5fe9ac4f33044b0efa1f1be294

Pick-to: 6.9
Change-Id: I32334d658ea5a74a9e5f2a7fab2c1f531c099901
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-04-04 10:59:34 +00:00
Even Oscar Andersen
6ead92b459 wasm: a11y - Add handling of LocationChanged
Fixes: QTBUG-134585
Change-Id: Ib82ee6f59b7b2ca16ad4d84980cbd27ba13b6dd0
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-04-04 07:55:49 +02:00
Artem Dyomin
29115f0d7c QGIM: simplify constant for one-dimensional ranges
Introduce constant that we can check against directly rather than
comparing repeatedly against 0.

Change-Id: I717a5c3684d855f83ac28655b3fc2fc011b49865
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-04 06:45:40 +02:00
Artem Dyomin
b6782d148c QGIM: whitespace fixes
Change-Id: Ib832f1ba7edcd4beec95c6dbe0965a4af02961f0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-04 06:45:40 +02:00
Giuseppe D'Angelo
a99d73c53a qCheckedFPConversionToInteger: streamline the checks
Use the same algorithm as convertToDouble. We don't really need
convertToDouble, as we plan to truncate anyhow (convertToDouble returns
`false` if truncation caused loss of precision, so we can't use it to
distinguish an out-of-bounds value), and these are debug-only checks.

Change-Id: I70d70c05ce3f4996bd74361e6f78c02064232a57
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-04 06:00:19 +02:00
Giuseppe D'Angelo
07b8909360 QByteArray(View) comparisons: tame the overload set a bit
QByteArray declares comparison operators against QByteArrayView.
With the addition of the implicit conversion from QByteArray to
std::string_view, those comparison operators are now ambiguous
when comparing a QByteArray against a std::string_view. The
overload set contains:

1) QByteArray<=>QByteArrayView, after converting the string_view
   to a QByteArrayView
2) string_view<=>string_view, after converting the QByteArray to
   string_view.

This is part of the fallout of adding QByteArray->std::string_view
implicit conversions. We accepted the risk of SICs, and here they are.

The first operator should have never been added: comparing a QByteArray
to a QByteArrayView is already possible using QByteArrayView's own
comparison operators (QBAV<=>QBAV, after converting the QBA to it).
Therefore, this commit removes it.

The removal reveals two other problems:

1) there is a comparison defined between QByteArrayView and
const char *. That comparison makes comparing QByteArrayView and
QByteArray ambiguous, because QByteArray can convert to both
QByteArrayView (thus finding the QBAV<=>QBAV comparisosn) and to const
char * (thus finding the QBAV<=>const char * comparison).

Again, the latter overloads should have never been added: const char *
implicitly converts to QByteArrayView and therefore it's served by the
QBAV<=>QBAV comparison operators. This gets removed too.

2) comparisons between QByteArray and types convertible to
QByteArrayView (e.g. std::string) are no longer possible. These were
never meant to be supported: heterogeneous string comparisons must first
and foremost convert everything to a common view type
(...QAnyStringView?), and only then the comparison can proceed.

In general, we should aim at this setup:

1) Owning string classes should only have homogeneous comparisons. They
   might offer heterogeneous comparisons (say, QString <=> const char *)
   on a case-by-case basis. The must never declare comparisons against
   views (instead, view's own comparisons will take care of comparing
   an owning string agains a view!).  Comparing different owning string
   types directly is not meant to be supported (e.g. QString <=>
   std::u16_string), as per above.

2) Views only have homogeneous comparisons. Everything compatible will
   convert to the view type for the comparison. Again, exceptions on
   a case-by-case basis (e.g. QStringView<=>const char *, protected by
   the NO_ASCII macro / ASCII_WARN / etc.).

3) We do not support compare against views coming from other libraries
   (e.g. QByteArrayView<=>std::string_view). One always risks an
   ambiguity, since both convert to each other. SG16 has rejected ideas
   of a "string view protocol"; Qt view classes implicitly build from
   compatible ranges (which likely includes any other string view class
   out there), which makes it a magnet for these ambiguities (say
   against a 3rd party view class that also does the same).

This isn't a complete overhaul: there are still strings and views that
don't follow the above and this commit isn't changing them yet.

Fixes: QTBUG-134902
Change-Id: If181af1fb627490423ca1e467ecce7330f7445fb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-04 03:57:27 +02:00
Mårten Nordheim
2e61a7fc60 Moc: Propagate flags from aliases (Q_FLAG)
When creating the list of 'enums' to print into the moc file we
go through enums that have been defined and then we consult
aliases pointing to those names. If an alias is known we also
add this to the list. But we don't copy over the flags for the alias so
they have the exact same flags as the original enum.
In practice this is not a problem, the only flag it carries is
'EnumIsFlag' and we independently deduce this using the fact that it's
an alias.
It only really reveals itself in moc-output since we cannot
differentiate it from enum, so we print them all prefixed with an 'enum'
comment.

Change-Id: Iad055e69549ec1e854e1b5ac9992b035a4c343b4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-04-04 03:57:27 +02:00
Thiago Macieira
4cd66686e4 Add support for C23 standard attributes using __has_c_attribute()
The __has_cpp_attribute() refers to the attributes supported by the C++
language. GCC returns its knowledge of the C++ attribute in C, even when
the C code doesn't support it.

N2335[1] added the C++ attribute syntax to the C language and N2553[2] added
the __has_c_attribute() query syntax.

Known attributes:
From https://en.cppreference.com/w/c/language/attributes#Standard_attributes:
* [[deprecated]] (from N2334)
* [[fallthrough]] (from N2408)
* [[nodiscard]] (from N2267, with message in N2448)
* [[maybe_unused]] (from N2662)
* [[noreturn]] (from N2764, which also deprecates _Noreturn)

Drive-by remove C++11 & 14 support from [[nodiscard]]

[1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2335.pdf
[2] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2553.pdf

Pick-to: 6.9
Change-Id: Ifd32b2557683218e0d26fffd5b58dedf7911f77a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-04-03 18:13:59 -07:00
Marc Mutz
27ed0014b4 QTimer: restore BC with Qt 6.7 for MSVC
When I ported the QTimer::defaultTypeFor() helper from ms to ns
granularity, I failed to account for MSVC, in which inline functions
of exported classes are themselves exported.

As a consequence, the private QTimer::defaultTypeFor(milliseconds)
symbol went missing.

To fix, re-add it as REMOVED_SINCE API.

We don't need to play tricks with QT6_*_NEW_OVERLOAD here, since the
overloads have a different signature and the only callers¹ are either
passing an exact ms or ns argument² or are in dependent names in
templates³ which removed_api.cpp does not instantiate.

¹ this is a private function, so we don't need to look very far...
² the string-based singleShot() overloads
³ and so name lookup (and therefore overload resolution) happens only
  at instantiation time, not at template parse time (so Integrity and
  VxWorks compilers will, that is)

Amends a60e341145a3b8a106e556e17ae62d2f45ac5d74.

Pick-to: 6.9 6.8
Fixes: QTBUG-135578
Change-Id: I375e6f04a3af3824f980fe59775d3eea94250987
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-04 02:41:44 +02:00
Marc Mutz
cba8f19ff8 tst_QGraphicsGridLayout: fix memleak in spanningItem2x2()
The `form` graphics-widget has no parent and is not otherwise added to another
object that would take ownership of it, so it was leaked, together with its children.

To fix, simply create it on the stack. This is the minimally-invasive fix.
Had I held it in unique_ptr instead, I would have had to touch the line
creating `layout`, too. Creating it on the stack is simpler than make_unique(), so do that.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I4027dcb0c0650eb7556de96e6d1d20b98c14dc9a
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-04 02:41:44 +02:00
Marc Mutz
b518a385ad tst_QGraphicsGridLayout: fix memleaks in addItem()
Both `layout` and `wid` were created without parents, and not otherwise added to
objects that would take their ownership; only `layout` was explicitly deleted
at the end of the function, `wid` was leaked.

The usual solution, giving them a stack-allocated graphics-widget as
parent that will delete them, doesn't work here, because the layout
does refuse to add the widget in some test rows.

Since there are no checks in-between the allocation and de-allocation
(this test is only checking for expected warning messages), do the
minimal fix and explicitly delete `wid`, as it was already done for
`layout`.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I5c7356ac93c04d648eb31888105b480791fbe155
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-04 02:41:43 +02:00
Marc Mutz
fc89096bcb tst_QGraphicsGridLayout: remove unneeded delete in rowMaximumHeight()
The deleted 'widget' was added to a stack-allocated QGraphicsScene,
which owns it and will delete it as its child if it itself is deleted.

There's no check following the manual delete, and the test function's
name shows no indication that deleting graphics-widgets from a scene
in a show()n QGraphicsView is being tested here, so it serves no
purpose.

Remove it.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I4e5405cd6212d2a318a567d99ef42c99261d431a
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-04 02:41:43 +02:00
Marc Mutz
b9836518a3 tst_QGraphicsGridLayout: fix memory leaks in rowCount()
The populateLayoutWithSpansAndHoles() function adds parent-less
QGraphicsWidgets (RectItems) to the layout. If the layout had a
graphics-widget parent, it would reparent the items added to it onto
the parent. But it didn't, so it didn't.

Therefore, the last part of the test function (as denoted by the
re-creation of `layout`) leaked a lot of items, including `layout`.

To fix, give the layout the existing graphics-widget parent. Then the
layout itself isn't leaked anymore, either.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I063c0e3336d943a35592fa62a5d16cbddb6b920e
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-04 02:41:43 +02:00
Marc Mutz
5a559758d1 tst_QGraphicsGridLayout: fix memleaks in columnSpacing()
The populateLayout() function adds parent-less QGraphicsWidgets
(RectWidgets) to the layout. If the layout had a graphics-widget
parent, it would reparent them onto the parent. But it didn't, so it
didn't.

Therefore, the 2nd and 3rd part of the test function (as denoted by
the top-level scopes in the function) leaked a lot of items.

The first part of the function already used a widget, itself without
parent, but added to a QGraphicsScene allocated on the stack, so was
not leaking.

To fix, give the layouts a graphics-widget parent. Then the layout
doesn't need to be deleted anymore, either.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I7e63c51cf037818fb1e519dab5394ad75c74d67d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-04 02:41:43 +02:00
Marc Mutz
0840c4f1ab tst_QGraphicsGridLayout: fix memleaks in a few test functions
Namely task236367_maxSizeHint(), widthForHeight() and
heightForWidthWithSpanning().

These functions allocated a parent-less QGraphicsWidget on the heap,
and didn't delete it, leaking it.

Hold in unique_ptr instead. This is the minimally-invasive fix.

Amends the start of the public history.

Change-Id: I684c374f2dff14ec93cda87f49ae286fe9453cd9
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-04 02:41:43 +02:00
Marc Mutz
dceff0ace4 QDialogButtonBox: fix UB (invalid downcast) in Private::handleButtonShowAndHide()
The event filter was still active when the QDialogButtonBox in its
destruction process had already been demoted to QWidget. The
ignoreShowAndHide guard came too late, because by the time we check
it, in Private::handleButtonShowAndHide(), we had already cast q_ptr
to QDialogButtonBox.

Says UBSan:

  qdialogbuttonbox_p.h:26:5: runtime error: downcast of address 0x7fffefab47e0 which does not point to an object of type 'QDialogButtonBox'
  0x7fffefab47e0: note: object is of type 'QWidget'
   00 00 00 00  28 c1 5b 6e 6d 7f 00 00  80 22 10 00 90 61 00 00  d8 c2 5b 6e 6d 7f 00 00  00 00 00 00
                ^~~~~~~~~~~~~~~~~~~~~~~
                vptr for 'QWidget'
     #0 0x7f6d6b51141d in QDialogButtonBoxPrivate::q_func() qdialogbuttonbox_p.h:26
     #1 0x7f6d6b51141d in QDialogButtonBoxPrivate::handleButtonShowAndHide(QAbstractButton*, QEvent*) qdialogbuttonbox.cpp:913
     #2 0x7f6d6b51436c in eventFilter qdialogbuttonbox.cpp:127
     #3 0x7f6d40c1a8f1 in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) qcoreapplication.cpp:1248
     #4 0x7f6d690b23d5 in QApplicationPrivate::notify_helper(QObject*, QEvent*) qapplication.cpp:3303
     #5 0x7f6d69132a3a in QApplication::notify(QObject*, QEvent*) qapplication.cpp:3259
     #6 0x7f6d40c1da6a in QCoreApplication::notifyInternal2(QObject*, QEvent*) qcoreapplication.cpp:1111
     #7 0x7f6d40c20473 in QCoreApplication::sendEvent(QObject*, QEvent*) qcoreapplication.cpp:1551
     #8 0x7f6d690fe76c in QApplicationPrivate::setActiveWindow(QWidget*) qapplication.cpp:1857
     #9 0x7f6d695ac796 in QWidgetPrivate::deactivateWidgetCleanup() qwidget.cpp:2326
     #10 0x7f6d6976f8ce in QWidgetPrivate::hide_sys() qwidget.cpp:8256
     #11 0x7f6d69814579 in QWidgetPrivate::hide_helper() qwidget.cpp:8199
     #12 0x7f6d69887c1f in QWidgetPrivate::setVisible(bool) qwidget.cpp:8406
     #13 0x7f6d69775d23 in QWidget::setVisible(bool) qwidget.cpp:8314
     #14 0x7f6d695fb018 in QWidget::hide() qwidget.cpp:8179
     #15 0x7f6d6981a183 in QWidgetPrivate::handleClose(QWidgetPrivate::CloseMode) qwidget.cpp:8580
     #16 0x7f6d699e6fc6 in QWidgetWindow::closeEvent(QCloseEvent*) qwidgetwindow.cpp:871
     #17 0x7f6d52ef9f5d in QWindow::event(QEvent*) qwindow.cpp:2721
     #18 0x7f6d69a575f8 in QWidgetWindow::event(QEvent*) qwidgetwindow.cpp:398
     #19 0x7f6d690b2491 in QApplicationPrivate::notify_helper(QObject*, QEvent*) qapplication.cpp:3309
     #20 0x7f6d69132a3a in QApplication::notify(QObject*, QEvent*) qapplication.cpp:3259
     #21 0x7f6d40c1da6a in QCoreApplication::notifyInternal2(QObject*, QEvent*) qcoreapplication.cpp:1111
     #22 0x7f6d40c205b3 in QCoreApplication::sendSpontaneousEvent(QObject*, QEvent*) qcoreapplication.cpp:1565
     #23 0x7f6d5287415b in QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent*) qguiapplication.cpp:2911
     #24 0x7f6d528b543f in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) qguiapplication.cpp:2259
     #25 0x7f6d52fb5b02 in QWindowSystemEventHandler::sendEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) qwindowsysteminterface.cpp:190
     #26 0x7f6d52fb5b02 in bool QWindowSystemHelper<QWindowSystemInterface::SynchronousDelivery>::handleEvent<QWindowSystemInterfacePrivate::CloseEvent, QWindow*>(QWindow*) qwindowsysteminterface.cpp:102
     #27 0x7f6d52fb5b02 in handleWindowSystemEvent<QWindowSystemInterfacePrivate::CloseEvent, QWindowSystemInterface::SynchronousDelivery, QWindow*> qwindowsysteminterface.cpp:138
     #28 0x7f6d52fb5b02 in bool QWindowSystemInterface::handleCloseEvent<QWindowSystemInterface::SynchronousDelivery>(QWindow*) qwindowsysteminterface.cpp:351
     #29 0x7f6d52cb6f1e in QPlatformWindow::close() qplatformwindow.cpp:348
     #30 0x7f6d52e7e158 in QWindow::close() qwindow.cpp:2449
     #31 0x7f6d6981b4d2 in QWidgetPrivate::close() qwidget.cpp:8632
     #32 0x7f6d698205c6 in QWidget::~QWidget() qwidget.cpp:1508
     #33 0x7f6d6b4f6bf0 in QDialogButtonBox::~QDialogButtonBox() qdialogbuttonbox.cpp:496

To fix, don't delay the Q_Q to until after the ignoreShowAndHide
check, since that woould be brittle. Instead, do as we for signal/slot
connections, which we disconnect explicitly in ~QDialogButtonBox(),
and delete the EventFilter explicitly there, too. This way, it's more
natural, and also prevents all those useless event filter invocations
from having to be processed later on.

Amends aff0915352dda0cfaa11a249b665fbe47be21d69. The original code,
using QDialogButtonBox::eventFilter(), was not affected, since by the
time QDialogButtonBox was demoted to QWidget, QWidget::eventFilter(),
not QDialogButtonBox::eventFilter() would been invoked. Which just
goes to show that one needs to be very careful with delegating too
much responsibilites to the Private class, as it lives, fully derived,
until ~QWidget() executes.

Pick-to: 6.9 6.8 6.5
Change-Id: I04f36fd6d7d160932bfe1494fdff464786b85047
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-04 02:41:42 +02:00
Marc Mutz
af71de2036 tst_QMainWindow: fix unit'ed value in AddDockWidget
The constructors didn't initialize all fields, leading the
compiler-generated move contructor to read invalid enum values:

Says UBSan:

  tst_qmainwindow.cpp:1645:8: runtime error: load of value 32675, which is not a valid value for type 'Orientation'
    #0 0x55b1bd283e2e in AddDockWidget::AddDockWidget(AddDockWidget&&) tst_qmainwindow.cpp:1645
    [...]

  tst_qmainwindow.cpp:1645:8: runtime error: load of value 72, which is not a valid value for type 'DockWidgetArea'
    #0 0x55b1bd284024 in AddDockWidget::AddDockWidget(AddDockWidget&&) tst_qmainwindow.cpp:1645
    [...]

(ubsan does not direct uninitialized memory accesses directly).

Fix by vale-initalizing the two members. This is the most natural
initialization for these members: Given that the test passed even with
random data before, 0 is surely good enough.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I6fc0b2f79679fd0f69024066c1e66b4434a5ebe6
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-04-04 02:41:42 +02:00
Marc Mutz
b724c3708b tst_QDockWidget: split setFloating() test function
The test function contains two completely separate tests: The old
setFloating() method from a910daf52678469b7e595da5fe54aa09ba2373c3^,
and the additions of said commit, which don't reuse any objects of the
old function.

Turn the latter into a new test function, setFloatingReparenting(), to
help code readers understand that these two parts of the test function
have nothing in common.

Case in point: setFloating() is now ubsan+asan-clean while
setFloatingReparenting() inherits both asan and ubsan errors of the
old, combined function.

Amends a910daf52678469b7e595da5fe54aa09ba2373c3.

Pick-to: 6.9 6.8 6.5
Change-Id: Ib0d54d47e74d4c3b70637bef95fa81d4da83dd76
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-04 02:41:42 +02:00
Marc Mutz
2c67d47ea1 QDockWidget: fix UB (invalid member calls) in QDockAreaLayout::takeAt()
The process by which the QDockAreaLayout changes a QDockAreaLayoutInfo
from representing a QWidget that's being deleted to representing a
QPlaceholderItem involves the construction of the latter from the
former. If a QDockWidget is being deleted, however, at the time the
QDockAreaLayout notices, the ex-QDockWidget has been demoted to a
QObject, causing the calls to QWidget member functions to be UB:

Says UBSan:

  qdockarealayout.cpp:46:25: runtime error: member call on address 0x7ffe74a429d0 which does not point to an object of type 'QWidget'
  0x7ffe74a429d0: note: object is of type 'QObject'
   33 7f 00 00  c0 ea 73 6e 33 7f 00 00  00 12 00 00 70 61 00 00  40 cd 41 83 33 7f 00 00  00 00 00 00
                ^~~~~~~~~~~~~~~~~~~~~~~
                vptr for 'QObject'
    #0 0x7f339546e251 in QPlaceHolderItem::QPlaceHolderItem(QWidget*) qdockarealayout.cpp:46
    #1 0x7f33955169a8 in QDockAreaLayoutInfo::takeAt(int*, int) qdockarealayout.cpp:1780
    #2 0x7f3395517175 in QDockAreaLayout::takeAt(int*, int) qdockarealayout.cpp:3432
    #3 0x7f33959e38a8 in QMainWindowLayoutState::takeAt(int, int*) qmainwindowlayout.cpp:927
    #4 0x7f33959e38a8 in QMainWindowLayoutState::takeAt(int, int*) qmainwindowlayout.cpp:919
    #5 0x7f3395a42cdd in QMainWindowLayout::takeAt(int) qmainwindowlayout.cpp:2238
    #6 0x7f3393fae246 in removeWidgetRecursively qlayout.cpp:485
    #7 0x7f3393fb8300 in QLayout::widgetEvent(QEvent*) qlayout.cpp:544
    #8 0x7f3393bde28a in QApplicationPrivate::notify_helper(QObject*, QEvent*) qapplication.cpp:3298
    #9 0x7f3393c5f74a in QApplication::notify(QObject*, QEvent*) qapplication.cpp:3259
    #10 0x7f336b784ada in QCoreApplication::notifyInternal2(QObject*, QEvent*) qcoreapplication.cpp:1111
    #11 0x7f336b7874e3 in QCoreApplication::sendEvent(QObject*, QEvent*) qcoreapplication.cpp:1551
    #12 0x7f336bcc624a in QObjectPrivate::setParent_helper(QObject*) qobject.cpp:2271
    #13 0x7f336bccd76c in QObject::~QObject() qobject.cpp:1146
    #14 0x7f339434e126 in QWidget::~QWidget() qwidget.cpp:1584
    #15 0x7f33955b5815 in QDockWidget::~QDockWidget() qdockwidget.cpp:1362
    [...]

  qwidget.h:816:25: runtime error: member call on address 0x7ffe74a429d0 which does not point to an object of type 'QWidget'
  0x7ffe74a429d0: note: object is of type 'QObject'
   33 7f 00 00  c0 ea 73 6e 33 7f 00 00  00 12 00 00 70 61 00 00  40 cd 41 83 33 7f 00 00  00 00 00 00
                ^~~~~~~~~~~~~~~~~~~~~~~
                vptr for 'QObject'
    #0 0x7f339546e0bb in QWidget::isWindow() const qwidget.h:816
    #1 0x7f339546e0bb in QPlaceHolderItem::QPlaceHolderItem(QWidget*) qdockarealayout.cpp:47
    [... rest as above...]

Fix by dragging the setParent(nullptr) up into ~QDockWidget().

Ordinarily, that call happens only in ~QObject(). But that's what
caused the layout to react to the ChildRemoved element too late. When
doing it here, the dock widget is still itself, and all the
QDockAreaLayout machinery can still access its QWidget-ness.

Amends the start of the public history.

After consulting with QtWidgets maintainer, not picking to 5.15,
since, even though slim, there's a non-zero chance this might break
something, somewhere.

Pick-to: 6.9 6.8 6.5
Change-Id: I5472bbb0fcab9fb74272a1da6c2a2896226e12bb
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-04-04 00:41:42 +00:00
Thibaut Cuvelier
6cfd7944bf Implement \tabs for DocBook
The existing implementation only works for online HTML and the
workaround generates nonsensical DocBook that not a single processor
could parse.

This implementation is not ideal, but gives enough information for
processors to do their job (i.e. the tab title and contents are uniquely
linked, the tabs in a group are related). Unaware processors still
render useful information to the user thanks to links.

The ideal presentation would use a container such as `formalgroup` for
the tabs, but there is no notion of tab in DocBook.

The missing part in this patch is allowing all uses of tabs with DocBook; they are still guarded by `\if defined(onlinedocs)`.

For instance, this change updates `porting-to-ios.xml` from:

```xml
<db:listitem…>
<db:para>If your application uses imports or plugins that depend on special Qt modules, these Qt modules should be added to your build configuration file. For example, if your application uses the Qt Multimedia import in QML, you should add the following to your .pro or CMakeLists.txt file: </db:para>
<db:section xml:id="using-cmake">
<db:title>Using CMake</db:title>
<db:programlisting language="cpp" role="bad">find_package(Qt6 REQUIRED COMPONENTS Multimedia)
target_link_libraries(my_project PRIVATE Qt6::Multimedia)
</db:programlisting>
</db:section>
<db:section xml:id="using-qmake">
<db:title>Using qmake</db:title>
<db:programlisting language="cpp" role="bad">QT += multimedia
</db:programlisting>
<db:para>In Qt for iOS, everything is compiled statically and placed into the application bundle. The applications are &quot;sandboxed&quot; inside their bundles and cannot make use of shared object files. Because of this, also the plugins used by the Qt modules need to be statically linked. To do this, define the required plugins using the <db:link xlink:href="qmake-variable-reference.xml#qtplugin">QTPLUGIN</db:link> variable.</db:para>
</db:section>
```

to:

```xml
<db:listitem…>
<db:para>If your application uses imports or plugins that depend on special Qt modules, these Qt modules should be added to your build configuration file. For example, if your application uses the Qt Multimedia import in QML, you should add the following to your .pro or CMakeLists.txt file: </db:para>
<db:bridgehead xml:id="tab-cmake" renderas="sect5" role="tabbed checked tab-group_build-ios-app" xlink:href="#tab-cmake_contents">CMake</db:bridgehead>
<db:bridgehead xml:id="tab-qmake" renderas="sect5" role="tabbed checked tab-group_build-ios-app" xlink:href="#tab-qmake_contents">qake</db:bridgehead>
<db:sidebar xml:id="tab-cmake_contents">
<db:programlisting language="cpp" role="bad">find_package(Qt6 REQUIRED COMPONENTS Multimedia)
  target_link_libraries(my_project PRIVATE Qt6::Multimedia)
</db:programlisting>
</db:sidebar>
<db:sidebar xml:id="tab-qmake_contents">
<db:programlisting language="cpp" role="bad">QT += multimedia
</db:programlisting>
</db:sidebar>
```

Change-Id: I63f3e8d03a5f4ee52e7c67971d14d4497dd78cb8
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2025-04-03 21:39:13 +00:00
Giuseppe D'Angelo
fcde9f13d9 QVariant: fix assert in FP->int conversions
The newly introduced asserts in qRound make QVariant FP->int conversions
crash. The crash is legitimate, because the conversion has UB. However
we've historically supported these conversions with a somehow specific
(albeit undocumented) behavior; I'm trying to keep it as accurately as
possible, based on testing on x86-64. (I have no idea if the behavior
was actually different elsewhere. Formally there's no "behavior" to
talk about here.)

Specifically: use "saturation rounding" towards qint64, and then convert
the result to the target type. This can be done by using the private
qSaturateRound function, which however needs to be extended to 64 bits.

This extension revealed an implementation problem: using qBound to clamp
the result of the rounding is inaccurate for certain combination of
input and output types (e.g. double to qint64), because the maximal
value can't be correctly represented in floating point.  Use a better
algorithm instead.

Finally, I'm making NaN *fail* the conversion (and return 0). I don't
think there's any other sensible alternative here. I'm not sure of the
pre-existing behavior of the code across different architectures and
using different encodings for NaN, and it sounds extremely brittle to do
something else instead.

Fixes: QTBUG-135285
Change-Id: Ia5f54094807210d0dbbdbb9a0a4f3a0f18ea3d80
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-03 22:40:55 +02:00
Volker Hilsheimer
07804a83c4 QGIM: support move-only row types
A move-only type can be used as the row if the container of the rows
can be populated via insert from another container. This is the case for
the standard containers, but not for e.g. QList.

If an insert(pos, start, end) overload is available, then use that also
in the moveRows() implementation to move the data over.

The only limitation now is that we cannot assign a complete row type as
data of an item, as we cannot get a move-only value out of a const
QVariant.

Change-Id: Icea66ed82c601fd819f7db2eca2f8e023d8aa7c2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-04-03 21:55:00 +02:00
Ivan Solovev
046b8523f2 QXmlStreamReader: check appending data with unexpected encoding
If we add the first part of the XML document using a QBA overload of
the constructor or addData() method, the encoding of the document will
be extracted from the "encoding" attribute of the XML prolog.

This way, if the encoding is different from UTF-8, appending the data
with the QASV overload of addData() will always result in reading the
data incorrectly, because the implementation converts the input data
to UTF-8.

This test explicitly highlights this behavior.
In some cases the current behavior is probably fine. However, cases
like appending Latin1 to Latin1-encoded document or appending UTF-16
to UTF-16-encoded document should just work instead of doing the
unwanted conversion to UTF-8 and failing.

Task-number: QTBUG-124636
Task-number: QTBUG-135129
Pick-to: 6.9 6.8 6.5
Change-Id: Idf0571083e56032145478631538f09d251cb1022
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-04-03 21:54:59 +02:00
Ivan Solovev
633278fe1c QXmlStreamReader: fix parsing of non-wellformed inputs
The tst_QXmlStream::runTestSuite() had two issues which resulted
in non-wellformed files not being checked in the incremental
parsing mode.

The first issue is that the TestSuiteHandler::endElement()
function calls isWellformed() twice with two different modes,
passing a pointer to a previously opened QFile to both calls.
As a result, the first call uses ParseSinglePass mode, which reads
the entire file at once. After that, the second call with
ParseIncrementally mode already uses a file which has
atEnd() == true. So, the call to readAll() simply returns an empty
QByteArray. So, the ParseIncrementally test was effectively a no-op.

This commit fixes it by explicitly calling seek(0) at the beginning
of the isWellformed() function and also changing the type of the
input parameter to be a QFile pointer instead of QIODevice pointer,
to make sure that seek(0) actually makes sense.

After that issue was solved, I noticed that in the incremental mode
the algorithm that was feeding the data to QXmlStreamReader
byte-by-byte was always skipping the first character (and also
reading past the end of the buffer). As a result, all the XML files
parsed in this mode were malformed.

This was fixed by moving the increment of the index after the
addData() call.

Finally, after these two things were fixed, six test cases from the
XML test suite started to fail, because the non-wellformed files
were incorrectly reported as well-formed.

Fix it by using StreamEOF instead of 0 in
QXmlStreamReaderPrivate::fastScanContentCharList().

The test case fixes amend the beginning of the public history.

The parser fix amends 817800ad39df10ca78e2c965a61d4d2025df622b
which introduced StreamEOF instead of 0.

Fixes: QTBUG-135471
Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I885166252d40819a4460ec246db10bf448e4a8e2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-03 21:54:59 +02:00
Mårten Nordheim
541ff8e15c Re-enable some TextBoundaryFinder test data
As part of updating UCD for Unicode 16 there was a need to support this
data anyway.

Task-number: QTBUG-121907
Pick-to: 6.9 6.8
Change-Id: I1d58a856de9b2aaff28917bd067914227bcffd9d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-03 20:29:45 +01:00
Laszlo Agocs
15eeb3f511 Fix -no-pch build
Amends 589bfddc7c44a92e7e3f98a1e73871793c153ab7

Avoid "'QObject': base class undefined" errors with MSVC when
configured with -no-pch by adding the missing include.

Change-Id: I80b0a0ab705f4466fc1d94da253b26ba3ab31779
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-04-03 20:00:13 +02:00
Alexandru Croitor
a20f281212 CMake: Fix CMP0177 warnings by adjusting qt_join_path
INSTALL_DATADIR and INSTALL_ARCHDATADIR have the value "." by default.

CMP0177 in CMake 3.31 now warns when paths that have "." as a
component are passed to install().

To avoid the warning, change the implementation of qt_path_join, to
filter out "." components.

That way all install() calls that build up their paths via
qt_path_join() will avoid the warning.

Pick-to: 6.8 6.9
Change-Id: Ib82aa9fe6b5d32e374e8b1acf05402312b6dbe1a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-04-03 20:00:13 +02:00
Joerg Bornemann
4422480260 CMake: Make the plugandpaint example runnable without installation
The extrafilters DLL must be placed in the plugins directory to be
found. The QMake build is correct in that regard.

Change-Id: Ic1652e008148f3dfa36558b82d8bc8ddb08c1e99
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2025-04-03 20:00:13 +02:00
Emir SARI
bfb7a47e13 QPrintPreviewDialog: Improve i18n for percent value
This fixes the initial percent value being in the wrong format
for languages that have a different format set. Also enables
locale-aware decimals separator.

Change-Id: I77db487635284e58ed47ed3807fe4390d8d97123
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-04-03 19:18:50 +03:00
Tuomas Vaarala
1e10ede244 Replace qFatal() statements with qWarning() in case of failed queries
In some cases the QNX events can be stale ie. referring to a window
object that is already destroyed. This is not necessarily a fatal
condition, but there are some qFatal() statements in this case which
could be removed.

Fixes: QTBUG-135076
Pick-to: 5.15 6.5 6.8 6.9
Change-Id: I885fa95c323590a814176b8a70ef5b7ee332012c
Reviewed-by: James McDonnell <jmcdonnell@blackberry.com>
2025-04-03 16:18:50 +00:00
Even Oscar Andersen
45f6785078 wasm: a11y - enable accessibility by environment variable
If QT_WASM_ENABLE_ACCESSIBILITY is set to "1" when the application
starts, accessibility is enabled right away.

Change-Id: I5b0118dc8ae19f446c64be33fe3c03b45c5b4527
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-04-03 15:19:26 +02:00
Tor Arne Vestbø
1085143208 Replace variable length array in qt_mac_draw_pattern with QVarLengthArray
Pick-to: 6.9 6.8
Change-Id: I1869ba14cdddb23cd903013fb6d160e24ac72967
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2025-04-03 11:41:06 +02:00
Alexey Edelev
a42fbfba26 Skip the tst_QSettings::testRegistryShortRootNames
The test is failing on aarch64 VM, when attempt reading
QSettings::childGroups for HKEY_CLASSES_ROOT. The returned list
contain precending '*'(astersk) node, which disappears at the second
call.

Task-number: QTBUG-135470
Change-Id: Ia8bb4c90d504353bb4e699a8133d63e7bae7afb3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-03 11:40:45 +02:00
Axel Spoerl
23357e59bb QMainWindowLayout: Fix leaking of unused tab bars
QMainWindowLayout::unusedTabBars contains unparented tab bars.
They are leaked when QMainWindow and its layout get destroyed.
They still are in QApplication::allWidgets(), which attempts to delete
them eventually. When that happens, they try to remove themselves from
an already deleted QMainWindowLayout::unusedTabBars.

Delete all unused tab bars in the d'tor of QMainWindowLayout.

Task-number: QTBUG-135468
Pick-to: 6.9 6.8 6.5
Change-Id: I5ac7748ef738955522567db585e9505e3ba435ad
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-03 11:15:41 +02:00
Volker Hilsheimer
1bbbacbecb QDockWidget: don't access a QMainWindow that's under destruction
Amends b6b489db6968fbc3b4aab3755d0166ee09712ff0, which introduced UB
(invalid downcast):

By the time the
QMainWindowTabBars are destroyed, and they want to unregister
themselves from the QMainWindow, the ex-QMainWindow has already been
demoted to a QWidget. Says UBSan:

  qmainwindow.cpp:63:47: runtime error: member call on address 0x6040000267d0 which does not point to an object of type 'QMainWindow'
  0x6040000267d0: note: object is of type 'QWidget'
   00 00 00 00  28 c1 e6 f3 c7 7f 00 00  80 24 00 00 60 61 00 00  d8 c2 e6 f3 c7 7f 00 00  00 00 be be
                ^~~~~~~~~~~~~~~~~~~~~~~
                vptr for 'QWidget'
    #0 0x7fc7f06da8c5 in QMainWindowPrivate::mainWindowLayout(QMainWindow const*) qmainwindow.cpp:63
    #1 0x7fc7f06da8c5 in qt_mainwindow_layout(QMainWindow const*) qmainwindow.cpp:69
    #2 0x7fc7f07bb4ed in QMainWindowTabBar::~QMainWindowTabBar() qmainwindowlayout.cpp:2042
    #3 0x7fc7f07bf4e5 in QMainWindowTabBar::~QMainWindowTabBar() qmainwindowlayout.cpp:2047
    #4 0x7fc7c69f9c2a in QObjectPrivate::deleteChildren() qobject.cpp:2226
    #5 0x7fc7ef0b7f3d in QWidget::~QWidget() qwidget.cpp:1557
    #6 0x7fc7f082c7c7 in QDockWidgetGroupWindow::~QDockWidgetGroupWindow() qmainwindowlayout_p.h:343
    #7 0x7fc7f082c7c7 in QDockWidgetGroupWindow::~QDockWidgetGroupWindow() qmainwindowlayout_p.h:343
    #8 0x7fc7c69f9c2a in QObjectPrivate::deleteChildren() qobject.cpp:2226
    #9 0x7fc7ef0b7f3d in QWidget::~QWidget() qwidget.cpp:1557
    #10 0x7fc7f06ce495 in QMainWindow::~QMainWindow() qmainwindow.cpp:338
    #12 0x556a6180a84c in std::default_delete<QMainWindow>::operator()(QMainWindow*) const unique_ptr.h:85
    #13 0x556a6180a84c in std::unique_ptr<QMainWindow, std::default_delete<QMainWindow> >::~unique_ptr() unique_ptr.h:361
    #14 0x556a6180a84c in tst_QDockWidget::setFloatingReparenting() tst_qdockwidget.cpp:492

Use qobject_cast to verify that the mainWindow is not pointing to a
QMainWindow that is being destroyed (and has passed the ~QMainWindow
destructor). If the main window is destroyed, then removing the tab bar
from the list of unused tab bars is unnecessary.

Pick-to: 6.9 6.8 6.5
Change-Id: I25e12d79198137b75cd2576ff1440b6c94277eba
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-03 11:15:37 +02:00
Mitch Curtis
55f163382d Refactor default QTRY_* timeout value into one place
Move it into a global static, so that we can allow changing it in a
follow-up commit.

Task-number: QTBUG-81979
Change-Id: I795002054f9aa7781157739b94fc2b85bcb61705
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-04-03 09:43:35 +08:00
Volker Hilsheimer
0ae202c2a7 QGIM: override sibling() to avoid the roundtrip through parent()
Change-Id: I91bc8d3e94d35fb30bc4886ba6be554ca7cf866b
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-04-02 21:12:50 +02:00
Axel Spoerl
4b198c5e64 QXcbIntergration: Fix build w/o DBus
Don't include QKdeTheme when Qt is built w/o DBus.

Change-Id: Iefa16ace1fbac2cad1fb964bfaecbe3e4f309f25
Found-by: juha.vuolle@qt.io
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2025-04-02 20:33:10 +02:00
Edward Welbourne
6faf5f2bbc Remove a test based on a mythical transition
Although timeanddate.com does claim Berlin was on double summer-time,
the IANA DB doesn't believe in it and the test itself found the text's
date-time to be valid, despite a comment claiming we expect it to be
invalid (which, these days, we wouldn't - it'd be corrected).

Change-Id: I726b28725da976a28410754681ae840e03b15b53
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-02 16:42:30 +02:00
Edward Welbourne
79a1986e86 Add a reproducer tests for an assertion failure
The fix [*] means this already passes on dev; and the belated pick to
6.8 should get there before this does (it landed before 6.9, so did
not need picked there).

[*] commit 5d656e5085303bd427a4e8564818c65ec1d0ac26

On 6.8, without the fix, the ISODate test passes (that's handled by a
sui generis parser) but all three of the fromStringFormat tests of
QDate, and the QDatetime exact reproducer from the bug report, provoke
assertion failures.

Task-number: QTBUG-135382
Pick-to: 6.9 6.8
Change-Id: I303df9215873e37a9f2cbf5a78aab8ffa48f67aa
Reviewed-by: Albert Astals Cid <aacid@kde.org>
2025-04-02 16:42:26 +02:00
David Faure
b4d6892ba5 QTestLib: fix crashes when using qDebug()s from threads with -junitxml
Other test loggers just output things immediately, but the junit test
logger appends messages to a vector, so this needs to be
mutex-protected.

In case of qDebug()s from long-running threads, we also need
to protect creation/destruction of systemOutputElement and
systemErrorElement -- and in case of qFatal(), currentTestCase.

Pick-to: 6.9 6.8 6.5
Change-Id: If35055fc232276a778951ebbfeaccd185b04f46b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Jason McDonald <macadder1@gmail.com>
2025-04-02 15:41:17 +01:00
Marc Mutz
e2790a6758 tst_QComboBox: fix popupPositionAfterStyleChange() FAIL on Kubuntu 20.04
On my machine, the window manager opened the QComboBox always at y = 0
(top edge of the screen), where the popup, being confined to the
screen geometry, had no chance of "open[ing] up centered on top of the
current index".

Fix by centering the widget on screen.

Amends 8393922e7071221a9c6c0811eb714f20bf4ed02b.

Pick-to: 6.9 6.8 6.5
Change-Id: I7b4d066aa1e555f3d5cc1d5e0c88b1d835bf2b26
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-02 16:38:31 +02:00
Marc Mutz
e5f11eebc8 QAbstractItemView: disconnect from the correct delegate
Purely from a symmetry argument, we should be disconnecting the old
item delegate, not the new one.

I didn't find a case where this actually causes test failures, nor did
I take the time to implement a test where it does.

Amends a126d3627cc347500c1a6bd82027efa6d451ccbd. That patch landed in
Qt 6.7, but that branch is "closed" at this point in time, so not
picking there now.

Pick-to: 6.9 6.8
Change-Id: I06b704e699616d61c65ad676ffe45dfbd9f8a870
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-02 14:38:21 +00:00
Marc Mutz
e55479ea4a tst_QComboBox: ignore two warnings from setCompleter() in getSetCheck()
Tidies up the test output by removing expected warnings from the log
(and alerting us if they're missing).

Amends 64f6169f61ce8c982a1b92b20f930518a5f0d477, which introduced the
warning.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Idcef99d556b11035307e6e207cf31fc2f13ed291
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-04-02 14:38:10 +00:00
Marc Mutz
00fdf9e432 QComboBox: fix UB (signed overflow) in Private::recomputeSizeHint()
The minimumContentsLength() is user-settable, and tst_QComboBox
actually sets it to INT_MAX as some point. As such, the implementation
needs to defend itself from UB, either by limiting what values it
accepts as minimumContentsLength() or by making sure it doesn't cause
signed overflow in calculations involving this user-controlled
variable.

The former doesn't really work as long as the test checks that INT_MAX
is accepted as-is, so we need to do the latter.

Do the calculation in qint64, and use the result only when it doesn't
exceeed good old QWIDGETSIZE_MAX.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I8aac7bda593095638c9c09db3b70b4c84e698419
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-02 16:38:01 +02:00
Marc Mutz
d884591391 tst_QComboBox: fix memleak in task_QTBUG_56693_itemFontFromModel()
QProxyStyle's ctor arguments are not QObject parents, but the proxied
style, which becomes the proxy's QObject ... get this ... _child_.

What a broken concept... It means that this test function took
ownership of QApplication::style(), and the only way it wasn't going
to wreak havoc on the rest of the test functions was to leak it after
use.

To fix, create the style on the stack, so it gets automatically freed
by the compiler on all exists from the function. As a drive-by, use {}
instead of () to call the ctor (not to prevent C++' Most Vexing Parse,
just because it's easier on the eye).

The meat of the change, however, is in making the helper proxy-style
defend against QProxyStyle's grabbing of the baseStyle() as its child,
and managing baseStyle()->d->proxyStyle so we properly dissociate from
qApp->style() after we're done. Needed to use ctor delegation to
extract original parent and proxy model from the incoming style before
QProxyStyle, our first subobject, gets first picking on the style,
destroying the very state we're trying to preserve.

This should be become some QTest::LocalProxyStyle, if we find more
users of this pattern.

Amends 5cff7d2b679d48a247b4630cb9e3d5b04fab0b55.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I2abf4a0bf54158254fd8d526de55ad486ca4e296
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-02 16:37:47 +02:00
Marc Mutz
27279e01d2 tst_QComboBox: fix memleaks in task_QTBUG_52027_mapCompleterIndex()
Both the QCompleter and the QSortFilterProxy objects are not owned by
the QComboBox merely by setting them as completer and model. Having no
other QObject parents, and having being allocated on the heap, they
were leaked.

To fix, give them the combo-box as QObject parent.

Amends 8b6d6d4832ea8ed5f9857d5ddf06408ee9d0b4e0.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I5c3594272a5283a3fbaeb9885d315047b04f30de
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-02 16:37:40 +02:00
Marc Mutz
c41592c900 tst_QComboBox: fix memleak in task190205_setModelAdjustToContents()
A QComboBox does not own the model set on it, because models can be in
many views at once. So the QStringListModel, allocated on the heap
without a QObject parent was leaked.

Fix by giving the model the combo-box as QObject parent.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Idd9057c8f796937d9d3c5c4ef99b329124d2192d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-02 16:37:30 +02:00
Marc Mutz
fda3526f9c tst_QComboBox: fix memleaks in setItemDelegate()/task253944_itemDelegateIsReset()
QItemDelegates are owned by neither the QComboBox directly, nor the
QComboBox::view(), upon a mere setItemDelegate() (the docs of this
function is pretty clear about that). Since the objects didn't have a
QObject parent, either, they were leaked.

To fix, give it the comboBox as a parent.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Ic8bc2603072070b458bd79a6129af6c76811f8ec
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-02 16:37:21 +02:00
Marc Mutz
0de7cafabc tst_QComboBox: fix memleak in getSetCheck()
Contrary to what the code comment suggested, a QComboBox does not own
the object passed in by setItemDelegate(). After a nullptr check, the
function merely forwards to QComboBox::view()->setItemDelegate() and
QAbstractItemView::setItemDelegate() documents very clearly that the
item delegate ownership does not change. Consequently, the test
function leaked the object.

To fix, hold it in a unique_ptr and reset() at the end of the code
block.

I opted to not merely comment in the delete there, because that would
still leak in case one of the QCOMPARE()s in-between failed. While it
is not the purpose of the current work to make tests leak-free even on
failure, it likewise makes little sense to not reap this small benefit
now, albeit at the cost of a bit of git history mess-up, itself
mediated by the fact that we're picking this all the way back, since
this...

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I1e604b795f5a12dc8829bf5913b88bc7c7110352
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-02 16:37:12 +02:00
Marc Mutz
bf62a9762b QLineEdit: fix UB (invalid downcast) in Private::removeAction()
QLineEdit remembers whether a QWidget size-widget came from a
QWidgetAction or is just one of its own QLineEditIconButtons. On
removal of the action, if QWidgetAction, it will ask the action to
deal with its widget, calling QWidgetAction::releaseWidget(),
otherwise it just deletes the QLineEditIconButton itself.

This is fine if the action is being removed from the line edit, but
not immediately deleted. But if the action is being deleted while its
widget is still in a QLineEdit, then the QLineEdit is informed of this
only by ~QAction(), at which point the QWidgetAction has ceased to
exist and the cast, in QLineEditPrivate::removeAction(), to
QWidgetAction is UB.

Says UBSan:

  qlineedit_p.cpp:656:10: runtime error: downcast of address 0x6020000c3950 which does not point to an object of type 'QWidgetAction'
   0x6020000c3950: note: object is of type 'QAction'
    00 00 00 00  70 57 49 81 3d 7f 00 00  80 bc 0c 00 50 61 00 00  03 02 00 00 10 00 00 00  a6 01 00 71
                 ^~~~~~~~~~~~~~~~~~~~~~~
                 vptr for 'QAction'
    #0 0x7f3d93910686 in QLineEditPrivate::removeAction(QAction*) qlineedit_p.cpp:656
    #1 0x7f3d938b44bc in QLineEdit::event(QEvent*) qlineedit.cpp:1469
    #2 0x7f3d91c50211 in QApplicationPrivate::notify_helper(QObject*, QEvent*) qapplication.cpp:3309
    #3 0x7f3d91cd160a in QApplication::notify(QObject*, QEvent*) qapplication.cpp:3259
    #4 0x7f3d697f6ada in QCoreApplication::notifyInternal2(QObject*, QEvent*) qcoreapplication.cpp:1111
    #5 0x7f3d697f94e3 in QCoreApplication::sendEvent(QObject*, QEvent*) qcoreapplication.cpp:1551
    #6 0x7f3d92345199 in QWidget::removeAction(QAction*) qwidget.cpp:3215
    #7 0x7f3d92e47202 in QtWidgetsActionPrivate::destroy() qaction_widgets.cpp:35
    #8 0x7f3d7f75d5fb in QAction::~QAction() qaction.cpp:451
    #9 0x7f3d92e4cc76 in QWidgetAction::~QWidgetAction() qwidgetaction.cpp:94
    #10 0x7f3d92e4e965 in QWidgetAction::~QWidgetAction() qwidgetaction.cpp:94
    #11 0x558c993da3b0 in tst_QLineEdit::sideWidgets() tst_qlineedit.cpp:4693

To fix, check the dynamic type of the action (using qobject_cast)
before calling QWidgetAction::releaseWidget(). If the cast fails, the
QWidgetAction will have dealt with the widget itself, in its own dtor,
so QLineEdit needn't do anything.

Unfortunately, fixing this centrally by just dragging destroy() down
from ~QAction() to ~QWidgetAction() causes use-after-free in other
test functions of tst_QLineEdit, so I deciced to fix this at the
QLineEdit level only.

Amends 9ce12cc8de940cdd450a28f4bd079acfc3621aa3.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I3c514dbd1f1a4e1510df3dd9ac67b4bab50e63e9
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-02 16:36:57 +02:00
Marc Mutz
73fc32af14 tst_QTextEdit: fix UB (invalid downcast) in various functions
The test uses the old-but-invalid trick of inheriting from a class X
to gain access to its private or protected parts, but then just
casting an object of dynamic type X to the newly derived class. This
is invalid, because the object is not actually of the newly-derived
type.

Says UBSan (excerpt):

  tst_qtextedit.cpp:2273:5: runtime error: downcast of address 0x60400013c190 which does not point to an object of type 'PublicTextEdit'
  0x60400013c190: note: object is of type 'QTextEdit'
   00 00 00 00  70 bc 57 df b1 7f 00 00  80 66 30 00 90 61 00 00  70 be 57 df b1 7f 00 00  00 00 be be
                ^~~~~~~~~~~~~~~~~~~~~~~
                vptr for 'QTextEdit'

To fix, make QTextEdit befriend tst_QTextEdit. This is how we do it
elsewhere, too. Then remove the now-unused PublicTextEdit helper.

Amends the start of the public history, and, in one function,
56f0ebfe860e440dcbba8997f44836debc901119 (which is only in Qt 6.4+, so
the cherry-pick to 5.15 will have to drop the part in pasteFromMarkdown().

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I967238d84cae0f6dd8f05d0afb7a318292d96415
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-02 16:36:51 +02:00
Marc Mutz
de2de7e12c tst_QTextEdit: fix memleak in the MyPaintDevice helper
The constructor new'ed up a MyPaintEngine, but there was no destructor
to delete the object again. Neither is ownership of the engine
transferred out of the class, so the object was leaked.

Fix by holding it in a unique_ptr.

Amends 391e3aeef45efc937979b44c32147206e389a60b.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I0c4da10d5a1659eceac0deba32cac757579e46c5
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-04-02 16:36:45 +02:00
Marc Mutz
dd264cc9c0 QGraphicsView: remove (last remaining?) user of QEvent::op=
Instead of aggregating a QMutableSinglePointEvent by value, which
depends on the QEvent copy assignment operator, and casting it to a
QMouseEvent that it isn't, introduce QEventStorage which is a bit like
std::optional, but, by each event subclass befriending it, can store
event copies by-value, unlike clone(), which is restricted to the
heap. We could have befriended std::optional<QMouseEvent>, too, but by
adding our own type in _p.h, we can better control which code uses
this dangerous construct.

Added a guard to avoid clobbering lastMouseEvent with a copy of itself
in storeMouseEvent(). Before, we'd self-assign to lastMouseEvent,
which didn't invalidate the reference. Now, a store() is the
equivalent of a dtor + copy constructor, so we need to be a bit more
careful.

Fixes UBSan reports when running tst_qgraphicsview:

  qgraphicsview/qgraphicsview.cpp:612:27: runtime error: downcast of address 0x61a000035e90 which does not point to an object of type 'QMouseEvent'
   0x61a000035e90: note: object is of type 'QMutableSinglePointEvent'
    00 00 00 00  30 47 ef 8b 99 7f 00 00  02 00 00 00 00 00 00 e0  d0 91 00 00 20 60 00 00  00 00 00 00
                 ^~~~~~~~~~~~~~~~~~~~~~~
                 vptr for 'QMutableSinglePointEvent'
       #0 0x7f99a27c7a47 in QGraphicsViewPrivate::replayLastMouseEvent() qgraphicsview.cpp:612

  qgraphicsview.cpp:653:39: runtime error: member call on address 0x61a0000fe290 which does not point to an object of type 'QMouseEvent'
   0x61a0000fe290: note: object is of type 'QMutableSinglePointEvent'
    00 00 00 00  30 47 ef 8b 99 7f 00 00  05 00 00 00 00 00 00 e0  d0 91 00 00 20 60 00 00  00 00 00 00
                 ^~~~~~~~~~~~~~~~~~~~~~~
                 vptr for 'QMutableSinglePointEvent'
       #0 0x7f99a27c3609 in QGraphicsViewPrivate::mouseMoveEventHandler(QMouseEvent*) qgraphicsview.cpp:653
       #1 0x7f99a27c7832 in QGraphicsViewPrivate::replayLastMouseEvent() qgraphicsview.cpp:612

  qgraphicsview.cpp:654:37: runtime error: member call on address 0x61a0000fe290 which does not point to an object of type 'QMouseEvent'
   0x61a0000fe290: note: object is of type 'QMutableSinglePointEvent'
    00 00 00 00  30 47 ef 8b 99 7f 00 00  05 00 00 00 00 00 00 e0  d0 91 00 00 20 60 00 00  00 00 00 00
                 ^~~~~~~~~~~~~~~~~~~~~~~
                 vptr for 'QMutableSinglePointEvent'
       #0 0x7f99a27c358b in QGraphicsViewPrivate::mouseMoveEventHandler(QMouseEvent*) qgraphicsview.cpp:654
       #1 0x7f99a27c7832 in QGraphicsViewPrivate::replayLastMouseEvent() qgraphicsview.cpp:612

Pick-to: 6.9
Task-number: QTBUG-99563
Change-Id: Ib642d416b8aef98c7fd8b1fa164ec2449189992a
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2025-04-02 15:36:33 +01:00
Joerg Bornemann
e07b4d4394 Doc: Fix the example for qt_generate_deploy_script
The EXECUTABLE argument must point to the full path of the created
executable, not just the file name. Otherwise,
qt_deploy_runtime_dependencies won't file the file.

Pick-to: 6.8 6.9
Change-Id: I18b6214b9f46c0ad4b99ca57468fe272efb9d718
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-04-02 16:23:01 +02:00
Even Oscar Andersen
363f7000c5 wasm: a11y - Add call to setActive
There are various tests for this within the accessibility system.
Without it, it is not consistent what works and what does not work.

Task-number: QTBUG-134657
Change-Id: Idfa8905f377e2ef00a4d1af26cbf001064bc75dc
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-04-02 15:22:51 +01:00
Volker Hilsheimer
c99816b033 QGIM: add support for tree data structures
QAbstractItemModel represents a table of tables where each item can
have an entire table-hierarchy as children. In practice, it is enough
to support a hierarchy of rows: that's what our views can display,
and what users are familiar with.

With this limitation, a data structure represents a tree if it's
possible to traverse that hierarchy. For each row, we need to be
able to navigate to the parent row (which might be nil if the row
is a top-level row), and get the (optional) list of children.
To enable this, we introduce a protocol type that QGIM can be
instantiated with, either explicitly or implicitly.

An explicit protocol provides implementations for parentRow and
childRows. Const overloads are mandatory, mutable overloads are
optional and allow modifying the tree structure as well. A
modifyable tree might in addition need to create a row object, as
new rows have to be hooked up with parent and child relationships.
And a tree must be able to destroy row objects as well when rows
are removed.

An implicit protocol means that the row type implements this
protocol through member functions. We detect this at compile time
and implement tree support for ranges with an appropriate row
type.

This implements a first ownership model as well: if the range was
moved into the model, then the owner of the model cannot/must not
do anything with the container anymore, so also cannot delete the
rows. We have to do so. Detect that we are operating on a moved-in
container, and delete all rows if so.

To make the code more readable, use explicitly named types for the
implementation of the model structure, with dedicated and clearly
constrained QGIM constructors.

Change-Id: Iaf19c27da6ec8604923ec7c0c2523c7d62edee50
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-04-02 11:08:51 +02:00
Volker Hilsheimer
efe41182fd Corelib snippets: make widgets optional
Amends f5115a913738aef2ee37b880c2e7275f1045b8ae.

Fixes: QTBUG-135397
Change-Id: Ic36e462779bf32429dba85aa50d4a0955993d990
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-04-02 11:08:49 +02:00
Ahmad Samir
095e6fd084 QCryptographicHash: use switch statements with the Algorithm enum
To benefit from -Wswitch compiler flag, requested by Marc in code
review.

Define supportsAlgorithm() twice, with/without USING_OPENSSL, amends
9248d0cfbee0805d670f4b6b07bd3bf4003d6263.

Pick-to: 6.9
Change-Id: I236093532196689bc0828131360dfeeb24fac23f
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-04-02 03:11:58 +02:00
Ahmad Samir
a3813abd40 QCryptographicHash: remove QT_CRYPTOGRAPHICHASH_ONLY_SHA1
It was added in 44cb71d6fdb0b7285d4ef74a1ef778323aa9e5ee to reduce the
size of the bootstrap lib.

Since commit c7f64d84fbd9b5b3cac41c1d81dc4d0479fc3fa1 removed
QCryptographicHash from the bootstrap lib, the macro is now
redundant (unless it's used by QtLite).

Change-Id: I5459a52507bc9e0a7b982b4382211be9a23c4ad9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-02 03:11:58 +02:00
Marc Mutz
c6c2a0bf37 tst_QMetaType: fix UB (nullptr passed to memcmp()) in selfCompare()
QMetaType::Void is not constructible, so create() will return nullptr,
and even though sizeOf() returns 0, calling memcmp() is still UB in
that case.

Fix by guarding the memcmp() from QMetaType::Void.

Amends a59e7361714d50687d82a2d9abae9e95825a23b6.

Pick-to: 6.9 6.8 6.5
Change-Id: I55896826e6c0cad5d77e9d0ab861efa9a32f780f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-02 00:30:12 +02:00
Albert Astals Cid
0475bc57d6 Improve macos tabs accessbility support
Map PageTabList controls (i.e. QTabBar) to the TabGroup role, and
report the list of PageTabs as the tabs. Add a predicate-argument
to the unignoredChildren() function so that we can re-use that
logic to return the list of tabs, while also ignoring otherwise
accessible children, such as the scroll buttons.

Change-Id: I57472e9213dd178e018449e542de276051097073
Fixes: QTBUG-134807
Pick-to: 6.9 6.8
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-01 23:21:55 +02:00
Tor Arne Vestbø
420db269fe Remove dead QT_EXPERIMENTAL_CLIENT_DECORATIONS code
Change-Id: I841f483b368d3f2740828f8933b91898f6a4d453
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-04-01 16:14:03 +02:00
Tor Arne Vestbø
589bfddc7c Teach QWinRegistryKey to observe changes to the key
In some cases there are no explicit notification APIs for
changes to system settings, and the developer is expected
to observe changes to the registry keys directly.

For example this applies to color profile associations, as
documented in:

 https://learn.microsoft.com/en-us/windows/win32/wcs/wcs-registry-keys

Change-Id: I3507058d90b1d32b8b5256f40861126277242cd6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-01 15:14:01 +01:00
Volker Hilsheimer
e88940941f macOS a11y: clean up ignore-logic
Replace an if-chain with a switch statement, and remove the duplicate
test for QAccessible::Client - we already ignore all such elements,
no matter their special role name.

Compare an object's className as a QByteArrayView, no need to expand to
a UTF16 QString just to compare with a Latin1 literal.

Pick-to: 6.9 6.8
Change-Id: I79f52277e4177f2a688216b7f5ef7469cfe0534c
Reviewed-by: Albert Astals Cid <aacid@kde.org>
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2025-04-01 16:13:59 +02:00
Tim Blechmann
eb6042f915 QLinuxFbIntegration: silence -Wunused-private-field
when configured without `evdev`, clang emits -Wunused-private-field

Pick-to: 6.8 6.9
Change-Id: Ia4ff59c002c1a00ef1b445520c28db0d932ee564
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-04-01 08:17:29 +00:00
Tor Arne Vestbø
9d39aa260d Windows: Remove support for QT_QPA_VERBOSE logging environment variable
We have QT_LOGGING_RULES nowadays, and the verbosity levels for
QWindowsContext are controlled by the `verbose` platform plugin
argument.

Change-Id: I3f998afaa962220b7babb093c030d0798e450db0
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Reviewed-by: Zhao Yuhang <2546789017@qq.com>
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2025-04-01 02:41:23 +01:00
Tor Arne Vestbø
ae19b13c7d Add QWinRegistryKey::name() and debug operator
Helps debugging to know which key you're working with, if
all you have is a QWinRegistryKey instance.

Change-Id: I09aa2d997871ff46c455ee0d1a566d858163d19e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-04-01 02:41:23 +01:00
Tor Arne Vestbø
4ae41c225b Use QLastCursorPosition to check for missing cursor position
After c5792dcfd631abb4f9e2b92cd6e88d7e5c373406 the last cursor position
is reflected as a QPoint(std::numeric_limits<int>::max(), ...), and
after 209a2145f94e99f99832c3a08cdf579d8f42ca55 as 1 << 23. Instead of
hard coding the sentinel value, let's use QLastCursorPosition directly.

Pick-to: 6.9 6.8 6.5
Change-Id: I24031f3cc800d2f0028eb95f4f8597019cc945c0
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2025-03-31 23:15:45 +02:00
Thiago Macieira
4afd089612 QLoggingCategory: make defaultCategory() truly a global static
We don't need two independent Q_GLOBAL_STATIC variables: one for the
default category and the other for the logging registry. We can simply
save one in the other.

However, we can do better than even that. QLoggingCategory currently
doesn't hold any allocated resources: the const char *name points to a
static string and the void *d is always null. That means the constructor
and destructor only serve to register and unregister the category with
QLoggingRegistry, so we transfer that responsibility to QLoggingRegistry
itself (the un-registering is implicit in the registry's own
destruction).

The benefit of this is that the default QLoggingCategory can never be
found in a destroyed state, however late user code may be running after
::exit() was called. We have had a number of these issues of
De-Initialization Order Fiasco, especially since the changes to
QThreadData destruction timing.

Pick-to: 6.9
Change-Id: I2b6ea597ac257837669afffde2684c7b44a42e92
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-03-31 17:04:13 -04:00
Thiago Macieira
51c8c06951 tst_QLoggingRegistry: reinitialize the rules after modifying the env
Don't assume that this call to QLoggingRegistry::instance() was the
first in the test application's execution.

Change-Id: Ia2d32ed7c4d930bef30efffd0b7d38a536b95772
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-03-31 17:04:13 -04:00
Thiago Macieira
d5a8339f65 tst_QLoggingRegistry: don't create a new QLoggingRegistry
The class assumes it's a singleton.

Change-Id: I81901b5bfd0008f58bf5fffda82da4179589a7cb
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-03-31 17:04:13 -04:00
Christian Ehrlicher
219e9fe7a2 SQL/MySQL: use utc datetime in formatValue()
We store timestamps as utc in the database but QSqlDriver::formatValue()
does not format the datetime string as utc. Fix it by converting the
datetime object to utc first.
This amends 2781c3b6248fe4410a7afffd41bad72d8567fc95

Pick-to: 6.9 6.8
Fixes: QTBUG-135135
Change-Id: Id26b251e9ed9800d6caff7f43de25fd9e9b08f43
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-31 20:40:12 +02:00
Christian Ehrlicher
06ef995a7d QSqlError: rename ctor parameter to 'nativeErrorCode'
Rename the parameter 'code' to 'nativeErrorCode' to match the getter
nativeErrorCode() with the ctor's parameters.

Pick-to: 6.9 6.8
Change-Id: Ic95b45c75a57796536d845249c719b5d0d0e7587
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-31 18:40:12 +00:00
Christian Ehrlicher
75c896f9b1 Windows11Style: Honor sort indicator size in headerview
The windows11 style, in contrast to the windows vista style, draws the
indicator on the side. Therefore call QWindowsStyle::sizeHint() for
CT_HeaderSection as the base style has the correct implementation.

Pick-to: 6.9 6.8
Fixes: QTBUG-135338
Change-Id: If84f72f9f26e87617ecebb1a01f448219d8656ba
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2025-03-31 18:40:11 +00:00
David Faure
9e32306dae QTestLib: fix race on QElapsedTimers from WatchDog thread
The WatchDog thread calls printTestRunTime() which reads the two
timers, created and started in the main thread.

Pick-to: 6.9 6.8 6.5
Change-Id: I1a337648fddf87190075b7902311544d0ab21ac3
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-31 19:40:11 +01:00
Ahmad Samir
4fd7d31e09 QDirIterator: next() should return empty string after reaching the end
Amends c7691842f743f568a073582c8f0cacd6ee188f98, and actually fixes the
other half of QTBUG-130142.

Fix the unittest, it was wrong to begin with, iterating over an empty
string with NoDotAndDotDot, next() will always return an empty string
because `currentFileInfo` has never been initialized.

Pick-to: 6.9 6.8
Fixes: QTBUG-135287
Task-number: QTBUG-130142
Change-Id: I9966428c7a143803e6e934b5970ea6b6afc8a08f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-31 20:01:18 +02:00
Ahmad Samir
bbe79a3b98 QDirIterator: add note about always calling hasNext()
... before using next/nextFileInfo(). That's both more logical and
safer; this is analogous to always checking `iterator != end` before
using said iterator.

Change-Id: I87583f645087d34fc3e76e77f1ac168f76b6868e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-31 20:01:18 +02:00
Ahmad Samir
a6fc30f69d Revert "QDirIterator: clarify the docs wrt. calling hasNext() before next()"
This reverts commit c83304af27b403c9ebe64d4c768da25e04acafc1.

The original behavior is going to be finally restored by the next
commits in this chain.

Task-number: QTBUG-135287
Change-Id: Iae38d5d9271a77da9d9b1c938ccc73c7531d89d5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-31 20:01:18 +02:00
Ivan Solovev
c877930dce A11Y: Wrap generated D-Bus proxies into a custom namespace
Commit 351b7a31aa24a704dba09121d91cb34190892315 added a new feature of
wrapping the generated D-Bus proxies into custom namespaces. Use this
feature to avoid potential clashes with the proxies generated by other
modules (see QTBUG-133553 as an example).

Amends 38251c36edf11316a2467169b1d491bf13520fd3, but keeping it only
in dev because it depends on the new feature of qdbusxml2cpp.

Task-number: QTBUG-134305
Change-Id: I585cdda3f002ef7fa6dd3a76a3b4f2c9c68d2297
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-03-31 19:01:18 +01:00
Thiago Macieira
aa87214864 tst_QUuid: make big-endian runs not fail
As far as I can tell, QUuid is working correctly on big endian
platforms. But it stores the integers in such a weird fashion (I wish to
fix that for Qt 7) that this test is non-obvious.

I don't have a big-endian machine to test this with. Anyone interested
is welcome to submit patches.

Fixes: QTBUG-134634
Pick-to: 6.8 6.9
Change-Id: I2415be976d1d880d1525fffdf525dcf4f21aaa70
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2025-03-31 10:59:43 -07:00
Tor Arne Vestbø
6a465729be cmake: Respect CMAKE_MACOSX_BUNDLE and CMAKE_WIN32_EXECUTABLE
The user may set different global defaults for CMAKE_MACOSX_BUNDLE
and CMAKE_WIN32_EXECUTABLE, so we shouldn't unconditionally override
them on a target level.

This allows cmake ~/foo/ -DCMAKE_MACOSX_BUNDLE=ON to build a project
as a GUI app without needing to modify the CMakeLists.txt with target
specific overrides.

Change-Id: Id49adb1c0aedfe82a2b1d919d086c5112ba92b93
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-31 17:29:48 +02:00
Vlad Zahorodnii
6580ad906a Client: Reset mFrameCallbackTimedOut when showing a window
When a window is hidden, the corresponding expose event is sent
asynchronously. So, a buffer (and a frame callback) can be attached
after the window is hidden.

QWaylandWindow::initWindow() handles that case by attaching a nil buffer
to the surface, but it skips resetting the frame callback things.

If mFrameCallbackTimedOut is not reset, then the window can get stuck
in the unexposed state and not show up after the second setVisible(true).

This change makes the initWindow() function also reset frame callback
data. It fixes some windows not showing up after remapping them.

Pick-to: 6.9
Change-Id: I8952ffed24844c73721c4f689786146c317e014d
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-03-31 13:31:45 +03:00
Joni Poikelin
80d680e82f Call xcrun from PATH
The xcrun binary may be installed in a different location when cross
compiling to macOS using osxcross.

Change-Id: I47398e8da19c42e5e9d1b595673048c56662ea2e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-31 10:29:03 +00:00
Juha Vuolle
b145f23770 Yield a configuration error with -no-feature-desktopservices
Yield a configuration error with -no-feature-desktopservices
if the platform is either Apple or Android. This should be clearer
than a compiler error later on, and also occurs earlier in the
process.

Pick-to: 6.9 6.8
Fixes: QTBUG-135152
Change-Id: I5dfb9eda12472ed9359767f17423fda63d208d9c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-03-31 12:04:37 +02:00
Juha Vuolle
90c90d5071 Put qxmlstreamreader code behind its feature-flag
Missed feature guards from:
- QXmlStreamReaderPrivate class declaration
- QXmlStreamWriter::writeCurrentToken definition [*]

[*] Function takes in a qxmlstreamreader. The declaration
of the function already had the necessary feature guard.

Pick-to: 6.9 6.8
Fixes: QTBUG-135230
Change-Id: I78741bc75a6baa8bc86ec5ce7d34a4333d8bdad4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-03-31 12:04:37 +02:00
Juha Vuolle
33df53bf32 Fix qprocess.h include guards to match QProcess usage
Fixes: QTBUG-135225
Pick-to: 6.9 6.8
Change-Id: I64077ffaccc4f3b864c08df02b489857ac82f34b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-31 12:04:37 +02:00
Eskil Abrahamsen Blomfeldt
11620f97f6 Fix possible crash in FontConfig database
In the FontConfig font database, when we registered alternative
names for the same font, we would just copy the existing user
data (the FontFile struct) from the original font.

However, this did not account for the fact that registerFont()
may in some cases delete fonts from the database if they are
being overwritten, which will also delete the user data.
Therefore the existing FontFile struct is not guaranteed to
be valid once the font database has taken ownership.

This was pre-existing, but it started happening on some
systems after 1d6f71779f05df1af3daacd48f309cd92523152a because
this change will cause some fonts to be seen as identical
which were not before.

Pick-to: 6.8 6.9
Fixes: QTBUG-135264
Change-Id: I913bf13dc8069d952a4cdc5fa5544594be1cdba1
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-03-31 07:21:58 +01:00
Vlad Zahorodnii
727e115a81 Client: Notify about exposure changes when popup is repositioned
QXdgSurface::Popup::setWindowPosition() changes the exposed state, but
it doesn't call QWindowSystemInterface::handleExposeEvent() to notify
the QGuiApplication layer about it.

For example, this can result in the QMenu unexpectedly repainting with
the new size even though QtWayland still waits for the reposition
request to be completed.

xdg_popup_repositioned doesn't need to call updateExposure() because
it is going to be followed by a configure event and
QWaylandXdgSurface::applyConfigure() already updates the exposed state.

Pick-to: 6.9
Change-Id: Ia0435e2cd1a0d39e0edac61beb4c0d761314c1d6
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-03-31 07:27:58 +02:00
Michael Weghorn
0ca934b923 GnomeTheme: Add missing QtDBus includes
This fixes the following build error seen in a local
-no-pch Clang 19 build:

    [1677/16903] Building CXX object qtbase/src/gui/CMakeFiles/Gui.dir/platform/unix/qgnometheme.cpp.o
    FAILED: qtbase/src/gui/CMakeFiles/Gui.dir/platform/unix/qgnometheme.cpp.o
    /usr/bin/ccache /usr/bin/clang++ -DENABLE_PIXMAN_DRAWHELPERS -DGui_EXPORTS -DMD4C_USE_UTF8 -DQT_ASCII_CAST_WARNINGS -DQT_BUILDING_QT -DQT_BUILD_GUI_LIB -DQT_CORE_LIB -DQT_DBUS_LIB -DQT_DEPRECATED_WARNINGS -DQT_EXPLICIT_QFILE_CONSTRUCTION_FROM_PATH -DQT_LEAN_HEADERS=1 -DQT_MOC_COMPAT -DQT_NO_CAST_TO_ASCII -DQT_NO_CONTEXTLESS_CONNECT -DQT_NO_EXCEPTIONS -DQT_NO_FOREACH -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_QASCONST -DQT_NO_QEXCHANGE -DQT_NO_QSNPRINTF -DQT_NO_STD_FORMAT_SUPPORT -DQT_NO_USING_NAMESPACE -DQT_QPA_DEFAULT_PLATFORM_NAME=\"xcb\" -DQT_STRICT_QLIST_ITERATORS -DQT_USE_NODISCARD_FILE_OPEN -DQT_USE_QSTRINGBUILDER -D_GLIBCXX_ASSERTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I/home/michi/development/git/qt5/qtbase/src/gui/Gui_autogen/include -I/home/michi/development/git/qt5/qtbase/include -I/home/michi/development/git/qt5/qtbase/include/QtGui -I/home/michi/development/git/qt5/qtbase/src/gui -I/home/michi/development/git/qt5/qtbase/src/gui/../3rdparty/VulkanMemoryAllocator -I/home/michi/development/git/qt5/qtbase/src/gui/../3rdparty/D3D12MemoryAllocator -I/home/michi/development/git/qt5/qtbase/include/QtGui/6.10.0 -I/home/michi/development/git/qt5/qtbase/include/QtGui/6.10.0/QtGui -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/libmount -I/usr/include/blkid -I/home/michi/development/git/qt5/qtbase/src/gui/../3rdparty/md4c -I/home/michi/development/git/qt5/qtbase/include/QtCore -I/home/michi/development/git/qt5/qtbase/mkspecs/linux-clang -I/home/michi/development/git/qt5/qtbase/src/corelib -I/home/michi/development/git/qt5/qtbase/include/QtCore/6.10.0 -I/home/michi/development/git/qt5/qtbase/include/QtCore/6.10.0/QtCore -I/home/michi/development/git/qt5/qtbase/include/QtDBus -isystem /usr/include/glib-2.0 -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include -isystem /usr/include/sysprof-6 -isystem /usr/include/harfbuzz -isystem /usr/include/freetype2 -isystem /usr/include/libpng16 -D_GLIBCXX_DEBUG -g -std=gnu++17 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -fPIC -Werror "-Wno-error=#warnings" -Wno-error=deprecated-declarations -Wno-error=deprecated-enum-enum-conversion -Wno-error=deprecated-copy-with-user-provided-copy -Wno-error=unused-but-set-variable -fcf-protection=full -ftrivial-auto-var-init=pattern -fstack-protector-strong -fno-exceptions -pthread -MD -MT qtbase/src/gui/CMakeFiles/Gui.dir/platform/unix/qgnometheme.cpp.o -MF qtbase/src/gui/CMakeFiles/Gui.dir/platform/unix/qgnometheme.cpp.o.d -o qtbase/src/gui/CMakeFiles/Gui.dir/platform/unix/qgnometheme.cpp.o -c /home/michi/development/git/qt5/qtbase/src/gui/platform/unix/qgnometheme.cpp
    /home/michi/development/git/qt5/qtbase/src/gui/platform/unix/qgnometheme.cpp:41:32: error: incomplete type 'QDBusMessage' named in nested name specifier
       41 |         QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.portal.Desktop"),
          |                                ^~~~~~~~~~~~~~
    /home/michi/development/git/qt5/qtbase/src/dbus/qdbusconnection.h:34:7: note: forward declaration of 'QDBusMessage'
       34 | class QDBusMessage;
          |       ^
    /home/michi/development/git/qt5/qtbase/src/gui/platform/unix/qgnometheme.cpp:41:22: error: variable has incomplete type 'QDBusMessage'
       41 |         QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.portal.Desktop"),
          |                      ^
    /home/michi/development/git/qt5/qtbase/src/dbus/qdbusconnection.h:34:7: note: forward declaration of 'QDBusMessage'
       34 | class QDBusMessage;
          |       ^
    /home/michi/development/git/qt5/qtbase/src/gui/platform/unix/qgnometheme.cpp:47:9: error: no template named 'QDBusReply'
       47 |         QDBusReply<QVariant> reply = dbus.call(message);
          |         ^
    /home/michi/development/git/qt5/qtbase/src/gui/platform/unix/qgnometheme.cpp:66:9: error: unknown type name 'QDBusPendingCallWatcher'; did you mean 'QDBusPendingCall'?
       66 |         QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(dbus.asyncCall(message));
          |         ^~~~~~~~~~~~~~~~~~~~~~~
          |         QDBusPendingCall
    /home/michi/development/git/qt5/qtbase/src/dbus/qdbusconnection.h:35:7: note: 'QDBusPendingCall' declared here
       35 | class QDBusPendingCall;
          |       ^
    /home/michi/development/git/qt5/qtbase/src/gui/platform/unix/qgnometheme.cpp:66:48: error: unknown type name 'QDBusPendingCallWatcher'; did you mean 'QDBusPendingCall'?
       66 |         QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(dbus.asyncCall(message));
          |                                                ^~~~~~~~~~~~~~~~~~~~~~~
          |                                                QDBusPendingCall
    /home/michi/development/git/qt5/qtbase/src/dbus/qdbusconnection.h:35:7: note: 'QDBusPendingCall' declared here
       35 | class QDBusPendingCall;
          |       ^
    /home/michi/development/git/qt5/qtbase/src/gui/platform/unix/qgnometheme.cpp:66:48: error: allocation of incomplete type 'QDBusPendingCall'
       66 |         QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(dbus.asyncCall(message));
          |                                                ^~~~~~~~~~~~~~~~~~~~~~~
    /home/michi/development/git/qt5/qtbase/src/dbus/qdbusconnection.h:35:7: note: forward declaration of 'QDBusPendingCall'
       35 | class QDBusPendingCall;
    ...

Change-Id: I40bc994f7af3dd5a314d051018991d81087844b4
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-30 19:33:04 +01:00
Artem Dyomin
7803e6c000 QGIM: support range provided in a std::reference_wrapper
std::reference_wrapper is a good option for explicitly passing
a reference to the model range. Some users, who don't like
raw pointers, may prefer explicit semantics like
QGIM(std::ref(myModel)) instead of passing a raw ptr.

Change-Id: I28df0842d78365c980a3edea6883a3819a1c0c33
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-30 18:11:51 +02:00
Christian Ehrlicher
c833ed5711 Tests/QSqlDriver: move cleanup tables into own function
Move the cleanup of the temporary tables into an own function and call them during init and cleanup. this makes sure the tables are
 - deleted on clean exit
 - not there during init when cleanup was not run (e.g. due to debugging or a crash).

Pick-to: 6.9 6.8
Change-Id: I9013a26b0166d0756a37f0a5d50ed825adf63868
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-30 00:27:03 +00:00
Magdalena Stojek
d2258328e3 Clarify QDomProcessingInstruction docs regarding XML declaration
The documentation now explicitly explains that the XML declaration is
not a processing instruction according to the XML 1.0 Specification and
the W3C DOM Level 1/2 Core specifications. It advises against using
createProcessingInstruction() to insert an XML declaration and
recommends QXmlStreamWriter.
This clarification aims to reduce confusion caused by the similar syntax
of processing instructions and the XML declaration.

Fixes: QTBUG-21166
Pick-to: 6.9 6.8 6.5
Change-Id: I630e0e73bc8e4b6f145cb1e771a0a6fec54543cf
Reviewed-by: Safiyyah Moosa <safiyyah.moosa@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-03-29 20:10:29 +01:00
Mårten Nordheim
56bfb02587 QStorageInfo: Fix namespace issue
We have a copy of the FS_INFORMATION_CLASS enum, but it's inside
the QT_BEGIN/END_NAMESPACE macros, move it out so it's compatible with
MinGW's header where it's already defined (and not inside our
namespace.)

Change-Id: I0dddd167275a01ace55cd5e76e54da973fd0510d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Zhao Yuhang <2546789017@qq.com>
2025-03-29 19:50:24 +01:00
Thiago Macieira
7bf9beb300 QRhiD3D11: fix qHash() to use qHashMulti()
The old code used XOR to combine hash values, but XOR is a bad combiner,
since it's mixing the bits insufficiently (XORing the same value again
will e.g. undo the original change).

This is a private class, so there are no users outside of Qt that would
have inlined this qHash() function; therefore, we are free to change the
algorithm.

Pick-to: 6.9
Change-Id: I7970e52ef4bd3b6a2248fffda0d4d75eb4afdf5a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-29 18:50:24 +00:00
Thiago Macieira
de90f2e064 QThread/Doc: improve docs on running, finished, and the OS thread
And take the opportunity to explain that the finished() signal does not
indicate the end of the operating system thread. Indeed, on some OSes,
not even wait() can be sure of that: for Unix systems, see the docs at
the top of qthread_unix.cpp about timed pthread_joins.

Pick-to: 6.9 6.8
Fixes: QTBUG-135163
Change-Id: Ie00a742f0707f57c767bfffd44bdaec40df05e4a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
2025-03-29 11:50:23 -07:00
Giuseppe D'Angelo
771466b9e7 qfloat16: remove noexcept from qRound
These functions have narrow contracts since they return integer types.
Passing infinities or NaN is illegal, therefore they can't be noexcept.
The qRound overloads for float/double in fact aren't noexcept.

Change-Id: Id41c166bc296fd11fc10a31ceab640f55868570e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-03-29 15:52:58 +01:00
Thiago Macieira
729a6f56d0 forkfd: fix build with FreeBSD 14.2: convertForkfdWaitFlagsToWaitFlags()
The FreeBSD-specific pdfork() code in forkfd_freebsd.c code was failing
to build because convertForkfdWaitFlagsToWaitFlags() wasn't
defined. That function is behind a check for #ifdef HAVE_WAITID, which
is only defined if _POSIX_VERSION is 2008 or later. That macro has been
stuck at 2001 for the past 23 years. I can't explain how this code
compiled with FreeBSD 14.1 and earlier, because I am sure it was using
pdfork().

So just #define HAVE_WAITID for FreeBSD. It must have been there since
much earlier than 13.0, but that seems like a reasonable starting point
today.

We also need to #include <sys/param.h> to have the __FreeBSD_version__
macro, something that also wasn't needed in earlier versions. It was
probably indirectly #include'd by something.

Pick-to: 6.8 6.9
Change-Id: I262d9922128d046221b7fffd0ec481bc0012f55c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2025-03-29 14:50:31 +00:00
Matthias Rauter
355e0d85eb Remove debug flag from benchmark
If debug symbols are needed, then pass the respective flag to the
configure script.

Pick-to: 6.9 6.8
Change-Id: I99db92bdd5b7eb896e0d592117a8f218467a4bd7
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-29 11:02:46 +00:00
Marc Mutz
76e76afb83 tst_QGraphicsWidget: fix memleak in qgraphicswidget()
The QGraphicsWidget `parent` didn't have a parent itself, and the test
function neglected to delete the object manually, leaking it.

To fix, allocate it on the stack.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Ie9814655c1a52b6dc0d15076eca591fe710d51ae
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-29 08:20:57 +01:00
Marc Mutz
235fe36de7 tst_QGraphicsWidget: remove unused object from qgraphicswidget()
The QGraphicsScene object wasn't used, so can be removed.

Make it so.

Seems to amend the start of the public history (and if there was a
user that has since been removed, we'll get a compile error, so no
need to data-mine the git history further).

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I9eeacde057ee5681ea86c185b66dff618a6f364e
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-29 08:20:45 +01:00
Marc Mutz
92c1413c08 tst_QGraphicsWidget: fix memleak in shortcutsDeletion()
The QGraphicsWidget didn't have a parent, and wasn't deleted by the
test function, so it leaked.

To fix, hold it in unique_ptr. While we're at it, and so that it
doesn't look too out of place, also hold the other parent-less
QGraphicsWidget in a unique_ptr.

The action, OTOH, has a parent, so we don't need to change something
there.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I0597b7ecd293ac54981df9e276c38c385ac811c7
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-29 08:20:33 +01:00
Marc Mutz
f0a9b5b6f1 tst_QGraphicsWidget: fix memleak in setStyle()
The result of QStyleFactory::create() is owned by the caller, and this
test function neglected to delete it, leaking the object.

To fix, reset() it, once created, into a unique_ptr. This is the
minimally0-invasive fix.

Amends 9bc49b0bca361646aac90cd00706588d3dcd66c9.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I17fae174b93bd27e2cac6e5e2d2c8a4ac2de703e
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-29 08:20:24 +01:00
Marc Mutz
dbfcd54155 tst_QGraphicsWidget: remove unneeded casts in setStyle()
`fstyle` is already a QStyle*, so casting it to QStyle* is unneeded.

Amends 9bc49b0bca361646aac90cd00706588d3dcd66c9.

And 0 is a valid nullptr value, so we don't need to cast there,
either.

Amends the start of the public history.

Drive-by port to nullptr.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: If763b8bf42de9d8bbe988ac76773d02bb7a2b68b
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-29 08:20:09 +01:00
Marc Mutz
156bd55923 tst_QGraphicsWidget: fix memleak in implicitMouseGrabber()
If a QGraphicsItem is removed from a QGraphicsScene, it also gets
un-parent-ed, and the caller of removeItem() is responsible for
deleting the item henceforth. The test function neglected that,
leaking the object.

To fix, use a scope-guard to defer deletion of the object to the exit
from the test function. This is the minimally-invasive fix.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Ie4f9be232674bba583f4a59908e42de096930136
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-29 08:19:59 +01:00
Marc Mutz
bfd852c502 tst_QGraphicsProxyWidget: fix memleak in forwardTouchEvent()
The result of QTest::createTouchDevice() needs to be deleted by the
caller. The test function didn't, so leaked the object.

Fix by holding it in unique_ptr.

Amends 982b70d37db337b2c57a3cfce0f24c3d00a598d6, even though the code
that this patch replaced looked leaky, too.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I3c7dfab31dc6ab364195381352d98fbd9c730990
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-29 08:19:46 +01:00
Marc Mutz
01ee8fd7b5 tst_QGraphicsProxyWidget: fix memleak in touchEventPropagation()
The result of QTest::createTouchDevice() needs to be deleted by the
caller. The test function didn't, so leaked the object.

Fix by holding it in unique_ptr.

Amends 1ecf2212fae176b78c9951a37df9e33eb24d4f2d.

Not picking to 5.15, because the cherry-pick of
1ecf2212fae176b78c9951a37df9e33eb24d4f2d to 5.15 was abandoned.

Pick-to: 6.9 6.8 6.5
Change-Id: I649357466a51e02d669b114bdfa0746bfa09fe34
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-29 08:19:32 +01:00
Marc Mutz
0665ae81fb tst_QGraphicsLinearLayout: fix memory leaks in removeAt()/removeItem()
Like in other test functions in this class, the QGraphicsWidgets were
leaked. So the solution is the same: hold them in a QVLA.

Also like in other test functions, the child layouts _are_ owned by
the parent layout, so were not leaked.

There's a twist here, though: we're removing layout items, which may
be widgets _or_ layouts. The old code deleted the removed layout item,
but we can't do that anymore, since it may be one of the widgets that
are owned by the QVLA, and that would cause a double-delete. If we
don't delete the removed item at all anymore, though, we'd leak it
when it was a layout.

So hold the layouts in QVLA, too. _Then_ we don't need to delete the
removed item anymore.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I16c61eb18f2843ceb72a432db1bd9be29e258bfd
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-29 08:19:22 +01:00
Marc Mutz
59b18d07e7 tst_QGraphicsLinearLayout: remove remaining memleaks in insertItem()
After the QGraphicsWidgets have been dealt with in a previous commit,
the last leak in the function is that of 'item'.

Fix by holding it in a unique_ptr.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I56986139a2b7865cf367bdd25ccde90d5e1c50ca
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-29 08:19:13 +01:00
Marc Mutz
8914732708 tst_QGraphicsLinearLayout: remove dead code (dump())
This test function hasn't tested anything since the start of the
public history, and leaks memory (the QGraphicsWidgets).

The dump() function, while implemented, doesn't do anything by default
(#ifdef'ed out), so there's no point in adding actual dump() calls
here, either.

Remove this function as dead code.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I6d9d224945fab0f97db0c5ea7d13a7df6c8837b2
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-29 08:19:03 +01:00
Marc Mutz
374b9fd031 tst_QGraphicsLinearLayout: fix memleaks in count()/insertIrem()
The tests added parent-less QGraphicsWidgets to a
QGraphicsLinearLayout, which doesn't reparent them (and cannot,
because it doesn't have an item as a parent itself onto which to
reparent them), so the test functions leaked them.

The layout items, OTOH, do get reparented, and are therefore deleted
by the stack-allocated layout as its children.

Since there's thus no object that could naturally be a parent for the
widget items, allocate them on the stack. Since their number is
variable, use QVLA, whose constructor is able to create a ... wait for
it ... VLA of non-copyable-non-movable elements on the stack (we test
for this, also in Qt 5, see e7c792ba7179c4c81fb2e26f66031ec81234b0d7).

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I9b0b65efbccd1fd7e708da4d12f746d942f602fe
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-29 08:18:49 +01:00
Marc Mutz
159029b587 tst_QGraphicsLinearLayout: fix memleaks in itemAt()
The old code used a data-driven test to check that itemAt(i), 0 ≤ i ≤
2, was returning non-nullptr. It re-created the widgets and the layout
for each data tag anew, leaking the widgets by the way.

Using data-driven test machinery here is overkill. Remove it and
create the widgets in a C array on the stack, so they're not leaked,
and iterate over them using range-for.

Also check not just for nullptr, but also that the pointer matches the
widgets we put into layout, at the position we put them in.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Ib808aa6756c6550a61a4768edfc5021f2f6ae3b3
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-29 08:18:40 +01:00
Marc Mutz
dd9a94a3b3 tst_QGraphicsLinearLayout: fix memleaks in defaultSpacing()
QStyle objects aren't owned by widgets (or QGraphicsWidgets) they are
set on, so need to be deleted manually. The test function didn't do
that, so they style objects were leaked.

To fix, hold them in unique_ptrs. QStyle subclasses, even though being
QObjects, don't have the usual QObject *parent=nullptr constructor
parameter, so passing a QObject parent isn't an alternative, really.

Amends 66b7e7497c3b318dddeb91175d8f85f606c99eec.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I6c43264760f7126610fe51f72e74ec341bd2e3d7
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-29 08:18:31 +01:00
Marc Mutz
64060cbeae tst_QGraphicsLinearLayout: fix memleaks in itemAt_visualOrder()
The test function leaked all the items it created.

Unless I renamed the object and kept the pointers to them by their old
names, any fix would touch every line, anyway. The former would be
pretty contrived in such a short function, so port the complete test
to stack-allocated objects, which is how this function would have been
written today.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Ia8a67825d3a80be4574b7779c2105d53003b9e69
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-29 08:18:22 +01:00
Marc Mutz
9bab38b133 tst_QGraphicsLinearLayout: fix memleak in testStretch()
QGraphicsView, being a QWidget, needs to have a parent or be manually
deleted. The test function did neither, so leaked the view.

Fix by allocating it on the stack.

Amends 913ff732004c2c61c39bcdd82ff05ea1827f328b.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: If012d4b833849285b62e2a4b4089457c2aef1d88
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-29 08:18:12 +01:00
Marc Mutz
f3a02fe39d tst_QGraphicsLayout: fix memleaks in alternativeLayoutItems()
I honestly didn't bother to figure out the ownership relationships
between these items; the QGraphicsView docs don't help much:

> The layout takes ownership of the items. In some cases when the
> layout item also inherits from QGraphicsItem (such as
> QGraphicsWidget) there will be a ambiguity in ownership because the
> layout item belongs to two ownership hierarchies

but asan said that the AnimatedLayoutItem objects were leaked, so hold
them in unique_ptrs now.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Icd0eabc4129b57251bbec7f8e3752f99ee584cf3
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-29 08:18:01 +01:00
Marc Mutz
fbaa376335 tst_QSplitter: don't leak the QSplitter from initTestCase()
Several test functions use a centrally-allocated QSplitter for their
tests. This object was allocated in initTestCase(), but
cleanTestCase(), while present, was empty, so nothing deleted the
object again.

Fix by deleting the object in cleanupTestCase(). Initialize the member
variable to nullptr so that the delete is well-formed even if
initTestCase() for some reason didn't run (or didn't run to
completion).

Amends the start of the public history, where this function read

    #if defined(QT3_SUPPORT)
        delete qApp->mainWidget();
    #endif

which was already leaking if QT3_SUPPORT wasn't defined.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I43e5d8921a9c097f252e11709f25bc622fc8fe15
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-29 08:17:44 +01:00
Marc Mutz
4513d48490 tst_QSplitter: fix memleak in replaceWidget()
Depending on whether QSplitter::replaceWidget() succeeds or not, we
need to delete either the return value (an unparented QWidget) or the
argument (another QWidget without parent). The test function only
deleted the return value.

Use a unique_ptr for delayed automatic deletion at the end of the test
function, which is the minimally-invasive fix. Use it for both
candidates, which ensures that either one of them is reliably deleted,
even if a QCOMPARE() fails in-between.

One check before we reset(newWidget) is special: if (!res) fails, then
the reaper contained something we also need to delete, and the reset()
will do that, but code checkers (e.g. Coverity) are known to complain
about using a pointer value after a delete, so split the check into
the check and the QVERIFY().

Amends 2c634a132696376a0a0d7641bf05ae875c50190e.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I8571477d9e53b85b2db041d7c9bdf2bd7aa69906
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-29 08:17:36 +01:00
Shawn Rutledge
eced22d725 QTextMarkdownImporter: Fix heap-buffer-overflow
After finding the end marker `---`, the code expected more characters
beyond: typically at least a trailing newline. But QStringView::sliced()
crashes if asked for a substring that starts at or beyond the end.

Now it's restructured into a separate splitFrontMatter() function, and
we're stricter, tolerating only `---\n` or `---\r\n` as marker lines.
So the code is easier to prove correct, and we don't need to check
characters between the end of the marker and the end of the line
(to allow inadvertent whitespace, for example). If the markers are
not valid, the Markdown parser will see them as thematic breaks,
as it would have done if we were not extracting the Front Matter
beforehand.

Amends e10c9b5c0f8f194a79ce12dcf9b6b5cb19976942 and
bffddc6a993c4b6b64922e8d327bdf32e0d4975a

Credit to OSS-Fuzz which found this as issue 42533775.

[ChangeLog][QtGui][Text] Fixed a heap buffer overflow in
QTextMarkdownImporter. The first marker for Front Matter
must begin at the first character of a Markdown document,
and both markers must be exactly ---\n or ---\r\n.

Done-with: Marc Mutz <marc.mutz@qt.io>
Fixes: QTBUG-135284
Pick-to: 6.9 6.8
Change-Id: I66412d21ecc0c4eabde443d70865ed2abad86d89
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 25986746947798e1a22d0830d3bcb11a55fcd3ae)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-03-28 19:46:23 +00:00
Oliver Eftevaag
49f05b043e GnomeTheme: read the initial color-scheme value from dbus
The initial color-scheme value was never initialized, and would thus,
always be 'Unknown', until the user changes the color scheme in the
system settings.

The xdg settings portal method ReadAll is currently omitting the
contrast setting from the reply. Because of this, two separate dbus
calls are necessary to get both the initial color-scheme and contrast
setting.

Change-Id: Ie32371efd830e19727922efd2c9c32595395d11a
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-28 17:44:50 +01:00
Oliver Eftevaag
4ac89dad78 Add virtual member QPlatformTheme::contrastPreference()
This function can be overridden by individual platform themes, in order
to read contrast settings from the platform's system settings, and
report the result back to Qt.

This information is relevant for our styles, and can be used to
determine color palette values, and additional elements like outline
thickness for controls/widgets.

Currently only the Windows, macOS, Gnome and Flatpak themes support this
feature.

Task-number: QTBUG-133595
Change-Id: I3aff519aa7f07c8b2fdcc1e7fb35ec719ab8efcc
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-28 17:44:39 +01:00
Edward Welbourne
8c943392ae Purge dangling uses of QDateTime deprecated time-spec changes
QDateTime::{to,set}TimeSpec and QTimeZone::setOffsetFromUtc()
shouldn't be referenced in docs aside from their own; they are
deprecated from 6.9.

Fixes: QTBUG-135238
Pick-to: 6.9.0 6.9 6.8
Change-Id: I835cfaa888dd3079f96719cd1c413dc7c2796fdb
Reviewed-by: Magdalena Stojek <magdalena.stojek@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-28 17:03:24 +01:00
Volker Hilsheimer
b1ed5f656f macOS a11y: maintain reference count for cached elements
Retain elements when storing them in the cache, so that they only get
destroyed when they are neither stored as rows/columns, and removed
from the cache. If storing an element in the cache replaces a different
element with the same ID, release that before retaining the new one.
Give the insertElement() function a bool return value so that callers
know whether the element has been retained, so that they can correctly
release their own reference.

Release elements when they are removed from the cache so that it's
easier to see that the calls are balanced. For that to work, forward
declare QMacAccessibilityElement as an NSObject type.

A special case are place-holder cell elements. Those are not inserted
into the cache until the interface is requested, so when those get
inserted into the cache, we don't have a local reference to release -
it's the reference held by the rows/columns array.

However, we don't want stale elements in the cache, so when we release
the rows and columns arrays, also remove all cell entries from the
cache. Otherwise we end up with stale elements reporting outdated
values.

As this might invalidate references that our test object holds,
refresh the test object when triggering a model update.

Amends 1f7e926411d1e0d958c37dc597f24101d410c46b.

Pick-to: 6.9 6.8
Fixes: QTBUG-134784
Change-Id: Ib3cce35058e4c80e3edc97ae578584610ee93487
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-28 16:43:06 +01:00
Axel Spoerl
8ede178fd3 Refactor and fix platform theme selection
Finding a platform theme for the list of theme names happened in two
separate loops. The first loop checked for a platform theme plugin, the
second for a platform integration plugin. In case a theme name was
passed from the environment (with the -platformtheme command line
argument or by setting QT_QPA_PLATFORMTHEME), it was ignored if it was
a platform integration plugin and a platform theme plugin was found
in the first loop.

Combine both loops, in the assumption that the list of theme names
is always correctly prioritized.

Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-134702
Change-Id: I2703236dc0f406aeb48529f8e53de76c394b7172
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-28 16:43:06 +01:00
Giuseppe D'Angelo
92860503ce QHttpHeaders: remove an unnecessary std::move
The local is always moved in this situation. (I'm not sure why
this function returns a local but other functions use make_optional.)

Amends ed341fcdd18fb4bb58ea4fa9df0be6350a81578c.

Change-Id: I6719691ad13c65af083f1749be475dc8e2da4b07
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-28 15:43:06 +00:00
Axel Spoerl
63ba867ddd QXdgDesktopPortalTheme: Refactor base theme creation loop
The search for a base theme was handled in 2 separate loops.
Combine those in sync with QGuiApplication.
Make list of theme names const, as it doesn't and mustn't change.

Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-134702
Change-Id: If4ae8212bbefa2934639feec983b94e8e2d6b168
Reviewed-by: Jan Grulich <jgrulich@redhat.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-28 16:43:06 +01:00
Magdalena Stojek
bf5fcd6ebe QHttpHeaders: Add setters for QDateTime
Added setDateTimeValue() convenience methods to QHttpHeaders, allowing
direct setting of headers with QDateTime values.

[ChangeLog][QtNetwork][QHttpHeaders] Added setDateTimeValue() methods
for setting headers using QDateTime.

Task-number: QTBUG-124766
Change-Id: I5804fa8946feaed1dfb4b37ec97a1a4461521995
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-03-28 16:43:06 +01:00
Inho Lee
c0a01ca6ad rhi: vulkan: Support to read depth textures
When reading back textures, VkImageAspect is
just used as VK_IMAGE_ASPECT_COLOR_BIT and
it doesn't work for depth/stencil formats.

Change-Id: Ib356a0821f9de8e27eb2b9333714fe75971744a2
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-03-28 16:43:05 +01:00
Marc Mutz
f9d9630e9e tst_QSplitter: fix memleak in replaceWidgetWhileHidden()
QSplitter::replaceWidget() is decumented to un-parent and return the
original widget (the one that the newWidget) replaces, so the caller
of the function is responsible for deleting it, which the test
function neglected.

Fix by storing the returned object in a unique_ptr for delayed
deletion at the exit of the function. This is the minimally-invasive
change.

Amends fb56a0f2ce34e95d955095c01ecf2943046be85e.

Pick-to: 6.9 6.8 6.5
Change-Id: Ia63ebfde59b1c5ef8ddb6c3f3ab10b28d5bf6cff
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-28 12:50:46 +01:00
Volker Hilsheimer
75db2305cb QGIM: add MultiColumn wrapper for disambiguation
If a type has both a metaobject and implements the tuple protocol, then
we need to disambiguate as row_traits would be ambiguous.

Add  a wrapper that holds the type and provides a forwarding tuple
protocol implementation. With either or the SingleColumn wrapper, client
code can decide whether the type should be a a multi-column row in a
table (accessed via tuple protocol), or  a multi-role item in a list
(accessed via the meta object).

Add documentation.

Change-Id: I0145f7a35a125a138254397bc7eafa5506e5e3ad
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-03-28 12:41:10 +01:00
Karim Pinter
5901f0ba09 Remove library requirement from the im configure feature
The feature doesn't require library nor dlopen support, even for
input context plugins (which work fine in static builds).

Task-number: QTBUG-135146
Pick-to: 6.8 6.9
Change-Id: Id171fccffa78f2d8233d800a6ea3469e9f440f79
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-28 11:15:50 +00:00
Marc Mutz
0e322aa419 QErrorMessage: fix UB (invalid cast) in Private::setVisible()
The function can be called from ~QDialog(), in which case a cast of
q_ptr to QErrorMessage is UB.

Says UBSan:

  errormessage.cpp:33:5: runtime error: downcast of address 0x7fff5089a6e0 which does not point to an object of type 'QErrorMessage'
   0x7fff5089a6e0: note: object is of type 'QDialog'
    00 00 00 00  30 74 4e 6a 12 7f 00 00  80 aa 00 00 90 61 00 00  08 76 4e 6a 12 7f 00 00  00 00 e0 1a
                 ^~~~~~~~~~~~~~~~~~~~~~~
                 vptr for 'QDialog'
       #0 0x7f1267ce7d12 in QErrorMessagePrivate::q_func() qerrormessage.cpp:33
       #1 0x7f1267ce7d12 in QErrorMessagePrivate::setVisible(bool) qerrormessage.cpp:410
       #2 0x7f1267caaa25 in QDialog::setVisible(bool) qdialog.cpp:757
       #3 0x7f12654efb28 in QWidget::hide() qwidget.cpp:8179
       #4 0x7f1267caa239 in QDialog::~QDialog() qdialog.cpp:398
       #5 0x7f1267ce72f8 in QErrorMessage::~QErrorMessage() qerrormessage.cpp:287

Fix by casting at most to QDialog* (QWidget* would actually have
sufficed).

Add a code comment.

Amends e0bb9e81ab1a9d71f2893844ea82430467422e21 (I think; it might
have been present in a different form before that).

Pick-to: 6.9 6.8 6.5
Change-Id: I61a8692f073c2d2f379ea02fa580f7fe46691c1c
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-28 07:59:44 +01:00
Marc Mutz
4981333ff3 tst_QPushButton: don't leak m_touchScreen
Same problem as in 49a87936ef50acb1ab7156809bf5f85671d36f24, same fix:
hold the result of createTouchDevice() in an owning pointer.

Amends d15d9d49ac1e5120c052bb6c7e8bac5350eea357.

Pick-to: 6.9 6.8 6.5
Change-Id: I348336d82c167d95545c9e3d46e7479606605df9
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-28 07:59:17 +01:00
Marc Mutz
44a2d8cc20 tst_QFrame: fix memleak in testPainting()
Similar to 5be58ac9271555eed3a2884d827f30c164d2277d for tst_QWidget,
this test leaked the result of QStyleFactory::create() and the fix is
the same: cache across the test function calls. This time, it's for
performance; there's like 50 different data tags for this function...

Amends a8723871ee7125b97ce5467b94198e93a528c960.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I95cc1dc4459489904f3a5e0347570eb07ccdfde8
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-28 07:59:00 +01:00
Marc Mutz
8352112e58 tst_QDialogButtonBox: fix memleak in hideAndShowButton()
The old code created the top-level widget on the heap, without a
parent, so the test function leaked it.

Fix by creating on the stack instead.

This means we need to move the definition to before that of the child
button box (itself created on the stack), to avoid the double-delete
that would happen if the automatic parent would delete its QObject
child and then the compiler deletes the child again because it, too,
is an automatic variable. If, OTOH, the parent is declared before the
child, the child will have unregistered itself from its parent when it
was deleted.

Amends bbb71e7e80f292c2e69faef81b1624832981147e.

Pick-to: 6.9 6.8 6.5
Change-Id: I9489daace3bbbeecfaedcb5780a6b29a82c8d4ff
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-28 07:58:43 +01:00
Marc Mutz
bfefcec650 tst_QButtonGroup: fix memleak in task209485_removeFromGroupInEventHandler()
A QButtonGroup does not own the buttons it contains, so this test
function leaked the button, despite a thing called "ButtonDeleter".

That thing doesn't _actually_ delete the button, it merely removes it
from the group.

To prevent the code from instilling same confusion in the next reader
as it did in this one, inline the whole thing and condense it down to
a single connect() statement, using a lambda.

Sometimes, another level of indirection (or two) does _not_ solve
problems...

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I0002f0dd86d505d1aa089d696776051fddbf4c1e
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-28 07:58:23 +01:00
Marc Mutz
ccd0ea0b4e tst_QButtonGroup: fix memleak in keyNavigationPushButtons()
While a QButtonGroup is-a QObject, unless it has a QObject-parent, it
won't be deleted by, say, the parent of the buttons it contains, so
this test function leaked the QButtonGroup.

Fix by giving it the dialog as parent. This is just a QObject
parent-child relationship; it does not change the behavior of the
button group, nor the dialog, except that the latter now deletes the
former as its QObject child when it itself it deleted.

Amends e7cff5bca7aefaea63e80598babf6bd7917aa1c3.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Ic633179252c72e7ee47a57be73944a6aa589637b
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-28 07:58:03 +01:00
Marc Mutz
0e314d3434 tst_QAbstractScrollArea: fix memleak in task214488_layoutDirection()
QCoreApplication::sendEvent() does not take ownership of the event,
postEvent() does, so this test function leaked the QKeyEvent it
created on the heap.

Fix by creating it on the stack instead. Add a scope to limit the
lifetime of the event object to just the sendEvent() call.

Amends the start of the public history.

This doesn't completely make the test asan-clean, it still suffers
from the QScroller::grabGesture() leak (QTBUG-135055).

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I8c93e03b2ea919ab80a1d508f008853779eb89af
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-28 06:57:41 +00:00
Marc Mutz
7cf8b2d030 tst_QTreeView: fix memleak in fetchUntilScreenFull()
The TreeModel class was lacking the destructor, so the m_root TreeItem
was never deleted (it was held in a non-owning pointer and had no
parent).

Instead of adding ~TreeModel(), port to holding m_root in unique_ptr
instead. This creates a bit more churn, but communicates intent
better, and makes sure the item is never without an owner.

Amends e74af68654c0eb127277c73e20bda409b83d157b.

As a drive-by, fix the indent of the else clause of a ternary.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I2f5c8852b8bee89c63933c118a4599d6a17de8e2
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-28 07:57:18 +01:00
Marc Mutz
b5a87a665c QHeaderView: port from qt_saturate to q26::saturate_cast
The commit that introduced the qt_saturate call did use that old
function in order to stay compatible with Qt 6.5, which never received
q26::saturate_cast. This patch ports to the new function in branches
that have it.

Pick-to: 6.9 6.8
Change-Id: Iadd9d2c92ea1e37095b71b1647db61dec2b8333a
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-28 07:57:00 +01:00
Marc Mutz
03daf6685e QTapGestureRecognizer: fix UB (invalid downcast) in recognize()
The old code cast the event to QTouchEvent* ahead of checking that it
actually is of a type() that suggests is-a QTouchEvent.

I'm not sure this was UB, because we weren't dereferencing the result
until after we checked type(). Then again, who am I to argue with
compiler writers (= same people that write ubsan)?

Says UBSan:

  qstandardgestures.cpp:402:29: runtime error: downcast of address 0x7fffedb894f0 which does not point to an object of type 'QTouchEvent'
   0x7fffedb894f0: note: object is of type 'QEvent'
    ff 7f 00 00  c0 db 01 cf 99 7f 00 00  15 00 00 00 01 00 00 00  01 00 00 00 99 7f 00 00  b6 c4 14 f5
                 ^~~~~~~~~~~~~~~~~~~~~~~
                 vptr for 'QEvent'

Fix my delaying the cast until after we know that event is-a
QTouchEvent. All other recognize() overload already behaved correctly.

As a drive-by, use auto (RHS contains the type) and mark the result
const.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Ifa9e940232b93b2ecf666c35536519a8385c9800
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-28 07:56:35 +01:00
Marc Mutz
567da5e3e0 QDesktopUnixServices: don't leak the QDBusPendingCallWatcher
When, like in tst_QApplication::qtbug_103611(), a QApplication object
is destroyed without calling exec(), then QDesktopUnixServices leaked
its QDBusPendingCallWatcher, because the connection to the slot that
would deleteLater() the watcher was disconnected, and the watcher had
no QObject parent that would otherwise reap it.

Fix by actually deleting the watcher in ~QDesktopUnixServices(), if
it still exists (which implies disconnecting, of course).

This makes tst_QApplication asan-clean on Linux/X11 (was: "75466 bytes
leaked in 965 allocations").

Amends de609d84b9cee4a481d1718c00b09105d8c2ae69.

Pick-to: 6.9 6.8 6.5
Change-Id: I28a08abdb1be65a8746702ad304282de4e1100d7
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2025-03-28 06:56:15 +00:00
Marc Mutz
83af06b0e5 tst_QMenuBar: avoid UB (invalid downcast) in allowActiveAndDisabled()
When the test functions runs off the end (or returns from a failed
QCOMPARE/QVERIFY), `activeMenu` is destroyed while it's the
QMenuBarPrivate::activeMenu, and the following focusInEvent() on the
QMenuBar causes QMenuBarPrivate::setCurrentAction() to access
`activeMenu` when it has already ceased to be a QMenu.

Says UBSan:

  qpointer.h:75:14: runtime error: downcast of address 0x7fff87934860 which does not point to an object of type 'QMenu'
  0x7fff87934860: note: object is of type 'QWidget'
   00 00 00 00  08 f1 0e be 17 7f 00 00  80 c8 00 00 90 61 00 00  b8 f2 0e be 17 7f 00 00  00 00 62 c6
                ^~~~~~~~~~~~~~~~~~~~~~~
                vptr for 'QWidget'
    #0 0x7f17baf57be5 in QPointer<QMenu>::data() const qpointer.h:75
    #1 0x7f17baf57be5 in QPointer<QMenu>::operator QMenu*() const qpointer.h:83
    #2 0x7f17baf57be5 in QMenuBarPrivate::setCurrentAction(QAction*, bool, bool) qmenubar.cpp:351
    #3 0x7f17baf5a200 in QMenuBarPrivate::focusFirstAction() qmenubar.cpp:245
    #4 0x7f17baf5b727 in QMenuBarPrivate::focusFirstAction() qmenubar.cpp:1260
    #5 0x7f17baf5b727 in QMenuBar::focusInEvent(QFocusEvent*) qmenubar.cpp:1259
    [...]
    #34 0x7f17b93373d6 in QWidget::~QWidget() qwidget.cpp:1508
    #35 0x7f17badb4658 in QMenu::~QMenu() qmenu.cpp:1789

Since I couldn't fix the problem on short notice, I created
QTBUG-135151 to track it.

For now, simply close the QMenuBar on all exists from the test
function to avoid this code path.

Task-number: QTBUG-135151
Pick-to: 6.9 6.8 6.5
Change-Id: Id8c9ee090d8bbc5ec22ce3f2ff7485766640ab43
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-03-28 07:55:38 +01:00
Marc Mutz
c0dbfe6c87 tst_QGraphicsItem: properly init QGraphicsSceneDragDropEvent
Nothing was setting its proposedAction() and dropAction(), but they
were read in QGraphicsScenePrivate::cloneDragDropEvent(), leading
UBSan to complain about reading an invalid value for that
enum. Interestingly, Valgrind didn't find this issue, probably because
of the strong security options we're now activating by default for a
Qt build (stack protector, trivial-auto-var init, ...).

Says UBSan (excerpt):

  qgraphicssceneevent.cpp:1591:15: runtime error: load of value 3200171710, which is not a valid value for type 'DropAction'

To fix, explicitly set the two properties on the locally-created
QGraphicsSceneDragDropEvent. I didn't go the way of "fixing" this by
initializing the members in QGraphicsScenePrivate, because the rest of
the test doesn't trigger any other error, so Qt itself is
well-behaved, and proactively initializing stuff prevent tools from
noticing inconsistencies.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Ibc9663e8afcd1f7ff9d0e3c646f70e0ceded67a9
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2025-03-28 06:55:06 +00:00
Mårten Nordheim
2a7fa4963c Shuffle Q_(ALWAYS|NEVER)_INLINE around so they can be attributes
The attribute must appear before the modifiers like 'inline' and 'constexpr'.

Change-Id: If3d143fc2f85a8eba6e3ac2ceca10720649f33cb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-28 04:05:57 +01:00
Mårten Nordheim
d2d74673f3 QTest::ignoreMessage: Clarify what encoding we assume for parameter
So future-me and others don't have to look through the source code to
figure it out.

Pick-to: 6.9 6.8 6.5
Change-Id: I1f6e46cec256112226cad4d24ed52e4818635ae8
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-28 04:05:57 +01:00
Volker Hilsheimer
2332f827c5 QGIM: check that row is valid also in flags()
While we never access the data, accessing a MultiColumn item holding a
nullptr would still dereference that nullptr, and then pass that
reference to our lambda.

And the results are misleading: if there is no gadget or object stored
for that row yet, then the item is not editable - nothing can be stored.

Change-Id: Ic24242296f8cdedae6e36a12da470831eb93ee2a
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-03-28 02:51:00 +01:00
David Faure
e9dbc016e1 Use u' ' instead of QLatin1Char(' ') in qkeysequence.cpp
Easier on the eye.

Amends ada885dfd55d5c386d04039babee43e49ccab5c5.

Pick-to: 6.9 6.8
Change-Id: Id218288ccc4556abb7c9a199f27b7dcb6a3ba73e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-28 01:51:00 +00:00
Marc Mutz
6ac40faa80 QXcbDrag: Fix UB (unaligned load) in handleFinished()
According to the XDND spec¹, the window-ID of an XcbFinished message
is in xclient.l[0]. That's Xlib terms, though. In xcb terms, it's in
xcb_client_message_event_t's data.data32[0]. This is how all QXcbDrag
functions handle it (e.g. move()), except handleFinished(), which
casts the uint32_t array to a (misaligned) ulong one.

¹ https://www.freedesktop.org/wiki/Specifications/XDND/#index29h3
  (the fragment doesn't look like it's stable, it's the section
  titled "XdndFinished (new in version 2)")

Says UBSan:

  qxcbdrag.cpp:1051:12: runtime error: load of misaligned address 0x60400078ba9c for type 'const long unsigned int', which requires 8 byte alignment
  0x60400078ba9c: note: pointer points here
    c0 01 00 00 28 02 e0 08  01 00 00 00 c8 01 00 00  00 00 00 00 00 00 00 00  93 23 00 00 00 00 00 00
                ^
    #0 0x7fa3ea3a957c in QXcbDrag::handleFinished(xcb_client_message_event_t const*) qxcbdrag.cpp:1051
    #1 0x7fa3e9e20dec in QXcbConnection::handleXcbEvent(xcb_generic_event_t*) qxcbconnection.cpp:607
    [...]

I have a hard time seeing how it could have worked in big-endian
systems. In LE ones, it only works because the high bits of l[0],
which come from data32[1], are stripped again when the value is
narrowed for passing to findTransactionByWindow(). But the 'if' before
_could_ mis-detect a zero xcb_window_t for a non-zero one if data32[1]
wasn't empty...

To summarize: this is a mess (that's a technical term).

Fix by removing the pointless cast, and just read data32[0], like
elsewhere in the file.

Amends c3f9de62966d32d8e33d62eb374fe2657a4cfebe(!).

Pick-to: 6.9 6.8 6.5 5.15
Fixes: QTBUG-127517
Change-Id: Ie7c3718bada52ff82c16f814eee8ec57248fbfbf
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-03-28 01:50:59 +00:00
Thiago Macieira
ffb81e6270 QFileSystemEngine/Unix: remove superfluous setting of knownFlagsMask
fillFromStatBuf() and fillFromStatxBuf() (through flagsFromStMode()) set
the PosixStatFlags, ExistsAttribute, and sometimes HiddenAttribute. It's
harmless to set the same bits again, but we can do slightly better.

Change-Id: I1def9449b4ba10fbcd49fffd0fe6fc8734d0b3bd
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-03-27 18:50:59 -07:00
Thiago Macieira
e86b970ea4 QFileSystemEngine/Unix: deduplicate the st_mode parsing
Both fillFromStatBuf() and fillFromStatxBuf() had copies of the parsing
of the st_mode / stx_mode field. This deduplicates them and sets up for
when/if other OSes get a statx() system call similar to Linux's.

Pick-to: 6.9
Change-Id: I7c80d121c21b76d78b81fffd172d205287b595d9
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-03-27 18:50:59 -07:00
Marc Mutz
20d5a3cda9 tst_QLayout: fix memleak in removeWidget()
A QLayout that was removeItem()ed from its parent layout no longer is
deleted by it and has to be deleted manually, which the test function
failed to do.

To maintain the rest of the test function as faithfully as possible,
don't delete the layout right after the removeItem(), but delay until
the exit from the test function, using unique_ptr.

Amends 867c0b8d8a53974074b1fff5b132f3ae9f150066.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Ia915d29bda348849033a6b9eb282dcb26a68c383
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-28 02:50:59 +01:00
David Faure
90a82ad8e5 QSFPM: fix mapping corruption in mapFromSource() on hidden row child
source_to_proxy (called by mapFromSource) was unconditionally
creating a mapping for the parent of the given source index,
even if that parent is in fact filtered out in the proxy.
That mapping would then just say "-1" for the (also filtered out)
child row.

Afterwards, inserting a visible child (which makes the parent visible,
in a recursive QSFPM) would see that the mapping for the parent
already exists and fail to update it properly.

Various symptoms could ensue, such as an out-of-bounds access in
gm->proxy_rows.at(source_parent.row()) in a subsequent call to
can_create_mapping (as I had on KMail startup for years, randomly) or
a visible child that fails to appear (as in the unittest).

Fixed by using create_mapping_recursive() which returns 'end' if
the row is filtered out, going up the tree if necessary to
create mapping for parents on demand (so that the call to
filterAcceptsRow is cached).

Fixes: QTBUG-76976
Pick-to: 6.9 6.8
Change-Id: I25a3bf6b147092c1231ab6441e636264fd0c4222
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2025-03-28 01:50:59 +00:00
Marc Mutz
a8c55cb547 tst_QTreeView: fix memleak in expandAfterTake()
QStandardItems that were taken out of their QStandardItemModel need to
be deleted by the caller, which this test function forgot to do.

Store the item in a unique_ptr, so it isn't deleted until after the
next populateModel() call. Deleting immediately may change what the
test function checks for.

Amends 6012285e7dedb4364e2db087b7d5cbfc2973320a.

Pick-to: 6.9 6.8 6.5
Change-Id: I45a0a2f598febc75fd9ef683525c973476dcd7e0
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-28 02:50:58 +01:00
Giuseppe D'Angelo
78e785122b QDeadLineTimer: remove unused include for QElapsedTimer
Change-Id: Iaf1deec207a92292dcfdb5a99c97bbc25622d1d4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-27 21:55:56 +01:00
Christian Ehrlicher
c5c6df40be QIconLoaderEngine: use scaledPixmap() to properly pass dpr
QIconLoaderEngine::paint() was still using QIconLoader::pixmap() to
retrieve the pixmap for painting instead QIconLoader::scaledPixmap()
which takes the devicePixelRatio as additional parameter. In the case
of icon themes this could pick up the wrong pixmap (from the wrong
folder).

Pick-to: 6.9 6.8
Fixes: QTBUG-135159
Change-Id: I69ceada35f36c64675c4147cf284a180a4c69915
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-03-27 21:55:52 +01:00
Alexandru Croitor
d8caf6d89f CMake: Allow echoing RunCMake test command output via an opt-in
This will be used in a new manual test in qt5.git, to show progress of
long-running commands.

Store the diff in a new patches subdir, to make it easier to re-apply
when we update the file from upstream.

As a drive-by, store patches from the previous modifications that were
done before this change.

Pick-to: 6.8 6.9
Change-Id: Ib73908e20fac7fe0bd620400d483625238fa37d1
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Cristian Le <cristian.le@qt.io>
2025-03-27 18:58:47 +01:00
Mårten Nordheim
7293f05380 Include qtcoreglobal.h from qtcoreglobal_p.h
Otherwise including only the private header leads to QT_CONFIG being
undefined.

Amends 38bb72720aef4caf3de6c1c68ab46435d7c8d65c.

Pick-to: 6.9
Change-Id: I0960d38c98d64348ebf1cec481417bdb21eed9a6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-27 18:58:31 +01:00
Even Oscar Andersen
26d950bb77 Add security header for qaccessible.cpp
The text interface, like textAtOffset, parses data coming
in from the user. Therefor tagging as security critical.

Task-number: QTBUG-134483
Pick-to: 6.9 6.8
Change-Id: I3c97813d4fba719e7972693510a0b9a78cb1348f
Reviewed-by: Lorn Potter <lorn.potter@qt.io>
2025-03-27 15:53:27 +00:00
Edward Welbourne
ea3d2b24c4 Cope as best we can if fractional-part and group separators coincide
The user might misconfigure their system this way. CLDR's mn_Mong_MN
even had this from v43 (when I reported it) to v45 (after which it was
fixed), so some operating system using CLDR might have that problem if
configured for this locale.

This naturally makes number parsing ambiguous in general, when the
last group might be a fractional part or the end of the whole-number
part, but we can at least catch the cases where the pattern of lengths
of groups of digits would violate grouping rules for the locale under
one reading or the other. When it is ambiguous, interpret the last
group as a fractional part. That shall sometimes be wrong, but the
system is misconfigured in this case anyway, so we're allowed to not
care.

Add some test-cases for this scenario, making clear which are
unambiguous (malformed in one reading, well-formed in the other) and
which are ambiguous (so resolved by treating last separator as the
fractional-part one).

Fixes: QTBUG-134913
Change-Id: Ib8df9bcd9ca88ad4e949565b1ecfba3ef64b587d
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-03-27 16:53:27 +01:00
Edward Welbourne
754666dbe8 Fix parsing of most significant group of digits
The first-group minimum size limit is only relevant when there's
*only* one separator: a smaller group is allowed when there is a later
separator. QLocaleData::numberToCLocale() was, however, rejecting a
short first group without regard to what came later. Expanded two
grouping tests, that previously checked we *generate* correct strings,
to round-trip the strings and verify we get the right answer back.
Some of those duly failed. Fixed the parsing to check the right
condition on seeing a group separator.

That let valid groups get accepted. In the process, added some
test-cases that we do correctly reject invalid forms. Made sure the
fix also gets those right.

Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-134913
Change-Id: Ifa5351adba4eec232917a343d4a73fb4656d1d32
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-03-27 16:53:26 +01:00
Edward Welbourne
f1d48552e4 Catch invalidly-placed exponents on conversion to C locale
Although the number-parsing code to which the C-locale form is later
passed was already rejecting such malformed texts, it's better to
catch it earlier and to make the check overt in that parsing. Added
some tests cases that would fail if this wasn't checked; but they do
pass already in the parent.

Pick-to: 6.9 6.8 6.5
Change-Id: I5ef9e483317ce4dc519ddc7c4c016dcad5cb22c4
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2025-03-27 16:53:26 +01:00
Edward Welbourne
d1879c3a39 Replace several *_idx variables with an enum and a bool
Thanks to Mate Barany for pointing out that the *_idx variables are
now all reduced to serving (via comparison with -1) as
booleans. Replace them with a "where in the parse are we ?" enum
variable and a "do we need some digits ?" bool.

Restructure to make that work. This needed to recognize (the letters
that make up) Inf and NaN so as to know when not to object to a lack
of digits. Since NumericTokenizer already has a matcher for those,
export its access to that as a public method and use that to simplify
its own uses of the matcher. Added some test-cases suggested by this,
that actually pass in the parent, as qt_asciiToDouble() could see the
result was malformed in any case, even when they weren't caught by bad
digit-group sizes (as "inf,000", "1,inf", "NaN,000" and "1,NaN" were).

Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-134913
Change-Id: Ie1730530a4e34a76ba1836a25212e4ec27dad15f
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-03-27 16:53:26 +01:00
Konsta Alajärvi
f386f83266 Remove Blacklist entry for tst_QApplication::closeAllWindows()
tst_QApplication::closeAllWindows() is blacklisted but does not seem
to fail anymore.

Unblacklisting the function.

Fixes: QTQAINFRA-6894
Pick-to: 6.9 6.8
Change-Id: Ia6157cc767a191121c4026f1c17edcad3b526d5c
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-27 14:57:43 +00:00
Topi Reinio
7018db6916 Doc: Update copyright year in the global configuration
Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-134788
Change-Id: I118d15df4e644dbed1a3de5efdb0b5d5a0e11c20
Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
2025-03-27 14:57:43 +00:00
Tor Arne Vestbø
cf8f9580da Cast NativeResourceForIntegrationFunction via QFunctionPointer
To fix warnings with Xcode 16.3:

/Users/torarne/dev/qt/qtbase/src/widgets/widgets/qtabbar.cpp:117:6: warning: cast from 'QPlatformNativeInterface::NativeResourceForIntegrationFunction' (aka 'void *(*)()') to 'SetContentBorderAreaEnabledFunction' (aka 'void (*)(QWindow *, unsigned long long, bool)') converts to incompatible function type [-Wcast-function-type-mismatch]
  117 |     (reinterpret_cast<SetContentBorderAreaEnabledFunction>(function))(q->window()->windowHandle(), identifier, q->isVisible());
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Pick-to: 6.9 6.8
Change-Id: Ie7b5ace64c1aad5f970bc1a23e59c5724fcd92b5
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-27 15:57:42 +01:00
Tor Arne Vestbø
002badc3ab macOS: Remove unused variables in a11y implementation
Pick-to: 6.9 6.8
Change-Id: Ib011f09119e324ce08837448eb82249f0b79a33e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-27 15:57:42 +01:00
Tor Arne Vestbø
c805af5284 macOS: Remove unused variable in QMacStyle::drawPrimitive
Pick-to: 6.9 6.8
Change-Id: I42cdd765a19e26a4e4a1a276d2db552188003736
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-27 15:57:42 +01:00
Tor Arne Vestbø
5489aac90b macOS: Remove unused variable in CHECK_SPAWN macro
Pick-to: 6.9 6.8
Change-Id: I821655019ece82767ea09fb838b8ba513ca5530b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-27 15:57:42 +01:00
Lena Biliaieva
ed341fcdd1 Add QHttpHeaders convenience methods for converting to known types
Introduce new methods in QHttpHeaders to convert header values to common
types, including integers and date-times. These functions
return std::optional<T> to indicate conversion success or failure.

During the porting of QtNetwork internals to QHttpHeaders (specifically
replacing cooked headers with QHttpHeaders in QNetworkRequest), these
methods proved to be necessary.

[ChangeLog][QtNetwork][QHttpHeaders] Added convenience methods for
parsing header values to integers and date-times.

Task-number: QTBUG-124766
Change-Id: I95cc8c29c522b23b027d5a79beb9b882aeffa105
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-27 13:05:22 +01:00
Bartlomiej Moskal
23fd2cfb01 Android: Do not modify Touch Event position in JAVA code
In QtWindow class, the Touch Event coordinates were increased by Layout
position. That allows to move to global coordinates.
In the same time, in 15674f4ce9ea455b47f68d8871d5676d7a731630 commit, we
started mapping coordinates of Touch Event to Global position. That
cause the issue with incorrectly handled touches for example with
QDialogs.

To avoid this issue, we will stop modify Touch Event position in JAVA
code. We will send only localPosition to not make transformation twice.

With this change, all events received from JAVA have local position of
their window.

Pick-to: 6.9 6.8
Fixes: QTBUG-130576
Fixes: QTBUG-127925
Change-Id: I6b58e0369959840f869e31a3d96425c64507b39d
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2025-03-27 11:54:39 +01:00
Bartlomiej Moskal
01d25533b4 Android: Fix touchDown event coordinates
In the touchAdd method, the mapped touch point is divided by the
platform integration screen size.
In order not to mix different coordinate systems, we should use
platformWindow to correctly calculate global position of touch event.

Pick-to: 6.9 6.8
Task-number: QTBUG-130576
Task-number: QTBUG-127925
Change-Id: Ic7653a60fb3def181f29a3e28b963878dc54a99e
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-03-27 11:54:39 +01:00
Axel Spoerl
c04b95cb59 QGenericUnixTheme: Fix build w/o xcb and wayland
Add ifdef condition to consider QKdeTheme only if Qt is built either
with wayland or xcb.

Fixes: QTBUG-135204
Change-Id: I27941bf6bd576c1532ac23992c1c94f9ace53683
Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
2025-03-27 11:14:51 +01:00
Liang Qi
34be5083bd D3D12MemoryAllocator: fix the build with llvm-mingw 18.1.8 WoA
C:/qt/qtbase/src/3rdparty/D3D12MemoryAllocator/D3D12MemAlloc.cpp:144:32: error: unknown warning group '-Wnonnull-compare', ignored [-Werror,-Wunknown-warning-option]
  144 | #pragma GCC diagnostic ignored "-Wnonnull-compare"
      |                                ^
C:/qt/qtbase/src/3rdparty/D3D12MemoryAllocator/D3D12MemAlloc.cpp:9902:9: error: 'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to false [-Werror,-Wtautological-undefined-compare]
 9902 |     if (this == NULL)
      |         ^~~~    ~~~~
C:/qt/qtbase/src/3rdparty/D3D12MemoryAllocator/D3D12MemAlloc.cpp:10053:9: error: 'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to false [-Werror,-Wtautological-undefined-compare]
 10053 |     if (this == NULL)
       |         ^~~~    ~~~~
C:/qt/qtbase/src/3rdparty/D3D12MemoryAllocator/D3D12MemAlloc.cpp:10118:9: error: 'this' pointer cannot be null in well-defined C++ code; comparison may be assumed to always evaluate to false [-Werror,-Wtautological-undefined-compare]
 10118 |     if (this == NULL)
       |         ^~~~    ~~~~
4 errors generated.

This amends 84fb0de413ec574aab778d863c56e0d9a7f7ef6e .

See also
* https://clang.llvm.org/docs/DiagnosticsReference.html
* https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

Pick-to: 6.9 6.8
Change-Id: I2c8d27ade8a123bc4ff2fa5082e161c042335c6c
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2025-03-27 11:14:51 +01:00
Marc Mutz
8beaab9483 tst_QHeaderView: fix UB (invalid downcast) in testStylePosition()
The view that's being created in init() is not a
protected_QHeaderView, but only a "normal" QHeaderView, so casting it
to protected_QHeaderView is not valid.

Says UBSan:

  tst_qheaderview.cpp:3338:37: runtime error: downcast of address 0x604000087050 which does not point to an object of type 'protected_QHeaderView'
  0x604000087050: note: object is of type 'QHeaderView'
   00 00 00 00  d8 d2 e6 0b b2 7f 00 00  80 88 00 00 c0 61 00 00  08 d6 e6 0b b2 7f 00 00  00 00 be be
                ^~~~~~~~~~~~~~~~~~~~~~~
                vptr for 'QHeaderView'

Fix using the usual trick: forward-declare tst_QHeaderView and make
QHeaderView itself befriend it directly.

Amends bff78163f6dc83d833b2097a51453523cfa7b00b.

tst_QHeaderView is now asan/ubsan-clean, except for some signed
overflows in calculateAndCheck(), filed QTBUG-135201 to track it.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I718695bef26e72f442bd677c6bad05bab561163f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
2025-03-27 10:14:51 +00:00
Marc Mutz
03d1e81516 QHeaderView: fix UB (signed overflow) in setOffset()
I have no idea why setOffset() would accept all int values, but
tst_QHeaderView::getSetCheck() checks the function with both INT_MIN
and INT_MAX (albeit without having show()n the object it so tortures),
so try to make it work(-ish).

0 - INT_MIN overflows, of course, so use saturation math to calculate
the result. This might not scroll to pixel precision, but it couldn't
have done so before, either (no int value can possibly represent the
mathematical value, otherwise it wouldn't have overflown). But at
least we now don't run into UB anymore.

Said UBSan:

  qheaderview.cpp:418:9: runtime error: signed integer overflow: 0 - -2147483648 cannot be represented in type 'int'
   #0 0x7f183ffa4a5f in QHeaderView::setOffset(int) qheaderview.cpp:418
   #1 0x55f5ca56a5fe in tst_QHeaderView::getSetCheck() tst_qheaderview.cpp:437

While q26::saturate_cast was only picked to 6.8, its predecessor,
qt_saturate(), was picked to 6.2, so use that, for now, and port to
q26::saturate_cast in a follow-up.

As a drive-by, mark ndelta const.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5
Change-Id: I118c917ccd588c0b6d407090609f4d17075bbab6
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-27 11:14:50 +01:00
Marc Mutz
3b3b5968d0 QAbstractItemView: fix UB (invalid downcast) in Private::shouldAutoScroll()
Says UBSan:

  qabstractitemview.cpp:4442:18: runtime error: downcast of address 0x604000026790 which does not point to an object of type 'QAbstractItemView'
  0x604000026790: note: object is of type 'QWidget'
   00 00 00 00  08 b1 cf 9f 33 7f 00 00  80 24 00 00 60 61 00 00  b8 b2 cf 9f 33 7f 00 00  00 00 be be
                ^~~~~~~~~~~~~~~~~~~~~~~
                vptr for 'QWidget'

I did not reserch what the problem was that the code comment referred
to, but we now have QWidgetPrivate::get() (incl. in 5.15), so use
that.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: If658d21694f6806eafdf678b8d5ff7ed62e93513
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2025-03-27 11:14:50 +01:00
Marc Mutz
9ea9818eeb tst_QAbstractItemView: fix memleaks in testDelegateDestroyEditorChild()
After removing the QTreeWidgetItems from the QTreeWidget, they have no
parent anymore, and so no-one deletes them and they're leaked.

Add a vector<unique_ptr> to hold such items until the end of the
function. This is the minimally-invasive fix. If we were to delete the
items right after removeChild(), we might be changing the test, and if
we deleted them only at the end of the function, we'd still be leaking
them on a failed QCOMPARE().

Amends 1d799e91082092821a04885bd9d069febefc37da.

This doesn't completely fix tst_QAbstractItemView; it still suffers
from the QScroller leak, QTBUG-135055.

Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-135055
Change-Id: I2d3c661d5331ae33bb945f850fccdaa934f7a2dd
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2025-03-27 11:14:50 +01:00
Marc Mutz
3c7719f2c2 tst_QCalendarWidget: fix memleak in showPrevNext()
QObject parents own their children, but not the other way around. So
the parent-less QWidget *parent created on the heap was leaked.

To fix, create it on the stack instead, but for that to work, it must
be declared _before_ its eventual child, otherwise the parent would
delete the child as a QObject child, followed by the compiler deleting
the child as an automatic variable = double-delete.

Amends ab536c3c71deaaa3b67ca87c47628355d9f348e8.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Ibccf229fc056665e3b854e1a94e1f4b5bf7a89e1
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2025-03-27 11:14:49 +01:00
Marc Mutz
bdd2cefcf3 tst_QCompleter: fix memleak in hideWidget()
QLineEdit::setCompleter() doesn't reparent the completer under the
line edit, so this test function leaked the object (and with it,
"22260 byte(s) leaked in 214 allocation(s)"; seriously, what does a
QCompleter do with 20+KiB of memory!?).

Fix by giving the completer the line edit as parent.

Amends 24859d7deaf995e992f0d9439a1c476126d5f654.

Pick-to: 6.9 6.8
Change-Id: Ic14a32c982dd4c75ae527188e53a7f20af714038
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2025-03-27 11:14:49 +01:00
Marc Mutz
ad0d6be778 tst_QMenu: fix memleaks in tearOffMenuNotDisplayed()
QActions can be added to many widgets at the same time, so addAction()
doesn't reparent them.

Having no (QObject) parents, the QAction objects in this test were
consequently leaked.

Fix by giving them parents.

Passing `this` would have worked, but has the drawback that if you run
the test twice (by naming it twice on the command line), actions with
identical shortcuts would accumulate and potentially change the
result. Therefore, add an automatic QObject to act as their
parent. This is the minimally-invasive fix.

Amends 198225983df9f402bb368b449f1abeea95ff0dce.

Pick-to: 6.9 6.8 6.5
Change-Id: I59881b10076ba790502483242f620aeed3e99575
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2025-03-27 11:14:49 +01:00
Marc Mutz
850d352111 tst_QMenu: fix memleaks in transientParent()
QActions and QMenus can be added to several widgets, so addAction()
and addMenu() don't transfer ownership of their argument.

Having no (QObject) parents, the QMenu and QAction objects in this
test were consequently leaked.

Fix by giving them parents.

Amends 493a85a9e468874471057910a61e7c54a45eee83.

Pick-to: 6.9 6.8 6.5
Change-Id: I2c48a55de26c5ed487d2e42e50e0b2fbb6ddf98c
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2025-03-27 11:14:49 +01:00
Zhao Yuhang
09991b51a4 Replace some not appropriate QSystemLibrary usages
For these use cases we consider it's more appropriate to
use GetModuleHandle rather than QSystemLibrary.

Change-Id: I30f54e3dbe42d96292b6350a26c84fdb97e56ea4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-27 17:33:10 +08:00
Alexey Edelev
762c1561a8 Replace the manual chmod run with the file(CHMOD command
Change the permissions for Android executable runner using file(CHMOD,
this is allowed since we raised the minimum required CMake version to
3.20.

Change-Id: If7d9fdf1e7b44a4da3b353ec1d9a2db5c4353973
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-27 06:42:41 +01:00
Alexey Edelev
be5845e8ca Name (_)qt_internal_android_app_runner_arguments properly
The function is located in public CMake commands and should be '_'
prefixed.

Amends a905d26f14da1cf86b8490331c0cc41c2a45b283

Pick-to: 6.8 6.9
Change-Id: I2817105de4e60d9e5d9a65479af2d11ac6406dae
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-03-27 06:42:28 +01:00
Alexey Edelev
5a93c457e5 Teach syncqt to look for module headers in install path
If we build the specific module against installed Qt syncqt cannot
detect the installed module headers, since it only checks the build
paths. This adds the installIncludeDir argument for syncqt so it
now attempts looking for the included header file in Qt install path.

This will raise early warnings in Qt per-module builds too, but not
only when building top-level Qt or for non-prefixed builds.

Pick-to: 6.5 6.8 6.9
Change-Id: I5a28ec35a776b5b39f4a8923c9bf91e857f45e4a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-27 01:35:43 +01:00
Axel Spoerl
91c60f25e0 tst_QWidget: Improve diagnostic output in cleanup()
Use QTRY_COMPARE to have the size of topLevelWidgets() in logs.
Add a warning if QApplication::allWidgets() isn't empty.

Task-number: QTBUG-135138
Change-Id: I40bc3e5054776cb1b751218d9b9d1c46b349ccc7
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-03-26 21:53:28 +00:00
Thiago Macieira
62153d6ce0 QLoggingRegistry: load all the qtlogging.ini files, not just the first
QStandardPaths::locate() returns the first item that locateAll() would
have returned, which may be the user's override file. However, if this
file exists, it completely disables loading of the system files, so any
rules present there would be ignored, a behavior different from the
qtlogging.ini installed in the Qt DATADIR.

That means we now match what the documentation said we'd do:

    The \c QtProject/qtlogging.ini file is looked up in all directories returned
    by QStandardPaths::GenericConfigLocation.

[ChangeLog][QtCore][Logging framework] Fixed a bug that caused the
logging framework to not load all the QtProject/qtlogging.ini files
found in the user and system configurations. Previously, it would stop
parsing after finding the first one; now, all files are processed and
their rules are merged. See the QStandardPaths documentation for more
information on what file paths are considered in each operating system.

Change-Id: I7f6ea7e173e6dc9a8350fffde601bb2ca826a148
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
2025-03-26 13:14:13 -07:00
Mårten Nordheim
69633bcb58 QFileSystemEngine/Win: Use GetTempPath2 when available
Because the documentation for GetTempPath nows says apps should call
GetTempPath2.[0]

Starting with Windows 11[1], and recently Windows 10[2],
GetTempPath2 was added. The difference being that elevated
processes are returned a different directory. Usually
'C:\Windows\SystemTemp'.

Currently temporary files of an elevated process may be placed in a
world write-able location. GetTempPath2, by default, but can be
overridden, places it in a directory that's only accessible by SYSTEM
and administrators.

[0] https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppathw#remarks
[1] https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppath2w
(Minimum supported client - Windows 11 Build 22000)
[2] https://blogs.windows.com/windows-insider/2025/03/13/releasing-windows-10-build-19045-5674-to-the-release-preview-channel/
(This update enables system processes to store temporary files ...)

[ChangeLog][QtCore][Important Behavior Changes] On
Windows, generating temporary directories for processes with elevated
privileges may now return a different path with a stricter
set of permissions. Please consult Microsoft's documentation from when
they made the same change for the .NET framework:
https://support.microsoft.com/en-us/topic/gettemppath-changes-in-windows-february-cumulative-update-preview-4cc631fb-9d97-4118-ab6d-f643cd0a7259

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I5caf11151fb2f711bbc5599231f140598b3c9d03
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-26 19:36:26 +00:00
Edward Welbourne
7afa197a44 Purge some redundant class prefixes
Within the body of QFileSystemMetaData, saying to consult it as
namespace is redundant.

Change-Id: I7347d7f19c4bf92bd1f1be14e296441334559ce2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-26 20:36:26 +01:00
Edward Welbourne
f682406162 Tolerate spaces at start and end of a POSIX zone descriptor
It's easy to do and makes an unremarkable user error harmless.
In the process, add a comment to make QTBUG-112006 visible in the code.

Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-135109
Change-Id: I6b9cb431bf5b005fc0f9cdbb5cf30c90fa1154c4
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2025-03-26 20:36:26 +01:00
Edward Welbourne
cdcaaaeee3 Straighten out QLocaleData::numberToCLocale()
It was a bit convoluted, making it hard to reason about parts. The end
of the whole number part can happen at the very end, after the loop,
or when we hit the exponent or fractional part. That means the check
of grouping rules at the end of the whole number part had to happen
after the loop as well as within it. To avoid duplication within the
loop, the handlingof exponent and fractional part was done within the
handling of grouping, reprising the exponent and fractional part after
they're handled earlier in the loop.

Package the decision-making for that handling in a lambda (and
document some relevant details there) so that the duplication is
harmless and move into the handling of the exponent and fractional
part separators, where it belongs. This lets the bulk of the loop body
simplify into a straightforward if/else-if cascade, making it easier
to reason about (in preparation for some imminent fixing of quirks and
corner cases).

Since reviewers needed to understand what the GroupSizes members mean,
in order to make sense of this, I've also added some comments to the
struct's declaration to at least let future readers know what's what.

This refactoring should be harmless and change nothing; it is also
needed by an imminent fix, that I shall pick back into LTS branches.

Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-134913
Change-Id: Ib352aa9ab8341914e40d9c087b497db15a180ebb
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-03-26 20:36:26 +01:00
Piotr Wiercinski
0dab50a124 gtk3theme: Flush PlatformTheme palette on ColorScheme change
System color palette only takes the ColorScheme (Bright/Dark) into
account during creation, which results in static color palette which
does not reflect changes requested by `updateColorScheme`.
Reinitialize the platform system color palette when ColorScheme
is changed.

Change-Id: I3f8f77a5990bda0f2db744f6ee8c6b392dfe8a84
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-26 19:35:48 +01:00
Piotr Wiercinski
caa0aa3fb4 wasm: Fix Brotli compression in qtwasmserver.py
There is not compress() function in brotli.Compressor API.
Use process().
Use requirements.txt instead of Pipfile.

Change-Id: I55a0263f16f36bcb4b96e443f85925b7d5dd15af
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-03-26 19:35:48 +01:00
Marc Mutz
75e10a0656 qcompareheleprs.h: protect CompareThreeWayTester from -Wdeprecated
The namespace contains traits to check for presence and noexceptness
of compareThreeWay() overloads. One of those overloads, the (raw) ptr
one, is deprecated, and therefore throws a warning when one of these
traits hits it. But this is beside the point, because it's not
actionable by the user.

Fix by wrapping the whole namespace in QT_WARNING_DISABLE_DEPRECATED.

This fixes one of the two remaining -Wdeprecated warnings in
tst_qcompare (which the test tries its best to defend against, by
using QT_WARNING_DISABLE_DEPRECATED around the lines, too, but it
didn't help in this case), namely this one:

  qcomparehelpers.h: In instantiation of ‘constexpr bool QtOrderingPrivate::CompareThreeWayTester::compareThreeWayNoexcept() [with LT = int*; RT = int*; typename std::enable_if<hasCompareThreeWay_v<LT, RT>, bool>::type <anonymous> = true]’:
  qcompare.h:689:91:   required from ‘auto qCompareThreeWay(const LT&, const RT&) [with LT = int*; RT = int*; typename std::enable_if<disjunction_v<QtOrderingPrivate::CompareThreeWayTester::HasCompareThreeWay<LT, RT, void>, QtOrderingPrivate::CompareThreeWayTester::HasCompareThreeWay<RT, LT, void> >, bool>::type <anonymous> = true]’
  tst_qcompare.cpp:847:5:   required from here
  qcomparehelpers.h:1229:34: warning: ‘constexpr Qt::strong_ordering Qt::compareThreeWay(const LeftType*, const RightType*) [with LeftType = int; RightType = int; typename std::enable_if<disjunction_v<std::is_same<T, U>, std::is_base_of<Container, T>, std::is_base_of<U, T> >, bool>::type <anonymous> = true]’ is deprecated: Wrap the pointers into Qt::totally_ordered_wrapper and use the respective overload instead. [-Wdeprecated-declarations]
   1229 | { return noexcept(compareThreeWay(std::declval<LT>(), std::declval<RT>())); }
        |                   ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  qcomparehelpers.h:999:31: note: declared here
    999 | constexpr Qt::strong_ordering compareThreeWay(const LeftType *lhs, const RightType *rhs) noexcept
        |                               ^~~~~~~~~~~~~~~

The last warning actually pertains to the body of qCompareThreeWay()
calling Qt::compareThreeWay() on pointers. Even though we try to
suppress that one, too, for testing purposes, it's not clear how it
can be fixed without hiding it for all users of qCompareThreeWay(), so
this is left for another day.

Amends 3d231e27a8c38f8e840e161e76be3a153d6b0aa9.

Pick-to: 6.9 6.8
Change-Id: Id434629435ea8ea89d03e46096866283ab792b54
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-03-26 16:43:22 +01:00
Rami Potinkara
9d507910db Android: Unblacklist tst_QRhi::renderPassDescriptorCompatibility
With current CI android emulation, this test seems to pass the test as designed. Does not seem to be flaky either.

Fixes: QTQAINFRA-6336
Pick-to: 6.9 6.8
Change-Id: I863b2744a63b5f90fcc42570945f3f761a3da021
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-03-26 15:43:22 +00:00
Paul Wicking
a8dab8590a Doc: Drop "Unknown base" spurious regex from config
This regex pattern instructs QDoc to not include the matching warning in
its warning count. The warning has changed to a report, however, which
won't count towards the warning count in any case, so the regexp isn't
needed anymore.

Task-number: QTBUG-131459
Task-number: QTBUG-134219
Pick-to: 6.9 6.8
Change-Id: Ic461c63b62bd25fb2d1f3b485c46db55e52e20cf
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2025-03-26 16:43:21 +01:00
Giuseppe D'Angelo
b12a5bf41a tst_qdbusperformance: include what you use (QElapsedTimer)
Pick-to: 6.9 6.8 6.5
Change-Id: I2f880d4ad38f5f3c509c8ddcdad59108d915517b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-26 16:43:21 +01:00
Volker Hilsheimer
50da9d71ad Build system: further reduce verbosity for doc builds
Amends 87965f05567d1d65af705fd61b68a02710a4fa52 by adding a comment to
the qdoc invocation that generates the documentation.

Change-Id: I7e3e0a1386d54da0fb35b1853a6032dd2949da16
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-26 15:38:19 +01:00
Marc Mutz
780c67ad80 tst_QWidget: fix a memleak in destroyedSignal()
The test checks that the destroyed() signal is emitted, even in
exceptional cases. It has three degrees of freedom:
- blockSignals() or not
- QObject* or QWidget* as the connect() sender
- slot in a child of the deleted object or in an unrelated object
  (one of the latter caused a leak of the DestroyTester)

The code was very repetitive and one scenario may have been checked
twice (QObject*, no child, blocked signals), which probably means we
forgot another (didn't check).

Make the test data-driven, and DRY further using templates for the
QObject/QWidget cases.

The leak fix is to use unique_ptr to hold the QWidget, and a scope
guard to delete the DestroyTester. I didn't want to use QPointer (or
qdialog_p's QAutoPointer), because we're checking a mechanism that
strikes very close to QPointer, and we should not depend on knowledge
of the exact QPointer implementation to convince ourselves that we're
not testing the same thing twice here. Besides, by making the delete t
conditional, we can use ASAN to detect if we got the need to delete
wrong.

Amends e72e5aa83a0a287ea7e19158b39917eb3daef1d9.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I3bac9f81c33a24e1096041dfc3323e079fd46f8a
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-26 14:38:19 +00:00
Eskil Abrahamsen Blomfeldt
3728032e03 Account for rounding error when rounding height metrics
In Qt 5 we would ask FreeType for height metrics. FreeType
always returns rounded metrics, so for e.g. DejaVu Sans at
pixel size 21 it would return ascender=20 and descender=5,
which is actually incorrect, since the actual ascender is
19.49. The descender is rounded correctly. This is likely
due to the use of fixed point math internally.

In Qt, we would account for this error by setting the
leading to -1, so that the rounded height still becomes
24. (This is also technically incorrect, since the line gap
of the font is 0.)

In Qt 6, we got the same fixed point rounding error (so
ascender becomes 20 instead of 19), but we didn't account
for the error, so we would end up with lines that were 25
high instead of 24.

To reduce the chance of getting this error, we do the full
metrics calculation in floating point numbers instead. For
the case in question, we will then get arounded ascender of
19 and descender of 5, giving us a height of 24.

Fixed point numbers are still used for storing the results,
so while it's less likely, we could still end up with the
same error. Therefore, we also apply the same trick as in
Qt 5 when this occurs: Adapting the leading of the font to
account for the rounding error if it occurs.

[ChangeLog][QtGui][Text] Fixed an issue where the line
distance for hinted fonts would be off by one for specific
sizes of some fonts.

Fixes: QTBUG-134602
Pick-to: 6.8 6.9
Change-Id: I09f1806199b7b2b02a932bb65fe4da055bd60f51
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-03-26 14:38:19 +00:00
Giuseppe D'Angelo
600388ff2a Examples: port from QCheckBox::stateChanged to checkStateChanged
The former is deprecated.

Pick-to: 6.9
Change-Id: I94de7a6c6bbea61cd75820389e8039cb92c7ee6a
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-03-26 14:57:03 +01:00
Axel Spoerl
3404a1491e XdgDesktopPortal: Prevent c'tor re-entry
XdgDesktopPortal requires a base platform theme, which is created in
its c'tor. If XdgDesktopPortal was shipped as a plugin of its own,
it would find itself as a plugin, create itself as its own base theme
and thus end up in an infinite loop.

Factor out the key check from main.cpp as a static bool in
QXdgDesktopPortalTheme.
Ignore XdgDesktop keys when scanning for plugins suitable as a base
theme.

Fixes: QTBUG-134703
Pick-to: 6.9 6.8 6.5
Change-Id: I4aab1e77a48251581369f371e4c9af308ef0a02b
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-03-26 14:57:02 +01:00
Axel Spoerl
22e05d74b2 qguiapplication.cpp / init_platform() - optimize ranged loop and style
Use std::as_const() for a QStringList in a ranged for-loop.
Use auto * for a pointer.

Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-134702
Change-Id: Ia092933fe959afdd6b6e0a9743e3603c29b291d8
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-03-26 14:33:39 +01:00
Antti Määttä
86e3573671 Rhi: Add SampleVariables feature
The feature is required to check if gl_sampleID etc are available in the
fragment shaders.

Task-number: QTBUG-134999
Pick-to: 6.9
Change-Id: Id26c75780011a7553d332ae22e69aab632891998
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-03-26 15:33:39 +02:00
Frédéric Lefebvre
7929852c1d Add QTestPrivate::ensurePositionTopLeft() for reliable positioning
Implement ensurePositionTopLeft() to set a window's position
to the available top-left corner and verify that it is correctly
positioned.

Incorrect updates to window.position and window.framePosition have
been identified as one of the main sources of flakiness on
Opensuse. This test function addresses this issue and improves test
reliablity.

Task-number: QTQAINFRA-7050
Change-Id: I946f74c7d2c1db9cfe4fec7db272e12876b3ed43
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-26 12:14:01 +00:00
Nodir Temirkhodjaev
a5268131e2 Windows: qabstractsocketengine.cpp: Fix -unity-build
Avoid the <windows.h> and <winsock2.h> conflict by excluding the file from unity build.

Task-number: QTBUG-135134
Change-Id: I34393856242ea67a30553b26a465e12d5f738cf5
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-26 17:14:01 +05:00
Marc Mutz
e89c0a7fb5 QWidgetWindow: fix UB (invalid downcast) in Private::handleDragEnterEvent()
The handleDragEnterEvent() function is not only called for
QEvent::DragEnter, but also, in handleDragMoveEvent(), for
QEvent::DragMove, in which case the fully-derived event passed as an
argument is a QDragMoveEvent, and not its subclass QDragEnterEvent.

Code in Qt seems to assume that it's ok to cast an object down to a
more-derived class than the most-derived dynamic type, as long as no
extra state is being added between the two, but C++ does not chare
that view.

Says UBSan:

  qwidgetwindow.cpp:1000:38: runtime error: downcast of address 0x7ffe7b34c6e0 which does not point to an object of type 'QDragEnterEvent'
  0x7ffe7b34c6e0: note: object is of type 'QDragMoveEvent'
   00 00 00 00  e0 62 70 42 aa 7f 00 00  3d 00 00 00 00 00 00 00  00 00 00 00 00 c0 58 40  00 00 00 00
                ^~~~~~~~~~~~~~~~~~~~~~~
                vptr for 'QDragMoveEvent'

Furtunately, handleDragEnterEvent() doesn't actually need its argument
to be a QDragEnterEvent; QDragMoveEvent suffices, so we can just
change the argument type back to QDragMoveEvent and remove the cast in
handleDragMoveEvent().

Add a bit of \internal docs to describe the discrepancy between the
function's name and argument type.

Amends f8944a7f07112c85dc4f66848cabb490514cd28e.

Picking all the way, because this is risk-less: Either the code compiles
and then it works as before (minus the UB), or it doesn't compile.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I5be53b023d389902b43e9a896d074edea1c4ff2d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-26 07:11:10 +00:00
Marc Mutz
a6743bd3c7 QFileDialog: fix UB (invalid cast) in Private::setVisible()
The function can be called from ~QDialog(), in which case a cast of
q_ptr to QFileDialog is UB.

Says UBSan:

  qfiledialog_p.h:78:5: runtime error: downcast of address 0x7ffe7a8ad5a0 which does not point to an object of type 'QFileDialog'
  0x7ffe7a8ad5a0: note: object is of type 'QDialog'
   fe 7f 00 00  30 44 d8 fb d2 7f 00 00  80 b4 00 00 90 61 00 00  08 46 d8 fb d2 7f 00 00  00 00 00 00
                ^~~~~~~~~~~~~~~~~~~~~~~
                vptr for 'QDialog'
    #0 0x7fd2f96d7587 in QFileDialogPrivate::q_func() qfiledialog_p.h:78
    #1 0x7fd2f96d7587 in QFileDialogPrivate::setVisible(bool) qfiledialog.cpp:860
    #2 0x7fd2f95465f5 in QDialog::setVisible(bool) qdialog.cpp:757
    #3 0x7fd2f6d88768 in QWidget::hide() qwidget.cpp:8179
    #4 0x7fd2f9545e09 in QDialog::~QDialog() qdialog.cpp:398

Fix by casting to QFileDialog only on show() (in createWidgets()), not
hide(), and otherwise cast at most to QDialog* (QWidget* would
actually have sufficed).

Add a code comment.

Amends e0bb9e81ab1a9d71f2893844ea82430467422e21 (I think; it might
have been present in a different form before that).

Pick-to: 6.9 6.8 6.5
Change-Id: I4e206f7c36c03e8cb8a36001beae283628960073
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-26 07:10:36 +00:00
Giuseppe D'Angelo
52d3cb8904 Examples: include what you use (QElapsedTimer)
Pick-to: 6.9 6.8
Change-Id: Icb2ae16d8d6b9083c1118ef2489fa2a1d7db9bdf
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-03-26 02:04:43 +01:00
Giuseppe D'Angelo
029407117f Examples: fix UB calls into QElapsedTimer
Calling restart() without start() is illegal, so don't do that; use
start() instead.

Pick-to: 6.9 6.8 6.5
Change-Id: I2ff5151f588cb926ccecc3d9997615e63f36ee24
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-26 02:04:43 +01:00
Volker Hilsheimer
ff14e6fe08 QGIM: implement itemData/setItemData for gadgets
If the item at index is a gadget (or QObject type), then use the
properties that match the names of the roles to get and set the item
data.

This is transactional for gadgets, where we can modify a copy until all
entries have been successfully written, and then swap the copy and the
original value if all writes were successful. It cannot be transactional
for QObject instances.

Change-Id: I514853cbd67aaf6e86c100e815c8af579b8278c2
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-03-26 01:47:18 +01:00
Volker Hilsheimer
8da1ec6a09 QGIM: support gadgets and objects as rows and multi-role values
We can interpret the properties of a gadget or object in two ways:
either as different columns in a fixed-width table, or as different
role-values in a single item, matching the named properties against
the role names.

If used in a table structure, then the properties can only be
interpreted as different role values, as we already have a row type
with multiple columns.

In a list it can be either. To disambiguate in this case, check
whether there is a "display" property. If so, then we assume that
the gadget is supposed to be a multi-role item.

Change-Id: I99400304986f643506e590c5287f4d800654ec77
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-03-26 01:47:18 +01:00
Alexey Edelev
ec5f4fe580 Use 'file(CONFIGURE' in qt_configure_file for CMake >= 3.18
Use the original functionality as the fall back solution for
the introduced by CMake 'file(CONFIGURE' command.

Pick-to: 6.8 6.9
Change-Id: I2be7e3bf80a577cdf8292c9f47bb127fa71615b6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-26 01:14:33 +01:00
Alexey Edelev
cda51bcd9c Move detecting of USE_TERMINAL flag to a separate function
The logic is generic, make it accessible from the function.

Pick-to: 6.8 6.9
Change-Id: Ib361399722dba689891d301e20b3f713450e676f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-26 01:14:33 +01:00
Alexey Edelev
2c86eaee49 Add getter for the path to androiddeployqt executable
Return the androiddeployqt TARGET, which can be used in custom commands
or if the target doesn't exist, fall back to old approach and use
the full path to the host androiddeployqt. If both are not found,
encourage users to reinstall Qt or report the bug.

Pick-to: 6.8 6.9
Change-Id: I9f487b0f0af8703a9387b9c0cf8baae47859658e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-03-26 01:14:33 +01:00
Alexey Edelev
9819e9c2e0 Move the genex that returns Android SDK tools revision to a function
The genex will be generic, so make it accessible from function.

Pick-to: 6.8 6.9
Change-Id: I83246890e2d81f3cdbbd8fe2b93d59968623a889
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-26 01:14:33 +01:00
Alexey Edelev
b434e0be79 Change _qt_internal_android_get_target_android_build_dir signature
Swap the argument order so the "output" is the first argument.

Pick-to: 6.5 6.8 6.9
Change-Id: I1325af97f1d6540c6897b51f1b5736b4534f6412
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-03-26 01:14:33 +01:00
Alexey Edelev
2adf941060 Prepend '_' to qt_internal_android_get_target_android_build_dir
Adjust the function name according to our naming convention for
private function locating in public cmake scripts.

Pick-to: 6.5 6.8 6.9
Change-Id: I3a108cdb43bd4b3d8cf29ac4c42c7c20c541afc8
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-26 01:14:32 +01:00
Alexey Edelev
f10f609db9 Move the Android deployment config type detecting to a separate function
Since the deployment config type detecting is generic, move it a
separate function.

Pick-to: 6.8 6.9
Change-Id: If925b6e14ba0d64a003e7f9ae2a5d701b7886920
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-26 01:14:32 +01:00
Nicholas Bennett
7fdf9cea6c Docs: Replace supported Android NDK r26b with r27c
Updated the macros in qtbase to propagate changes to other doc
projects. A separate change has been raised to handle multiple supported
ndks in prior LTSs

Task-number: QTQAINFRA-6479
Change-Id: Ic052f1b6b80473cc33c7f2be23049969d3cec0ee
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-03-25 14:45:15 +00:00
Nodir Temirkhodjaev
23a4b586f7 qnetworkinterface.cpp: Rename "interface" variables to "iface" to fix a unity build
On Windows the "interface" is defined as "struct".

Pick-to: 6.9 6.8
Task-number:  QTBUG-122980
Change-Id: I1a80c9e40d59449bb3c3773679a95405ea39d630
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-25 14:43:36 +00:00
Frédéric Lefebvre
76bc2dd390 Fix tst_QGuiShortcutwithQApplication::windowShortcut flakiness
tst_QGuiShortcutWithQApplication::windowShortcut() is flaky on Linux.
When it fails, the key event is not properly received properly by the
window w as it is not active.

Verify that the window w is active before sending the keyEvent, to fix
the flakiness on Linux.

Change-Id: I98961cdfa9a4f46e83f0725ef1cabc91c0f8b055
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-25 15:43:36 +01:00
Frédéric Lefebvre
0b85624480 Fix flaky tst_QMdiSubWindow::emittingOfSignals on Opensuse
tst_QMdiSubWindow::emittingOfSignals() is flaky on Opensuse where it
fails when we add a subWindow to the workspace before verifying that it
is active.

Verify if the workspace is active before adding the subWindow.

Fix the flaky test tst_QMdiSubWindow::emittingOfSignals on Opensuse

Change-Id: I7a2e0898e94efd501acc51e0b518410b6f023791
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-25 15:43:36 +01:00
Aurélien Brooke
3bfc5d0b3b Update VulkanMemoryAllocator to 3.2.1
Now that Vulkan 1.4 is available in Qt
(ff7dfd72162423e98d73728c5c9ea007b5960fe7), we set
allocatorInfo.vulkanApiVersion = VK_API_VERSION_1_4; in
QRhiVulkan::create(). But vmaCreateAllocator() asserts because the
VK_VERSION_MINOR(pCreateInfo->vulkanApiVersion) <= 3 check fails.

Older versions of the VulkanMemoryAllocator aren't compatible with
Vulkan 1.4. (issue https://github.com/GPUOpen-LibrariesAndSDKs/
VulkanMemoryAllocator/issues/457)

Update VulkanMemoryAllocator to the latest version, which is compatible
with Vulkan 1.4.

[ChangeLog][Third-Party Code] Updated VulkanMemoryAllocator to 3.2.1

Change-Id: Ic6446ad6ee61a7f35ee70b19716f88eeda5eaa60
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-03-25 13:41:31 +01:00
Ivan Solovev
4b8659ebf6 QXmlStreamReader::addData: lock encoding for QLatin1 case
This fixes a bug when addData() is used to add a full Latin1-encoded
XML document with a proper "encoding" attribute.

Once addData() is called, it immediately converts the data to UTF-8.
However, if the encoding is not locked, the parser will later see
the "encoding" attribute, and try to interpret the data according
to the specified encoding.

The QXSR(QASV) constructor is not affected, because it already locks
the encoding.

Add a unit-test for the issue.

Amends 6bc227a06a0d1392d220aa79ddb1cdc145d4f76e.

[ChangeLog][QtCore][QXmlStreamReader] Fixed a bug when calling
addData() with a Latin1-encoded string containing a full XML document
with an encoding attribute, could result in incorrect parsing of this
document.

Fixes: QTBUG-135033
Pick-to: 6.9 6.8 6.5
Change-Id: I9a35d16d743050ea4feccab3d1336747ce0abff4
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-25 13:41:31 +01:00
Volker Hilsheimer
74e5a51bab QComboBox: close the container explicitly before destroying it
QComboBox destroys the container of the view in its own destructor,
before the QWidget destructor is entered. The container is a toplevel
widget, so destroying that will destroy a platform window, triggering an
accessibility update cycle that calls back into Qt. As the QComboBox has
not yet reached the QWidget destructor, it still considers itself as
visible and focused. The accessibility query will therefore operate on
it, as the focused object. Probing the state accesses the view.

The view however is already partially destroyed, as the container's
destruction has already passed the QWidget destructor deleting all its
children. As a result, we are returning a pointer to a QAbstractItemView
that's already in the QWidget destructor, resulting in a crash.

Options for fixing this would be resetting the view pointer in
~QComboBoxPrivateContainer to nullptr and to test for that in client
code. Doing that triggered crashes in tests, as QComboBox::view() so far
has never returned a nullptr no matter the state of the combobox.

So instead, close the container explicitly before destroying it. This
way, any update cycle resulting in reentrancy (such as accessibility of
backingstore flushing when the container closes) will be completed
before objects are destroyed.

This amends fde358dd9069d0695f113ec6ba98efebedd1e520, which added the
explicit destruction of the container, for similar reasons.

This seems to be a combobox-specific problem due to the combination of
explicit destruction of (toplevel) child widgets, resulting event
processing, and exposing of internal widget states through public API
as part of the widget's accessible state.

Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-132310
Change-Id: I74df5b71906ce8153b12ddc35b897a44e7752907
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-25 12:00:54 +01:00
Eskil Abrahamsen Blomfeldt
2b5533af92 Improve underline drawing for fonts in QPainter
In the underline drawing code in QPainter there were
some issues causing

First of all, if an underline was very thick, then we would
still just offset the drawing by 0.5 (as if it were 1 pixel
wide) causing part of the underline to appear on top of the
text. The shift here is intended to move the top edge of the
underline to the top edge of the pixel where we want to
draw it, so we need to offset it by half of the actual line
thickness.

In addition, fractional line widths look bad when drawn with
aliased painting, which is the default. Depending on where
the text would be, the thickness of a line might vary. Even
if it's very close to an integer, e.g. 1.04 as in one case,
then it will still sometimes fill two pixels if it happens to
be placed directly between them. To ensure that we always fill
the same number of pixels, we round the line thickness to
nearest integer when antialiasing is not enabled.

Pick-to: 6.8 6.9
Fixes: QTBUG-134626
Change-Id: I95bae3ac16010fc133995e5f9b6c2e5d022e3743
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-03-25 10:30:31 +01:00
Axel Spoerl
bec7201f32 Correctly name pragma macro in qgenericunixtheme_p.h
It was forgotten to rename the macro from plural to singular.
Fix it.

Amends 53fb13456fffe8bfd192f9197c6d1703854b49a2.

Task-number: QTBUG-132929
Change-Id: I76def400324ae47e61528e62f8589c05c5b3e4e2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-25 06:45:05 +01:00
Marc Mutz
4293381545 tst_QGraphicsEffectSource: fix memleak in pixmapPadding()
The test function didn't delete the heap-allocated QGraphicsScene,
because, a comment indicated, there was some "corruption in scene
destruction".

Fix the memleak by creating the scene object on the stack. A local
asan+ubsan build is clean, and so is a valgrind run, so whatever it
was, it seems fixed by now.

Amends the start of the public history.

Picking back to verify that it's been, indeed, fixed in all active
branches.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Ic7f96c7195d58ccbff45b17f76fb2babd1c1b648
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2025-03-25 05:33:53 +00:00
Marc Mutz
d8b79dc1c9 tst_QGraphicsScene: fix memleaks in taskQTBUG_7863_paintIntoCacheWithTransparentParts()
The test function created QGraphicScene objects on the heap, but never
deleted them. They were added to a View, yes, but a view doesn't own
the scene it renders, so this didn't help.

Fix by creating the scenes on the stack instead.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I939e028dbfd68b216ef67c3773f085ba98817b05
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2025-03-25 06:33:53 +01:00
Marc Mutz
fdcf54062c tst_QGraphicsScene: fix memleak in taskQTBUG_5904_crashWithDeviceCoordinateCache()
The test had it the wrong way around: it deleted the QWidget it had
added to the QGraphicsScene, which thus becomes the widget's owner,
but left the scene itself undeleted, leaking it and all the items (but
not the widget ;-)).

Create the scene on the stack, so it's deleted by the compiler, and
release() the widget into the scene.addWidget() call. Since
QScopedPointer::take() is deprecated, port to std::unique_ptr.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Idbf821a35a7db802a68923fc09b185ddc3181245
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2025-03-25 06:33:52 +01:00
Marc Mutz
3651769d52 tst_QGraphicsScene: fix memleaks in selectionChanged()/removeItem()
A QGraphicsScene owns the items added to it, but if we later
removeItem() one again, then we're also responsible for freeing the
item. The test functions didn't do that, so we leaked the item.

In order to not change the rest of the functions by deleting the item
earlier than it had been before, install a qScopeGuard() to delete it,
right after we removed it from the scene again.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I8ab50626a0b5d52825bb329233ab8efe6c1291dc
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-25 06:33:52 +01:00
Marc Mutz
0617d177ac tst_QGraphicsItem: fix memleaks in sceneEventFilter()
A view doesn't own the scene it renders, because scenes can be in
multiple views. So if the test function doesn't delete `anotherScene`,
no-one else does, either.

To fix, allocate it on the stack (like `scene`), and not on the heap.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I2f0bfc5dfafd68a347553335f5ac5f2d081d56ad
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-25 06:33:52 +01:00
Marc Mutz
284283c5b2 tst_QGraphicsItem: fix memory leaks in mapRectFromToParent()
The items were not added to any scene, so nothing ever deleted them.

Hold them in unique_ptr, taking care to delete the parent, if any,
last, even though it was created after its child.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I9980530efb3386e15b81232e526a1d8d3bb3c36d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2025-03-25 05:33:52 +00:00
Marc Mutz
e9a7c4a224 tst_QGraphicsItem: fix leak of m_touchDevice
The result of QTest::createTouchScreen() needs to be deleted by the
caller, and this test didn't do that.

To fix, put the object into a unique_ptr.

Amends 982b70d37db337b2c57a3cfce0f24c3d00a598d6, though the code it
replaced seems to have had the same problem.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I361a0b37b717ac543b003fb48a4a6934b6d79a03
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2025-03-25 06:33:52 +01:00
Marc Mutz
41480dbd4a QFontDialog: fix UB (invalid cast) in Private::setVisible()
The function can be called from ~QDialog(), in which case a cast of
q_ptr to QFontDialog is UB.

Says UBSan:

  qfontdialog_p.h:43:5: runtime error: downcast of address 0x604000026b90 which does not point to an object of type 'QFontDialog'
  0x604000026b90: note: object is of type 'QDialog'
   00 00 00 00  30 a4 26 31 45 7f 00 00  80 b9 00 00 90 61 00 00  08 a6 26 31 45 7f 00 00  00 00 be be
                ^~~~~~~~~~~~~~~~~~~~~~~
                vptr for 'QDialog'
    #0 0x7f452ecad24d in QFontDialogPrivate::q_func() qfontdialog_p.h:43
    #1 0x7f452ecad24d in QFontDialogPrivate::setVisible(bool) qfontdialog.cpp:959
    #2 0x7f452ea2b5f5 in QDialog::setVisible(bool) qdialog.cpp:757
    #3 0x7f452c26d768 in QWidget::hide() qwidget.cpp:8179
    #4 0x7f452ea2ae09 in QDialog::~QDialog() qdialog.cpp:398

Fix by casting at most to QDialog* (QWidget* would actually have
sufficed).

Add a code comment.

Amends e0bb9e81ab1a9d71f2893844ea82430467422e21 (I think; it might
have been present in a different form before that).

Pick-to: 6.9 6.8 6.5
Change-Id: Ic1a63ff02b1a1435499a6980772b1b75236f31f7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-25 06:33:52 +01:00
Marc Mutz
0be1ca029c QColorDialog: fix UB (invalid cast) in Private::setVisible()
The function can be called from ~QDialog(), in which case a cast of
q_ptr to QColorDialog is UB.

Says UBSan:

  qcolordialog.cpp:72:5: runtime error: downcast of address 0x7ffd37909750 which does not point to an object of type 'QColorDialog'
  0x7ffd37909750: note: object is of type 'QDialog'
   fd 7f 00 00  30 34 6e 35 4a 7f 00 00  80 b9 00 00 90 61 00 00  08 36 6e 35 4a 7f 00 00  00 00 f2 a6
                ^~~~~~~~~~~~~~~~~~~~~~~
                vptr for 'QDialog'
    #0 0x7f4a32e8738a in QColorDialogPrivate::q_func() qcolordialog.cpp:72
    #1 0x7f4a32e8738a in QColorDialogPrivate::setVisible(bool) qcolordialog.cpp:2154
    #2 0x7f4a32ea5675 in QDialog::setVisible(bool) qdialog.cpp:757
    #3 0x7f4a306e7768 in QWidget::hide() qwidget.cpp:8179
    #4 0x7f4a32ea4e89 in QDialog::~QDialog() qdialog.cpp:398

Fix by casting to Qcolordialog only on show() (in initWidgets()), not
hide(), and otherwise cast at most to QDialog* (QWidget* would
actually have sufficed).

Add a code comment.

Amends e0bb9e81ab1a9d71f2893844ea82430467422e21 (I think; it might
have been present in a different form before that).

Pick-to: 6.9 6.8 6.5
Change-Id: I006406b6cf1012fc3c7a910abcfe14bc119a2b29
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-25 06:33:52 +01:00
Marc Mutz
49a87936ef tst_QScroller: fix leak of m_touchScreen
The result of QTest::createTouchScreen() needs to be deleted by the
caller, and this test didn't do that.

To fix, put the object into a unique_ptr.

Amends 982b70d37db337b2c57a3cfce0f24c3d00a598d6, though the code it
replaced seems to have had the same problem.

Picking all the way back, since this code hasn't changed in ages, and
so conflicts are unlikely. Also, there appears to be a remaining leak
in QScroller::grabGesture(), and we don't know, yet, how far we'd pick
that one, but verifying it will likely be helped by the test not
otherwise leaking. Filed QTBUG-135055 to track the issue.

Pick-to: 6.9 6.8 6.5 5.15
Task-number: QTBUG-135055
Change-Id: I6ab3402671f768c6a33b682d456145f18629e6cb
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2025-03-25 05:33:52 +00:00
Marc Mutz
8b4900bfff QMessageBox: fix UB (invalid cast) in Private::setVisible()
The function can be called from ~QDialog(), in which case a cast of
q_ptr to QMessageBox is UB.

Says UBSan:

  qmessagebox.cpp:182:5: runtime error: downcast of address 0x7ffdccfbda00 which does not point to an object of type 'QMessageBox'
  0x7ffdccfbda00: note: object is of type 'QDialog'
   88 7f 00 00  30 94 4a 73 88 7f 00 00  80 8c 00 00 90 61 00 00  08 96 4a 73 88 7f 00 00  00 00 fb cc
                ^~~~~~~~~~~~~~~~~~~~~~~
                vptr for 'QDialog'
    #0 0x7f8870f9a8a3 in QMessageBoxPrivate::q_func() qmessagebox.cpp:182
    #1 0x7f8870f9a8a3 in QMessageBoxPrivate::setVisible(bool) qmessagebox.cpp:1660
    #2 0x7f8870c6b3b5 in QDialog::setVisible(bool) qdialog.cpp:757
    #3 0x7f886e4ad4b8 in QWidget::hide() qwidget.cpp:8179
    #4 0x7f8870c6abc9 in QDialog::~QDialog() qdialog.cpp:398

Fix by casting to QMessageBox only on show(), not hide(), and
otherwise cast at most to QDialog* (QWidget* actually suffices).

Add a code comment.

Amends e0bb9e81ab1a9d71f2893844ea82430467422e21 (I think; it might
have been present in a different form before that).

Pick-to: 6.9 6.8 6.5
Change-Id: Ia163483c1998924a0d9c9fd589311af24a93d1fe
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-25 05:33:51 +00:00
Tim Blechmann
e72aea90fd qmetatype: silence clang warning
Change-Id: Icaa43256a8eff27725d80d43fa44aba44d2ee84e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-25 02:42:54 +00:00
Joerg Bornemann
cf2efa90fa CMake: Prevent creation of empty InputSupportPrivate module
The combination of
    -no-feature-evdev
    -no-feature-tslib
    -no-feature-libinput
led to the creation of the InputSupportPrivate module without source
files.

This triggered CMake upstream issue 23464 when using CMake < 3.25.

Fix this by adjusting the inexact condition that decides whether to
build InputSupportPrivate.

Pick-to: 6.8 6.9
Fixes: QTBUG-99957
Change-Id: If23d029f21811b6ff7c92ac9ecd2882aedb309d6
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-03-25 00:29:48 +01:00
Joerg Bornemann
dc2a73cef5 CMake: Mention "Force assertions" in config.summary
...but only if the feature has been turned on explicitly.

Fixes: QTBUG-135026
Change-Id: I4125d26b00ec14511ada5c973ffe7616a24e673c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-03-25 00:29:48 +01:00
Joerg Bornemann
28d390d30d CMake: Fix macOS -no-feature-sessionmanager build with CMake < 3.25
Work around CMake issue 23464.

Task-number: QTBUG-99957
Change-Id: I116754345190d9cd15154fcd50b1add0f625d520
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-25 00:29:48 +01:00
Paul Wicking
bf15cf1cfa Add .gitreview file
`git-review` is a command line tool for interacting with Gerrit.
Some IDEs offer support for this tool, either natively or through
plugins. The tool relies on a configuration file, .gitreview. Adding
this configuration file to our repositories simplifies initial setup
for contributors that use the tool directly or through their IDE of
choice.

The configuration file adds a remote called 'gerrit'. This is the
default for the tool, and also the name set for
codereview.qt-project.org by Qt's `init-repository` script. Thus,
the configuration should work seamlessly alongside other repository
helpers.

Task-number: QTBUG-132604
Pick-to: 6.9 6.8
Change-Id: Ic14f4ac93dae34701e2a35b1802ab2d7b740985e
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
2025-03-24 23:19:04 +01:00
Marc Mutz
e9d4412538 QKdeTheme: de-inline dtor; make ctor explicit
1/
A QStringList and an int are not a faithful representation of a KDE
Theme, so the ctor should be explicit. Make it so™.

2/
As a polymorphic class, the (undeclared, therefore inline) dtor may
cause weak vtables to be emitted, with all the bad side-effects
described in the docs of -Wweak-vtable and QTBUG-45582. Mark the dtor
out-of-line in the usual way (= default'ing, but in the .cpp file).

Amends 53fb13456fffe8bfd192f9197c6d1703854b49a2.

Task-number: QTBUG-45582
Task-number: QTBUG-132929
Task-number: QTBUG-135037
Change-Id: Ie0c14e60d76d2205c2025598ac31a917dbf870b1
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-24 21:07:15 +00:00
Thiago Macieira
4c2d3b7a4c QFactoryLoader: embed the Private class into the front-end
Simplifies the code and avoids unnecessary indirections.

It's done in a quirky way with a d member with operator->() to mostly
preserve Git history.

Change-Id: I0989ef9b4cd7a620c891fffdb521d4280896d275
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-24 12:32:04 -08:00
Thiago Macieira
411a8332a7 QFactoryLoader: remove dependency on QObject
This class doesn't have signals or slots, so it doesn't need to depend
on QObject.

Change-Id: Ie4d7f47c659f4319abb6fffd181973fbb3a91ff3
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-24 12:32:04 -08:00
Thiago Macieira
fb2ef1a66d QFactoryLoader: do destroy the staticplugin instances too
The previous commit ensured we did delete the instances of regular,
dynamic plugins when this QFactoryLoader went out of scope. This commit
repeats the same technique for the staticplugins.

Change-Id: Ic9ff94cf7a6de95c63fbfffd30b8a418c211e824
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-24 12:32:03 -08:00
Thiago Macieira
a1b78213b3 QFactoryLoader: unload the plugins we loaded
We just left everything for QLibraryStore::cleanup() to do when that ran
at QtCore unload time. Which is certainly weird because that meant no
other library could be unloaded if it was a dependency of a plugin we'd
loaded. Now, this should allow the libraries to start unloading before
QtCore, when the Q_GLOBAL_STATICs holding the QFactoryLoaders get
destroyed by ::exit().

This also explicitly deletes the instances in each of those dynamic
plugins, otherwise they may remain around and cause crashes later. This
is not done for instances coming from staticplugins - see next commit.

Change-Id: I752d41069e192c7be4a0fffd5ab0a253108b0b0c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-24 12:32:03 -08:00
Thiago Macieira
817fa23109 QFactoryLoader: also move staticplugin instances to the main thread
We already move the instances coming from dynamic plugins, but for some
reason we don't for the ones coming from staticplugins. There's no hint
about it in the history; my guess is it was simply forgotten when the
staticplugins were added.

This necessitated extending the mutex lock over the staticplugin list
scan so we'd reach the QObject::moveToThread() call too.

Change-Id: Ibe0107a9daf46792b09efffd9a7d9c45214aa589
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-24 12:32:03 -08:00
Christian Ehrlicher
a37606310e Windows11Style: don't draw progressbar label for vertical progressbars
Since the label of a progressbar is drawn right of the bar, it does not
make sense to draw a label for vertical bars. This is consistent with
windows and windowsvista style.

Pick-to: 6.9 6.8
Fixes: QTBUG-132459
Change-Id: I6610a1ef1b4074a6301aac12928c1dfe99ffd457
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2025-03-24 21:32:03 +01:00
Alexandru Croitor
9ff4b5341f CMake: Fix list(REMOVE_ITEM) usage with older CMakes
Older CMakes error out with

CMake Error at cmake/QtSyncQtHelpers.cmake:156 (list):
  list sub-command REMOVE_ITEM requires two or more arguments.

if the last expanded variable is empty.

Fix by doing an explicit non-emptiness check.

Amends e7834e90f38891382f830da7700f00ebd81f21a8

Pick-to: 6.8 6.9
Task-number: QTBUG-134672
Task-number: QTBUG-128730
Change-Id: I3c355a02519c2c450235770b2ff8c92416615a9f
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-03-24 21:32:03 +01:00
Giuseppe D'Angelo
c3762aa30a Tests: include what you use (QElapsedTimer)
Pick-to: 6.9 6.8
Change-Id: Ia0809dcba4477da97b506b4a9651b00e4ed5ab2c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-03-24 21:20:30 +01:00
Volker Hilsheimer
cd870ed5eb QGIM: initialize function pointers when constructing base class
Initialize them as part of the base-class constructor rather than
through an explicit init-call.

Coverity-Id: 478630
Change-Id: Ibd97630418650f72668be20ca3cff7f24eec8387
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-24 19:11:11 +01:00
Volker Hilsheimer
a79d5b8d08 QObject::disconnect: warn if a wildcard call disconnects from destroyed
Qt relies internally on connections to the destroyed() signal of
application-objects, for example to clean up accessibility interface
implementations or other data structures that would otherwise grow or
hold danging pointers.

The QObject::disconnect function is already documented to be potentially
dangerous, as a wildcard call (with signal, receiver, and method
defaulted to nullptr) will disconnect everything. However, what happpens
to work in one Qt release might break things in another if we add code
that relies on connections to destroyed().

To make users aware of the danger of a wildcard disconnect call, and to
help with fixing the issues that might arise, emit a warning when a
wildcard disconnect() breaks an existing connection to the sender's
destroyed() signal.

Do this while we hold the connection mutex, and only if all parameters
to the disconnect() call are wildcarded. This happens very rarely, and
should never happen in performance critical code.

Fix the only test I found emitting this warning due to a wildcard
disconnect (the drag'n'drop subsystem relies on the destroyed signal).
Store the only relevant connection instead so that we can disconnect
when done.

Fixes: QTBUG-134610
Pick-to: 6.9 6.8
Change-Id: I9e6dcade0d5572345b71e3e8f06902bbea1ef89a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-03-24 19:11:11 +01:00
Kai Köhne
fde0022854 Fix 'ICU.dll is not available' on Windows 10 1809
The combined icu.dll was only made part of the OS in Windows 10 1903.
Since we still support 1809, we cannot rely on it.

The old API unfortunately also requires explicit initialization /
deinitialization of COM with CoInitializeEx / CoUninitialize. Make sure
that initialization happens in the current thread by calling the
qt_win_ensureComInitializedOnThisThread() helper function in relevant
code paths.

Fixes: QTBUG-134540
Pick-to: 6.9 6.9.0
Change-Id: I01677ccc8bfd3780267e3c788295d4ac2b0ed93c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-24 18:11:10 +00:00
Kai Köhne
f5ac4a7f14 Windows: Add helper function to initialize COM per thread
This adapts a pattern first introduced for qtmultimedia (7398c5daa9).

Pick-to: 6.9 6.9.0
Change-Id: I4682fcf49fe074c55b4a70a1e1ec659b33b31bbb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-24 19:11:10 +01:00
Marianne Yrjänä
f673d38129 Add QNX8.0 CI enablers
Task-number: QTBUG-131708
Pick-to: 6.9 6.8
Change-Id: I60c1be5fc117e5861147d9b194106b63a8b62aab
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-24 19:01:57 +02:00
Axel Spoerl
32d23904b2 QtCore: fix build w/o itemmodel
removed_api.cpp included qabstractitemmodel.h unconditionally.
Wrap it in #if QT_CONFIG(itemmodel)

As a drive-by, add the missing blank line after the initial

    #if QT_CORE_REMOVED_SINCE(6, 8)

Amends cbda9583521633fa6e8a9274d2e47aa14c8bd175.

Pick-to: 6.9 6.8
Change-Id: I6888d9a76078a2473a0a8f063cf8b93ac3025385
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-24 15:21:45 +00:00
Alexey Edelev
6b9c494543 Avoid using the PROJECT_VERSION_MAJOR as the HostInfo variable prefix
Manage the HostInfo variable prefix the correct way. The prefix
takes the HostInfo PROJECT_VERSION_MAJOR as the version specifier,
which is not necessary is the same as the PROJECT_VERSION_MAJOR
of the project that uses respective API. Instead of relying on the
current PROJECT_VERSION, use the version info stored in HostInfo
package and adjust the prefix accordingly. This will allow version
mismatching between the project that uses API and HostInfo version.

Change-Id: Idbaec1c7bb203448ceb0f15c9173ad3985c7112d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-24 12:02:20 +01:00
Alexey Edelev
fc95651996 Make HostInfo versioned
Generate and install the HostInfoConfigVersion file for the
HostInfo package. The package had no strict version compatibility
as Qt modules before, so we avoid adding them here too.

Pick-to: 6.5 6.8 6.9
Change-Id: Iaee43639dd87d911946c8ce72c4849f43599d08e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-24 12:02:18 +01:00
Ivan Solovev
3978f3d5ec Warn if QFuture::then() is called for a QFuture with multiple results
QFuture is tricky in the sense that it can store multiple results.
The users might write the code like:

  QList<int> values{1, 2, 3};
  auto f = QtConcurrent::mapped(values, func)
              .then([](auto val) { otherFunc(val); });

with the expectation that the lambda will be called on each mapped
value of the original input container.
However, that is not true. QtConcurrent::mapped() returns a QFuture
which has multiple results, and in this case only the first result will
be passed to the then() continuation.

We cannot detect this problem at compile-time, because we do not know
how many results will the QFuture hold. So, add at least a runtime
warning.

The warning is added in a new logging category, so that the users who
really need this behavior can disable it. The warning is implemented
as an exported out-of-line method for two reasons:
* To avoid code duplication for each template parameter of
  CompactContinuation.
* To avoid exposing a Qt-specific logging category into a public header.

Such design, however, prevents us from cherry-picking the change to
older branches.

Fixes: QTBUG-133522
Change-Id: I3344b5228b50e9c9d68d0c57961bbc969f566bb9
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-03-24 11:39:34 +01:00
Ivan Solovev
4b18a8946b docs: Clarify adding a continuation to a QFuture with multiple results
Explain that the continuation should take QFuture<T> as a parameter in
order to be able to access all results.
Add notes with examples to the QtConcurrent::mapped and
QtConcurrent::filtered overviews.

Task-number: QTBUG-133522
Pick-to: 6.9 6.8 6.5
Change-Id: I65655aadc8d4623b147d22a9bf9b2189c80b14c5
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-03-24 11:39:34 +01:00
Antti Määttä
6a534cf504 Mark QCtfServer as security critical
QCtfServer uses QTcpServer to accept connections with security sensitive
commands.

Pick-to: 6.9 6.8
Change-Id: I793e716560fedcf6155f36beeeafdcc0429fe092
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-24 11:43:09 +02:00
Volker Hilsheimer
dc3fb041e9 QGIM: implement itemData/setItemData for associative containers
If the item at index is an associative container, then we can operate
directly on that container. Otherwise, call the base class
implementation.

In contrast to the default implementation, the setItemData
implementation is transactional: nothing will be written to a multi-role
storage unless all entries could be written.

Change-Id: I883c647dac82b3a068afd77b36c245525d59b44b
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-03-24 05:59:51 +01:00
Volker Hilsheimer
9f63577ddd QGIM: test if a tuple row is valid before dereferencing
Row types that are convertible to bool, such as pointers, but also
unique_ptr and similar wrappers, should not be dereferenced when
accessing values for reading or writing. This is already done implicitly
when operating on single-value types, but for tuples we have to do so
explicitly, before accessing the element.

For example, inserting a row where the row type is a pointer will leave
that row be nullptr in the range, and both data and setData should fail
until a row has been constructed. For rows that are pointers to tuples,
we must never call get<>, as get cannot test if the item received is a
nullptr and still return a valid value (reference).

Since e.g. unique_ptr is explicitly convertible to bool we have to use
std::is_constructible rather than is_convertible, as the latter only
works for types that are implicitly convertible.

Change-Id: I9dbdf6e5cac0146ed5d1b88c523e182590b0c8ab
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-03-24 05:59:45 +01:00
Marc Mutz
5be58ac927 tst_QWidget: don't leak QStyle objects
The result of QStyleFactory::create() must be deleted by the caller.

Some test functions stored it in a QScopedPointer, while others
didn't, each causing a leak of a QWindowsStyle object.

DRY the test functions (except the one that checks that 'delete
widget.style();' works) by introducing an owning pointer at the test
class level, to be reused by test functions. This is not so much for
caching the object across test functions (though this is a nice
benefit, too), but in order to keep the owning pointer out of the test
functions, and allow most functions to just do

   setStyle(deterministicStyle()).

Found by ASAN.

On my machine, this test is now ASAN-clean, except a) the usual
cp-demangle.c leak and b) destroyedSignal(), which still leaks.

As a drive-by, pass a QStringLiteral instead of QL1SV to
QStyleFactory::create() and port one QVERIFY( != ) to QCOMPARE_NE().

No amends, it'd be too many. Not picking back far, because others
don't care, and I expect lots of conflicts when backporting, due to
many different amended commits.

Pick-to: 6.9
Change-Id: Ie9e7faf21bc177e08af56c659dc58870ad3cf6ff
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-23 16:49:26 +00:00
Alexander Stippich
2428cbf44e rely on CUPS for multiple page ranges in unix version of QPrintDialog
Since the introduction of QPageRanges with Qt6, multiple/arbitrary page
ranges are broken in the unix implementation of QPrintDialog due to a
possible double application of the page ranges: on the application side
and on the server side with CUPS. Reason for this is that the
QPrinter::PrintRange is set to PageRange instead of AllPages.
The latter is needed when relying on the CUPS server-side page range.
However, the server-side page range is always applied later on.

Restore the behavior of Qt5 and set the PrintRange to AllPages for
multiple/arbitrary page ranges and rely on the server-side filtering
with CUPS.

Pick-to: 6.9 6.8
Change-Id: I1b85552a8cf2509b11a81db028f957584043f3ee
Reviewed-by: Albert Astals Cid <aacid@kde.org>
Reviewed-by: David Faure <david.faure@kdab.com>
2025-03-23 13:12:17 +00:00
Marc Mutz
f4dd7e29a6 QMessageBox: really fix UB (invalid cast) in Private::canBeNativeDialog()
The code comment above the cast is correct, but the code wasn't: While
we're receiving the result of the cast in a QDialog pointer, the cast
is still to QMessageBox*, and whether that cast is in the Q_Q macro or
not doesn't change the fact that it's invalid.

Says UBSan:

  qmessagebox.cpp:2804:31: runtime error: downcast of address 0x7ffebfd87140 which does not point to an object of type 'QMessageBox'
  0x7ffebfd87140: note: object is of type 'QDialog'
   2b 7f 00 00  30 94 57 b9 2b 7f 00 00  80 8c 00 00 90 61 00 00  08 96 57 b9 2b 7f 00 00  00 00 d8 bf
                ^~~~~~~~~~~~~~~~~~~~~~~
                vptr for 'QDialog'

The trivial fix is to cast only to QDialog.

Amends 29b2506e8cf0c792821a3ddb28e62080cd66ae28.

Pick-to: 6.9 6.8
Change-Id: Ia3f6c08b62f6bed274f43baab881a0d802bd986b
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
2025-03-23 13:25:39 +01:00
Giuseppe D'Angelo
22e212b685 QProcessTask: include what you use
Pick-to: 6.9 6.8
Change-Id: I62d02bf914effa2d86e43ea178e5007acf9935c4
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2025-03-23 13:25:39 +01:00
Christian Ehrlicher
6e8b6250e7 Windows11Style: Don't modify palette for QCommandLinkButton in polish()
The windows vista style modifies the palette for a QCommandLinkButton to
match the vista style. For windows11 we simply use the same color as for
a normal button so no need to modify the palette is needed.
Since the vista style does not reset the palette on style change, the
wrong color is still used in the widgetsgallery example when switching
from vista to win11 (or fusion).

Pick-to: 6.9 6.8
Task-number: QTBUG-130480
Change-Id: I963215295ee1d2e483b5b58045752474c920c64b
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2025-03-23 09:53:19 +01:00
Volker Hilsheimer
c4cef19d58 QGIM: support associative containers for multi-role items
If the range used with QGenericItemModel contains associative containers
that map from Qt::ItemDataRole, int, or QString to QVariant, then we
interpret such values as multi-role items, and look up the respective
value for the role requested.

Add test coverage and documentation.

This change does not implement QAbstractItemModel::itemData/setItemData.

Change-Id: I00aa8da9369a20ea4ddb58bb24c45fef9465b33f
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-03-23 03:16:39 +01:00
Volker Hilsheimer
984074eea2 Doc: remove stray 's'
Amends 4409edc14b8a593640c1eb22560a6ba249336163.

Pick-to: 6.9 6.8
Change-Id: I1502e0d63a845c5deb476af1c37cb89a6cc43c6c
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-03-23 03:16:38 +01:00
Marc Mutz
9f2db4acd7 QFileSystemModel: remove an unneeded const_cast
QAIM::createIndex() takes a const void* pointer, so we don't need to
const_cast the const away.

Amends the start of the public history.

Picking all the way back, because I'm hunting a memleak here, and
can't say, yet, whether these lines need to be modified or
not. Besides, this change is 100% safe: either it compiles and works
as before or it doesn't compile. There is no silent breakage possible.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I2f9284540beed9d1ab027ac1e24f1c527537e122
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-22 20:24:02 +00:00
Artem Dyomin
47cf043329 QGIM: Add utilities for generic access of keys and values of iterators
Since Qt associative containers don't have the same iterator API as
their std equivalents, generic access to the key/value pair of a
container will be useful when adding support for multi-role storage
types and sparse tables.

Change-Id: I409e94485257982ac8a231f9bffd791a53867968
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-22 18:38:04 +01:00
Fabian Kosmale
0a567a7f92 Q_DECLARE_OPAQUE_POINTER: Document footgun
Using Q_DECLARE_OPAQUE_POINTER means that the metatype system won't have
any knowledge about the type, beyond it being a pointer. That leads to
all kinds of unexpected errors in code that needs to introspect the
meta-type information to handle QObject's and gadgets, notably but not
limited to QML.

Warn about using Q_DECLARE_OPAQUE_POINTER for gadgets and QObject's, and
offer Q_MOC_INCLUDE as a potential alternative for some use cases.

Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-127012
Task-number: QTBUG-134883
Change-Id: I4fe53f277d0aa51ef552d04f642364aa6613ef7c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2025-03-22 00:07:20 +01:00
Kai Köhne
68a1655817 Doc: Fix QThread documentation snippet
WorkerThread needs an explicit constructor, otherwise

    WorkerThread *workerThread = new WorkerThread(this);

will fail. While at it, at some infrastructure code so that the
.cpp file actually compiles.

Pick-to: 6.9
Change-Id: I35835b1be3da2a1f75222594197f6013b41a7b4a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-21 22:31:51 +01:00
Volker Hilsheimer
04fbdd2552 mac a11y: ignore expected debug output from test
Don't confuse the next person working on this code.

Pick-to: 6.9 6.8
Change-Id: I3f9ff59299a4150a96cc11d851d06539a5701a70
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-21 22:31:51 +01:00
Volker Hilsheimer
f5115a9137 Long live QGenericItemModel for lists and tables
QGenericItemModel provides a QAbstractItemModel implementation that can
make any C++ range with a cbegin/cend iterator pair available to Qt's
model/view framework.

To avoid subclassing a polymorphic type with a template, resulting
in weak vtables, the calls are dispatched through a set of static
helpers similar to existing pattern in e.g. QObject or QRunnable.

The public QGenericItemModel class is then a subclass of
QAbstractItemModel, where only the constructor is a template that
instantiates the specialization of QGenericItemModelImpl. The virtual
function overrides dispatch the call through the static helper to the
template class operating on the range.

The core of the implementation is the template class
QGenericItemModelImpl, that implements the QAbstractItemModel
functionality on top of iterator APIs. Implementations that are
specific to the structure of the model, i.e. whether it is a flat table
or list model, or (in a later commit) a tree, are in a base class of
QGenericItemModelImpl, QGenericItemModelStructureImpl. It uses CRTP
with decltype(auto) where we would otherwise have a return type that
is dependent on the (not yet fully specialized) implementation type.

The data for the model can be provided by copy, rvalue reference, or
pointer. If provided by pointer, the model will modify the original
data. Functionality that requires that the model itself, or the data
in the model, can be modified is compiled out if the model or data
is const.

The initial implementation supports lists and tables, where tables can
be nested containers (like `std::vector<std::vector<item_type>>`), or
as structs that implement the C++ tuple protocol.

Include test framework and documentation, as well as a snippet-project
that tests the code snippets.

[ChangeLog][QtCore] Added QGenericItemModel, a QAbstractItemModel
implementation that make any C++ range with a cbegin/cend iterator pair
available to Qt's model/view framework.

Change-Id: I8ff2b95cde2566f422f3aee7912660a8cb217397
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2025-03-21 22:31:50 +01:00
Joerg Bornemann
17a9343ace Doc: Fix typos in qt_deploy_runtime_dependencies documentation
Pick-to: 6.8 6.9
Change-Id: I273f4e8626df6242e82e015d76e5692b29afdec1
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-03-21 21:38:12 +01:00
Giuseppe D'Angelo
643086b135 tst_qlatin1stringmatcher: include what you use
Change-Id: I35a6e9b4c3fa9e04add85db790a6b6dc42e51a48
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-21 21:38:12 +01:00
Fabian Kosmale
fdb569a3e2 QKdeTheme: Don't leak resources on shutdown
The theme stores an array of pointers to allocated QFonts, which need to
be freed.

While this is not a "hard" leak (the OS will clean up the memory on
shutdown, and QKdeTheme lives as long as the application), it creates
ASAN warnings, which distract from more severe issues.

Change-Id: Iaa57138e5273c300c616ba85340283f18a267b09
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
2025-03-21 16:48:50 +01:00
Mårten Nordheim
930dfd11dd Mark QHttpNetworkConnectionChannel as final
To suppress clang-tidy's
bugprone-pointer-arithmetic-on-polymorphic-object
because we store a dynamically allocated array of
QHttpNetworkConnectionChannel objects in QHttpNetworkConnectionPrivate
and index into this all over the code.

Pick-to: 6.9 6.8
Change-Id: Ibcdf7c8acc4a57eaf36bca3719733655053ac818
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-03-21 14:25:21 +00:00
Alexey Edelev
56ec6b4843 Avoid using the PROJECT_VERSION when accessing the HostInfo package variables
The related functionality meant to be enabled by BuildInternals, which
makes the lookup of the pre-defined HostInfo version based on either
calculated or pre-defined INSTALL_CMAKE_NAMESPACE.

The PROJECT_VESION(_MAJOR) meanwhile is hardcoded by the current Qt
repo, which is not necessary aligned with BuildInternals/HostInfo.

Pick-to: 6.5 6.8 6.9
Change-Id: I61052c93ce2d6ee3c6d8025da2e078edcde48d0d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-21 12:55:49 +01:00
Alexey Edelev
a67c13d1a6 Make the HostInfo package lookup properly versioned
Avoid hardcoding the HostInfo package version, use the
INSTALL_CMAKE_NAMESPACE as the reference for the find_package calls.

If we assume that the package follows the versioning in the future,
we should consider the Qt version, to avoid any version related
issues.

Pick-to: 6.5 6.8 6.9
Change-Id: If84550ab82f8de51ff5af41c7f31838c4ed53a67
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-21 12:55:49 +01:00
Michał Łoś
276ccda2f3 Pass VxWorks touch ranges via environment variable
Some VxWorks touch device drivers return improper value of min and max
ranges in both axes (both 0 for both axes). This makes any touch point
position equal to (0, 0), making touch unusable in Qt.

[ChangeLog][Platform Specific Changes][VxWorks] The user can now
override touch ranges that the driver returns, by setting the
new parameters "rangex" and "rangey" on the environment variable
QT_QPA_VXEVDEV_TOUCHSCREEN_PARAMETERS with comma-separated
min and max touch ranges for X and Y axis respectively.
For example, add rangex=10,815:rangey=15,1024

Pick-to: 6.9
Task-number: QTBUG-115777
Change-Id: I4f4aba7ee66e76b80438888697f84c4db9896c3d
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2025-03-21 11:55:48 +00:00
Marc Mutz
d624454586 QDBusListener: remove ChangeSignal's defaut ctor
Coverity complained that the default ctor didn't initialize its two
members. This is true, and it even remains true if the user of the
type explicitly asks for value-initialization (ChangeSignal s = {}) as
opposed to default-construction (ChangeSignal s;).

Remove the default ctor as the minimally-possible fix. It was only
needed because of a call to QFlatMap::value(1-arg), which,
incidentally, constitutes a double-lookup, because it is following a
contains() call. Replacing that combo with find() and it.value()
avoids the double-lookup and removes the need for the type to be
default-constructible.

Amends 0328e4297e339de8a2acd84979c667936f6fadf8.

Coverity picked this up as a new issue following
53fb13456fffe8bfd192f9197c6d1703854b49a2, so there probably is another
CID for this for the same code in the old location, but my Coverity
search-foo is insufficient to find the corresponding CID, without
undue effort, so I didn't try.

Coverity-Id: 478089
Pick-to: 6.9 6.8 6.5
Change-Id: I912bf2af343b98fe62faf2d4bf8a6d1f385593e8
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-21 07:05:13 +01:00
Marc Mutz
536cd1ce20 QTriangulator: make a primeForCount() precondition explicit
Coverity complains that the binary search algorithm can yield high =
32, which, when passed to primeForNumBits(), will overflow
prime_deltas[]. This is true, for negative 'count', or, more general,
if the MSB of 'count' is set.

Add a Q_ASSERT(count >= 0) to inform Coverity (and other readers of
the code) that this function is only expecting non-negative arguments.

Amends 4adf5e1a9ef4fe78f4b70b7462943246903f4f11, which didn't fully
solve the issue, at least not as far as Coverity is concerned.

Pick-to: 6.9 6.8 6.5
Coverity-Id: 11295
Task-number: QTBUG-134543
Change-Id: I994dd1d1850c6644188a9fc0b83973614dd51e6b
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-03-21 06:04:39 +00:00
Marc Mutz
39aac93438 QUrl: add a link in a code fragment
Writing "adjusted()" would have produced a link automatically, but
since an argument is present, the function name is not a link. Add it
manually. Omit the parentheses and the argument, because that's how
QDoc renders "adjusted()", too (only the function name is the link).

Amends 1aa4ad46e4878072be9acb8389572e7f9e8198df.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I350a277f91e486256ca014e554beea3348b6ca96
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-21 06:04:29 +00:00
Thiago Macieira
895b1c0ab3 JSON/CBOR: fix conversions from QVariant containing longs and qfloat16
[ChangeLog][QtCore][QCborValue] Fixed conversions from QVariant when the
variant contained long, unsigned long, or qfloat16.

[ChangeLog][QtCore][QJsonValue] Fixed conversions from QVariant when the
variant contained long, unsigned long, or qfloat16.

Pick-to: 6.9 6.8
Fixes: QTBUG-134756
Change-Id: I08d069dd639c0fc5a15afffd4067762ec94d606d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-20 19:15:37 -07:00
Thiago Macieira
e8127dc79d QVariant: replace spaceShip() function with Qt::compareThreeWay()
Which will use the actual spaceship operator if Qt is compiled in C++20
mode. Hopefully this will generate better code than the explicit
content, especially for floating point types, because the compiler
recognizes the <=> operator.

Change-Id: I1313aafe7ca105eca510fffd46e1d1932a0943bc
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-20 19:15:08 -07:00
Thiago Macieira
a4daf49396 QVariant/QMetaType: fix conversions to/from qfloat16
Needed to make some conversions explicit, since you can't assign to a
qfloat16 from double.

[ChangeLog][QtCore][QVariant] Implemented converting of qfloat16 to and
from the other numeric types, text conversions to and from QString and
QByteArray, and conversions to and from QJsonValue and QCborValue. This
should make qfloat16 behave the same as float and double.

Also flip the order of arguments in one of the addComparePairs(): left
side is actual, right side is expected. I noticed on the copy & paste
to do the qfloat16 above it.

Pick-to: 6.9 6.8
Task-number: QTBUG-134756
Change-Id: I6a6c469d21746a07c18efffd6b3b961c73c0e2f2
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-21 02:14:59 +00:00
Thiago Macieira
ab45c44fb5 QVariant: use QMETATYPE_CONVERTER_ASSIGN_DOUBLE to convert from QCborValue
No-op change. All this does is explicitly wrap the right side of the
expression in a double() function-style cast.

Pick-to: 6.8 6.9
Change-Id: I84bc14bf75b4d0a046dcfffd19f318eaf7fe0e9f
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-03-20 19:14:56 -07:00
Thiago Macieira
42e0f98110 tst_QVariant: overhaul the conversion-comparison tests with templates
This makes the tests more exhaustive than they were, with far less
repetition. Also adding the testing of conversions for which we don't
have a toXxx() getter, because those exercise different code paths
inside of QVariant, and yet should produce the same result.

Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-134756
Change-Id: I99664a53da674bcbd992fffd5f290cfe51259d5b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-03-20 19:14:27 -07:00
Giuseppe D'Angelo
4a3e56ee87 QJUnitTestLogger: include what you use
Adds a missing include for QElapsedTimer.

Pick-to: 6.9 6.8
Change-Id: I3dbc19eb38bb44cae1e38a0c72981a14bc571cd5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-20 23:12:53 +01:00
Marc Mutz
b291047a4d QGenericUnixTheme: de-pessimise xdgFileIcon()
Coverity complained about a missing std::move() on the return in L270,
but adding that would, of course, not help, because the QIcon object
being returned is const.

If NRVO would (at least theoretically) kick in, this would be
harmless, but NRVO can't kick in, because it's unknown at the time of
construction whether this will be the object that end up being
returned to the caller, so the compiler will have to copy the object
into the return value when that decision is made (post the isNull()
check).

By not making the object const, we enable it to be moved instead,
which is what Coverity originally wanted us to do.

Amends 46ea82188e3678c5b7a2338d536da6c621822f2f.

Coverity picked this up as a new issue following
53fb13456fffe8bfd192f9197c6d1703854b49a2, so there probably is another
CID for this for the same code in the old location, but my Coverity
search-foo is insufficient to find the corresponding CID, without
undue effort, so I didn't try.

Not picking back, as this is a "low impact" issue, according to
Coverity (and me).

Coverity-Id: 478087
Change-Id: I7f36cdbe83525a23ea0dfa27157091dbdf73a28b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2025-03-20 23:00:52 +01:00
Marc Mutz
8aab205d6d qvkgen: fix Coverity complaint about uninit'ed data member
Coverity complains that in the first return from
VkSpecParser::parseCommand(), the c.deviceLevel member is left
uninitialized. Correct, but harmless, since the only caller of the
function discards results with an empty 'cmd.name`.

To nonetheless fix this issue, return {} instead of c. This allows
Coverity to continue diagnosing premature returns (which initializing
c or c.deviceLevel explicitly would take away), at the cost of
breaking NRVO in the function. qvkgen being a tool, I think we can
live with that.

Amends ff7dfd72162423e98d73728c5c9ea007b5960fe7.

Coverity-Id: 478090
Change-Id: I8744765f893580c59215da351c37d3cbfa960e55
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-03-20 21:59:27 +00:00
Alexandru Croitor
e7834e90f3 CMake: Fix dbus and vk headers to be excluded from doc generation
Before this change, if someone called ninja Gui_generate_docs, it
would implicitly depend on sync_all_public_headers -> Gui_sync_headers
which would generate dbus headers.

This caused trouble with the new 'build doc tools from
qttools/dev/HEAD' approach, because an older pre-built dbus tool might
be passed a newer option when integrating a qtbase change that passes
the new option.

To avoid that, we now filter out the dbus headers from the list of
headers that should be processed by syncqt when building a
documentation target.

We do the same for the qvkgen generated headers.

This also removes the dependency on the ${target}_sync_headers target,
which means there is a potential issue when someone manually calls
`ninja sync_all_public_headers Gui_sync_headers` or something like it,
which would spawn two syncqt processes that access the same files
concurrently. This is an edge case that should not happen, but if it
ends up happening, we will have to implement some kind of lock file
mechanism.

Pick-to: 6.8 6.9
Fixes: QTBUG-134672
Task-number: QTBUG-128730
Change-Id: I9061f9495e2faa77744f5f5c0de8fedd362ba228
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-03-20 21:15:12 +01:00
Mårten Nordheim
4c9a4ecd35 QNetworkAccessManager: don't resend non-idempotent requests
Requests that may lead to a different state when performed multiple
times (non-idempotent) should not be automatically re-transmitted if an
error occurs after we have written the full request.

We assume all custom methods are potentially non-idempotent.

[ChangeLog][QtNetwork][QNetworkAccessManager][Behavior Change]
Non-idempotent requests are no longer incorrectly re-sent if the
connection breaks down while reading the response.

Fixes: QTBUG-134694
Pick-to: 6.9 6.8 6.5
Change-Id: Ie8ba7828ce9375359c2326f06426fe1a1e568fef
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-03-20 20:37:24 +01:00
Christian Ehrlicher
7a238e1225 QLabel: don't cache scaled pixmap in QIcon
Caching the scaled QPixmap directly in QIcon is not a good idea
 - the cached pixmap might be used as starting point for a pixmap with
   another size so it gets blurry
 - QIcon has no caching mechanism to throw away unneeded QPixmaps after
   some time so the memory usage grows indefinitely

Pick-to: 6.9 6.9.0
Fixes: QTBUG-134930
Change-Id: Ic490ba15438a5cd07a555692e1d08cd1c211d005
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-20 19:37:23 +00:00
Volker Hilsheimer
bd6e55c856 macOS a11y: collapse branches on identical condition
No need to test twice whether the row's columns array is initialized.

Pick-to: 6.9 6.8
Change-Id: Iead06f98ad421202bb4b71ae8efbd784ab3e87c1
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-20 19:59:44 +01:00
Edward Welbourne
60c2eac401 tst_QTextStream: convert macros to templates called inline
Change-Id: Iacb92a91c4684185e6bff77f13b5ef0f2a41ce40
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-20 19:36:16 +01:00
Edward Welbourne
dabdadfdec tst_QTextStream: inline trivial _data() methods
Declare their shared implementations const in the process, since they
are.

Change-Id: I678025dae367417535a00c9f3673d6ea2e866be5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-20 19:36:16 +01:00
Edward Welbourne
05c8a48612 Correct case of QLocale::toString(double, ...)'s exponent separator
The function follows various libc functions in forcing the caller to
decide the case of the exponent separator, rather than allowing them
to opt for the case the locale normally uses. At Qt 6 I changed the
code reading from CLDR to not force the case, but didn't change
toString() to force lower when that was requested. Since the function
is documented to use lower-case when that's what it asks for, change
it to do what it says in its documentation. A caller who wants the
locale-appropriate case is thus obliged to call exponential() and scan
it for lower- or upper-case letters and select the right one of 'e'
and 'E' (or 'g' and 'G') to match.

This partially reverts some test changes made in
commit d5bb8d5150498dc059e8c17f224c66fb1a6bcf32 and expands the
QLocale tests to include ones matching those it changed. Fixed some
tests of QDoubleValidator that previously turned 'e' in the input into
'E' in the output; roughly alternate between changing the input to
match the output and the other way round, to be sure we exercise both
branches of the test.

Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-134785
Fixes: QTBUG-134768
Change-Id: I5cffbd772a166efab9f7a5145289771c16be1658
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-20 19:36:16 +01:00
Edward Welbourne
8c88a077cc QDoubleValidator: don't assume the locale's exponent separator is 'e'
Some locales even have multi-character exponent separators. Scan the
actual locale-appropriate separator to determine whether it contains
any cased characters; if upper, prefer 'E' format, of lower prefer
'e'; but match the case of the input string in any case, when it has
case. Use 'e' when it has no case.

This doesn't currently change any test data, due to the bug that
QLocale::toString(double, 'e',...) uses the locale-appropriate case,
even if that is upper-case, contrary to its own docs. However, fixing
that bug breaks some of the tests of QDoubleValidator without this fix
to prepare for it.

Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-134768
Change-Id: I0ba5bbdb507b8b6efdf6dc134c387fd3b4bcbeb2
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-20 19:36:16 +01:00
Magdalena Stojek
2edb569773 Add translation lookup for mimetype descriptions
Extend QMimeType::comment() to support translations from .qm files as a
fallback when system-provided translations (e.g., shared-mime-info) are
unavailable.

Pick-to: 6.9
Task-number: QTBUG-127004
Change-Id: I23060ab7a690c774691b2d96174e77a252c047ad
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-20 14:30:51 +01:00
Joerg Bornemann
d8f34049ff CMake: Fix generation of precompiled headers in per-repo Qt builds
When a Qt module Foo links against a Qt module Bar then we add the
${QT_BUILD_DIR}/include/QtBar/QtBar header to the list of precompiled
header files. However, this only works if Foo and Bar are in the same
build system, e.g. in the same repository or in a top-level build. For
example, the QtCore header was never precompiled when in a per-repo
build of QtSvg.

Now, we determine whether Foo and Bar are in the same build system. If
they are, we proceed as before. Otherwise, we calculate the QtBar
header's location from the following data:
- the location of Qt6BarConfig.cmake
- the relative path to Bar's include directory

The Q*Application tests' project files had to be adjusted to use
NO_PCH_SOURCES now, because they use the source file
apphelper_plugin.cpp that specifically checks that pre-compiled headers
are not used for its compilation.

Fixes: QTBUG-134424
Change-Id: I04ede51e4d853e8b813f660f29be8cfeb684c0b2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-03-20 14:29:51 +01:00
Joerg Bornemann
11dcc9018d CMake: Add NO_PCH_SOURCES argument to qt_internal_add_cmake_library
Forward NO_PCH_SOURCES to qt_internal_extend_target and port to
_qt_internal_forward_function_args while we're at it.

Change-Id: I0c62e84c5a22f937904c1949ff34d0171a1a937f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-20 14:29:48 +01:00
Giuseppe D'Angelo
ab1d9772aa tst_qeventdispatcher: include what you use
Pick-to: 6.9 6.8 6.5
Change-Id: Iae24fd5186946b6389e46b6bb69e393e353cb898
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-20 10:48:18 +01:00
David Redondo
f9e319dde3 Move platform plugin to main client directory
In preparation for the qtbase move

Task-number: QTBUG-133223
Change-Id: I280448dfd88ffdcace9a04c95f5cd2f4591522a1
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-20 10:15:41 +01:00
Lorn Potter
13e9228319 wasm: fix compositional input event handler leaks
Change-Id: Ia6d7b9972c126b926e1d7d458ef4e034edbc924a
Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-03-20 18:53:24 +10:00
Marc Mutz
0d0a151e0d QSqlQueryModel: memoize roleNames()
The return value of this function is constant and some users (QML?)
may call this function often, so memoize the result of the function
instead of re-creating the QHash on every call.

Amends 40206a9f6d7635bb19305d1c8d74908808e3529e.

Not picking to Qt 5, because I'm unsure about the state of magic statics
there, and I don't want to take out the Q_GLOBAL_STATIC sledgehammer.

Pick-to: 6.9 6.8 6.5
Change-Id: I8311e93ea16982c82e8312e1e104d95ed062fe6b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-03-20 06:14:33 +01:00
Ahmad Samir
fce5fdb4d1 QTimer: clamp too-large milliseconds intervals to INT_MAX ms
QTimer stores the interval in an int, a milliseconds interval that is
too-large will overflow and the value becomes negative. Clamp the
interval to INT_MAX ms. This also matches what QTimer::from_msecs()
does.

Amends f1f610bc67bfd5c2ef31270a6945e7bae93b5e4a.

Change-Id: Id925827f632e8a8d8b8b65e6a41e8f8722344c26
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-20 06:18:43 +02:00
Marc Mutz
bb846a22c3 QUuid: fix qHash() on 64-bit platforms
The old implementation from Qt 5 time only affected the 32 LSB of the
result. The upper bits were completely determined by the seed, and the
seed alone. To see this, note that all except the seed are at most
32-bit values, and no shifting out of that range occurs, either.

Fix by just using qHashBits(), making sure (with a static_assert())
that QUuid has unique object representation (= can be compared for
equality using memcmp()).

[ChangeLog][QtCore][QUuid] Improved the performance of the qHash()
function on 64-bit platforms by populating all bits of the output
(was: only lower 32 bits).

Amends 55d68a16aafb93aa15bcdbd78892006777b6067a.

Pick-to: 6.9 6.8 6.5
Change-Id: Ibf67350f571889fd21e0acc82639c053c0d606b6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-19 21:30:15 +00:00
Thiago Macieira
4a15417077 QMessageLogger: store the QT_FATAL_xxx state plus one in the atomics
Just so they're constant-initialized to zero and thus don't occupy disk
space in QtCore.

Change-Id: I2f876ef66b5f789c7642fffdfe073dbd65ea7a6d
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-19 14:33:45 -03:00
Thiago Macieira
009131e556 QMessageLogger: initialize QT_FATAL_xxx cooperatively between threads
The use of function-local static implied there was a guard variable to
perform a thread-safe initialization (a critical section). We don't need
that: we can just use a plain QBasicAtomicInt and cooperatively
initialize, in parallel. This way, the QMessageLogger code does not need
to check the status of the guard variable before every access to the
atomic, which would be an atomic access before the atomic access.

Change-Id: Iedfbe8e28ca5168dea43fffddf205d122c97f71c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-19 10:33:44 -07:00
Thiago Macieira
c8ecd0eb22 QMessageLogger: reject negative values for QT_FATAL_xxx
Amends ceb859bf036dfdd1c54eec403006eac62a0d09b8

We'd accept negative values and keep counting downwards, reaching 0
again only after a full underflow[*]. Effectively, this meant that a
negative value was the same as zero, so this makes the behavior
explicit. The commit introducing checked_var_value() said in its
changelog:

 For compatibility reasons with previous
 versions, if the variable is set to any non-empty and non-numeric value
 different from 0, Qt will understand as "stop on first warning".

Negative values are not "non-empty and non-numeric", so this commit
chooses to make the current behavior explicit.

[*] atomic under- and overflows are defined behavior, but only if the
atomic operation is the one producing it. The current code is doing the
subtraction by itself in the call to testAndSetRelaxed(), so underflows
are still UB. If/when this is replaced by atomicMutate, that might
change (and note to self when implementing that!).

Pick-to: 6.9 6.8
Change-Id: I594ed31f1cc7fc04ea98c6e86bdcaa3a4aa59114
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-19 10:33:40 -07:00
Thiago Macieira
6e37cd4176 QMessageLogger: Make sure we don't count to 0 QT_FATAL_xxx
Amends commit b933a5668cc5647d26378f8a9a52901d0497585d ("Make sure we
don't count down past 0 QT_FATAL_CRITICALS"), which introduced the CAS.

Apparently it was a design decision then that only one thread would call
qAbort(), while the others would happily continue. For example, for the
common case of QT_FATAL_WARNINGS=1:

    // T1                      T2
    v = n.loadRelaxed()                               // v = 1
    v != 0                                            // true
    n.testAndSet(v, v - 1, v)                         // n = 0
                               v = n.loadRelaxed()    // v = 0
                               v != 0                 // false
                               return v == 1;         // false

This commit changes that design, for two reasons. First, a semantic one:
if one thread has detected a fatal condition, it must be equally fatal
for all threads. Second, we must accept a meaningful time between the
detected condition and the call to qAbort() and thus the time until its
effects take. In the worst case scenario, T1 could get suspended
indefinitely, at which point T2 having concluded that warnings weren't
fatal will happily execute forever. [This could happen *because* of
having called abort(), and though that's a SW bug elsewhere, we should
not let our other warnings and criticals continue.]

The fix is simple: we never decrement from 1. That way, if multiple
threads start their verification at the same time, they will all see the
value 1 and will all abort. The abort() standard library function is
thread-safe, as our replacements for it.

Pick-to: 6.5 6.8 6.9
Change-Id: I03fbcbac26bd1f34d631fffd43bb9c27d51783d0
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-03-19 09:33:36 -08:00
Albert Astals Cid
2e6acc23cd macOS: Remove check for NSAccessibilityCellRole when synthesizing role
We check for `!synthesizedRole` before entering this code, which means
the role can not be NSAccessibilityCellRole either, as the synthesized
role is initialized from the role.

Change-Id: I8ea4a09f770901f34f41f52c8d736d70152d3312
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-19 17:32:39 +00:00
Axel Spoerl
7318bfb47a Clean up QKdeTheme
QKdeTheme used a ResourceHelper class to implement std::array of
QFont and QPalette points. The latter has never been used: Only the
first row was polulated with a KDE system palette. All other rows
remained nullptr.

Remove ResourceHelper.
Make the font array a member of QKdeThemePrivate.
Use a QPalette pointer member of QKdeThemePrivate instead of the
obsolete array a member of QKdeThemePrivate.

Task-number: QTBUG-132929
Change-Id: Ia8254182b2b824363253e2bfc71648cdfe55a403
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
2025-03-19 16:18:31 +01:00
Edward Welbourne
a52a979abd Fix a double test to actually test double, rather than float
The macro body did not use its type parameter and both uses of the
macro in fact passed float for that parameter in any case, making the
so-called double version of the test actually a redundant clone of the
float form. This code is very ancient (harald, 2006).

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Ib6b7231c2737346784385473a94f3936b08aed33
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-19 15:42:49 +01:00
Alexey Edelev
14d1651d15 Suppress the Private module warning if QT_FIND_PRIVATE_MODULES is ON
If users set QT_FIND_PRIVATE_MODULES we may assume that they know
what they are doing and it's the conscious decision, and the
Private module warning is not needed.

Ammends a9f26c3f9a9eb6758e3ef116e319a6cca8715a1c

Change-Id: I2d7bf86060b87365bda0a8355427c52b1b38c456
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-19 13:11:19 +01:00
Alexey Edelev
d3292dbeb6 Swap sending of SETTINGS ACK frame and emitting the signal
This allows API users sending the HEADERS and DATA frames after the
SETTINGS ACK right from settingsFrameReceived slot, and keep the
expected frame order.

Pick-to: 6.8 6.9
Change-Id: I7900e786074d1d534c2e14f00e2aedf8dbb3a9d9
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-03-19 13:11:19 +01:00
Eskil Abrahamsen Blomfeldt
e72b2f1930 Revert "Don't support subpixel positioning for color fonts"
This reverts commit fd9c9788f73cb088229701dd92443aa04005a4a3.

This change failed to consider the fact that color fonts may
also contain non-emoji characters and can be used for regular
text. In this case, it very much makes sense to support
subpixel positioning.

If needed, a more specific optimization can be made for emoji
characters later, but for now we just revert to fix the
regression.

Task-number: QTBUG-134626
Pick-to: 6.8 6.9
Change-Id: I07fece03d02b62811c2def26c19c5225a08a0037
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-03-19 12:11:18 +00:00
Magdalena Stojek
c3295bd59c QXmlStreamWriter: Ensure correct newline handling with auto-formatting
Previously, QXmlStreamWriter would incorrectly insert a newline before
the first token when writeStartDocument() was not used, while
auto-formatting was enabled.
This fix ensures that the first token is written inline without an extra
leading newline, while preserving expected formatting for subsequent
tokens.

To achieve this, two new flags have been introduced:
- didWriteStartDocument: Tracks whether writeStartDocument() was called.
- didWriteAnyToken: Ensures that at least one token has been written
before allowing newlines.

Fixes: QTBUG-28721
Pick-to: 6.9 6.8
Change-Id: I8be7e8fc6ac0e63304359d24c6c8372e5ba42bb4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-19 07:31:15 +01:00
Mårten Nordheim
d359035c80 tst_QLocale: Fix failing test on Norwegian Bokmål
It was failing because making it latin-1 turned it into:
"Norwegian BokmÕl, Latin, Norway"

While we expected:
"Norwegian Bokm\xE5l, Latin, Norway"

Amends e323d46cdaecffebb3f9fa55934e4eb4868611cf.

Pick-to: 6.9
Change-Id: I55fe21331d1cb3abd66780e103aee8b603509818
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-19 01:33:41 +00:00
Giuseppe D'Angelo
b0895d1bd7 tst_qregularexpression: include what you use
Pick-to: 6.9 6.8 6.5
Change-Id: I9e283a1065b37bb4c9d05468e75545d61762482b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-19 02:09:20 +01:00
Thiago Macieira
3e1d147986 QMetaType: suppress non-conversion content in convert()
Many of the conversions are implemented by macros and may include
conversion from a type to itself. We never call the convert() function
with those parameters, so that code can be safely suppressed.

Pick-to: 6.9
Change-Id: I31904243ae8f750a3002fffd85f944305f0eee6b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2025-03-18 16:33:35 -07:00
Christian Ehrlicher
1c26a93b3d Windows11Style: Use correct font when a pushbutton has a menu
When a pushbutton has a menu, the menu indicator is drawn as the glyph
ChevronDown from Segoe Fluent Icons font. But later the font is not
reset so it's also used for the push buttons label. Since the icon font
has no valid glyphs for most of the characters, a replacement is used
but this might not be the one set for the pushbutton.

Pick-to: 6.9 6.8
Change-Id: I25c9b993450e7fe740addb153259f46b570ad8f7
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-18 23:40:48 +01:00
Safiyyah Moosa
ada114f8b3 Doc: Mention how devicePixelRatio tracks changes
Currently the QWindow::devicePixelRatio() documentation mentions that the device
pixel ratio can change, but it does not explain how to track the changes.
This patch adds that the QWindow instance receives the event of type
QEvent::DevicePixelRatioChange when the device pixel ratio changes.

Fixes: QTBUG-128182
Pick-to: 6.8 6.9
Change-Id: I2107015a07f30167c9f7324959b47ada0a75988d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-18 19:24:39 +01:00
Marc Mutz
f3256e059f QConcatenateTablesProxyModel: cache roleNames()
The return value of this function only changes when models are added
or removed, and some users call this function often (an earlier
version of QGenericItemModel did, possibly QML does?), so cache the
result of the function instead of re-creating the QHash on every call.

Use QAbstractItemModelPrivate::defaultRoleNames() so we don't need
an instance to get the base class' contents. Amend the comment in
QAIM::roleNames() asking to keep the two in sync.

Amends 5ffb9d7ae6d60fb370b79f8222dab7d7e628fa4f.

[ChangeLog][Important Behavior Changes][QtCore][QConcatenateTablesProxyModel] The
roleNames property is only updated (lazily) on addSourceModel() and
removeSourceModel() now (was: on every call of the function). If your
source models change their roleNames() dynamically, you need to call
invalidateRoleNamesCache() manually when they do.

Pick-to: 6.9
Change-Id: I32edc93ff9ff7b252ca04f0d61b54b2244d0be48
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-18 18:15:45 +00:00
Marc Mutz
ed92f6c22f Q(Multi)Map: micro-optimize take()
Instead of the RVO-unfriendly¹

    auto r = std::move(it->second);
    erase(it);
    return r;

use map::extract(), if available. The RVO-unfriendly code now only
plagues old-fashioned compilers that, in 2025, didn't, yet, manage to
implement C++17 _cpp_lib_node_extract. The rest enjoys C++17
guaranteed RVO.

Amends 14090760a87f23509b7bb5ad846537c766cb44a5.

¹ theoretically, this code is eligible for NRVO, but embedded in a
  larger function like this, it won't kick in on most compilers.

Reported-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Pick-to: 6.9 6.8
Change-Id: I6654fa7f5ed80d07369eb6a2b37f1e82cd3aa7f0
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2025-03-18 19:15:45 +01:00
Laszlo Agocs
00155dabf3 Remove 6.7 preliminary tag for QRhiWidget
Pick-to: 6.9 6.8
Change-Id: Iab453b9c0cf4f158f9ca13294dcd053fb35daf93
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-18 18:25:51 +01:00
Dennis Oberst
6a64722fb3 Fix mixed-type usage for modf
When building Qt with a non-double qreal type, i.e.
QT_COORD_TYPE=float, the C function modf rejects the float type since it
is declared as:

        float modff(float, float*)
        double modf(double, double*)

Fix this by porting to std::modf, which provides overloads for both
FP types.

Amends 91f502a7d65d76f4a376903c4058385a62dad277.

Change-Id: Ic1de2f3d8e75a9594dbbd0fa92e63505dae6f1b4
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-18 17:25:51 +00:00
Karim Pinter
3c919b6d0d Add support for using static EGL libraries on VxWorks
On VxWorks there is dlopen, but the feature can be turned off for static
builds, so Qt can use EGL even when dlopen is not present. In
qeglplatformcontext.cpp dlsym needs dlopen feature. There is no dlopen
on windows neither on Integrity.

Task-number: QTBUG-134671
Pick-to: 6.8 6.9
Change-Id: I7ced5f53ca21a8b0ceb25732ed4b1dc6c0bb1300
Reviewed-by: Janne Roine <janne.roine@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Kimmo Ollila <kimmo.ollila@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-03-18 16:43:28 +02:00
Tor Arne Vestbø
16081f414d Only default top levels to Qt::WA_ContentsMarginsRespectsSafeArea
When safe area margins are in play, such as on iOS and Android, or on
macOS in 6.8 and above when the NSWindowStyleMaskFullSizeContentView
styleMask has been set (manually or via Qt::ExpandedClientAreaHint in
6.9), then widgets with a layout will by default try to avoid the non-
safe areas.

This worked well as a safe default, ensuring widget applications filled
the entire window with its background color, while constraining the
layout of children to the safe area.

However, for those that explicitly want to put content in the non-safe
areas, by setting Qt::WA_ContentsMarginsRespectsSafeArea to false, the
story was a bit cumbersome, as we set the attribute to true by default
for all widgets. Meaning, any child widget put into the non-safe areas
that itself had a layout (such as a push button) would also need the
Qt::WA_ContentsMarginsRespectsSafeArea = false override.

We now default Qt::WA_ContentsMarginsRespectsSafeArea to true only for
top level widgets on creation, and leave it up to the user to manage the
attribute for the other use-cases, as they then need to be in full control.

[ChangeLog][QtWidgets] The Qt::WA_ContentsMarginsRespectsSafeArea attribute
is no longer set by default for non-top-level widgets. Top level widgets
still default to Qt::WA_ContentsMarginsRespectsSafeArea=true, so children
are laid out in the safe areas, but overriding the attribute for the top
level now allows placing widgets in the non-safe areas without also setting
the Qt::WA_ContentsMarginsRespectsSafeArea attribute to false for every
descendant widget that overlaps the non-safe area.

Task-number: QTBUG-133215
Pick-to: 6.9 6.8
Change-Id: I7b1d420d730ee896ec2fb61aadacd94473dc9681
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-18 15:43:28 +01:00
Liang Qi
54651971a2 client: use qgenericunixtheme_p.h instead of qgenericunixthemes_p.h
... if available.

Prepares the code for qtbase/53fb13456fffe8bfd192f9197c6d1703854b49a2.

Change-Id: I599e3d47ed94c6e6fc0182495e483506b3ae7ff9
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-18 13:55:05 +00:00
David Edmundson
b3d855be59 client: Drop assert in frame size syncing
Whilst this assert is true for a normal application workflow
such as QtQuick, it's not something we can guarantee with all
applications.

If the assert is not true, the absolutely worst case is the
same glitchy resizing that we had in 6.8 and older.

Fixes: QTBUG-134126
Pick-to: 6.9
Pick-to: 6.9.0
Change-Id: I43b660d771d628ceedce9407fd146b48074557f9
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-03-18 11:51:07 +00:00
Marc Mutz
fde232c855 QFileSystemModel: memoize roleNames()
The return value of this function is constant and some users call this
function often (an earlier version of QGenericItemModel did, possibly
QML does?), so memoize the result of the function instead of
re-creating the QHash on every call.

Use QAbstractItemModelPrivate::defaultRoleNames() so we don't need
an instance to get the base class' contents. Add a comment to keep
the two in sync.

As a drive-by, port from the QByteArrayLiteral macro to _ba UDLs.

Amends 32b586864e3a4398da38c045f4ac0823c3dc3c57.

Pick-to: 6.9 6.8
Change-Id: If00b51e60930c974e6f8f928711dc78ba1f42b93
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-18 10:50:00 +00:00
Morten Sørvig
7c69d09262 highdpi: avoid rounding policy warning
Calling setHighDpiScaleFactorRoundingPolicy() during
Qt startup warns:

  "setHighDpiScaleFactorRoundingPolicy must be called
   before creating the QGuiApplication instance"

The warning is intended for user code, and Qt internal
code need not heed it.

Set the highDpiScaleFactorRoundingPolicy private variable
directly instead.

Fixes: QTBUG-132430
Change-Id: I50285dc76209f4a96bcdf46e1861fc2dc17ca5c2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-18 10:50:00 +00:00
Magdalena Stojek
8c99134584 QDom: Fix setAttributeNode() to properly replace existing attributes
This fix ensures that QDomElement::setAttributeNode() correctly replaces
an existing attribute with the same name. Previously, calling
setAttributeNode() with a new attribute of the same name resulted in
both the old and new attributes being present, violating the expected
behavior described in the documentation.

Fixes: QTBUG-15125
Pick-to: 6.9 6.8 6.5
Change-Id: Ibdda37a65f6e754d9f7e68e725d3438bbb2d9e0c
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-03-18 11:49:56 +01:00
Joerg Bornemann
1b9cf55117 CMake: Show the "Docker image ... not found" warning only once
...if docker / docker-compose are not installed.

This amends commit 3223c06d43b1be658032c179397eaf6ed3b1f27c, which fixed
the multiple warnings only for the docker image existence check.

Remove the QT_TEST_DOCKER_WARNING_SHOWN global property and set the
QT_SKIP_DOCKER_COMPOSE cache variable to ON instead. Now, we'll see the
warning only once, and further re-configuration attempts won't even try
to find the docker tools.

Change-Id: I98a584ae91899ae8c4c347ee62601d791105d301
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-03-18 08:00:05 +01:00
Giuseppe D'Angelo
baffc8e47d QElapsedTimer: port some restart() calls to start()
...when the return value is unused.

The code should already be safe from restart()'s preconditions: either
the timer is explicitly checked for validity before the call, or we can
reason about the code (in testlib, the functions are called after the
one that starts the timer, making it valid). Therefore, this is just a
"cosmetic" cleanup (and a super-micro-optimization), but Marc doesn't
want to think about the qtestlib changes and says to pick it all the
way, "just in case".

Pick-to: 6.9 6.8 6.5
Change-Id: I73cf287ce1314fc3626734ec64ddf5884afe3383
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-18 04:07:21 +00:00
Giuseppe D'Angelo
34f993b7f5 QByteArray: add conversion to std::string_view
96d67da420697cee10bdc537a1a592f6f22e2b8f didn't originally add this
conversion because on certain compilers (QNX) it's ambiguous. The
problem seems to be that QByteArray by default is convertible to const
char *; by adding a conversion to std::string_view, then the explicit
conversion

  std::string_view v(ba);

somehow becomes ambiguous.

Still, we've decided that we want the implicit conversion on non-broken
compilers, so this commits add it there.

[ChangeLog][QtCore][QByteArray] Added an implicit conversion operator
towards std::string_view.

[ChangeLog][QtCore][Important Behavior Changes] Converting a QByteArray
to a std::string_view will now create a view span over the entirety of
the byte array. Before, the view would have stopped at the first NUL in
the byte array (if there was one), unless the QT_NO_CAST_FROM_BYTEARRAY
macro was defined.

Change-Id: I70bbddac97636fbedb4d449eaa65cad4ecbdf0bf
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-18 05:07:21 +01:00
Lorn Potter
1a8c8ffb0c wasm: fix QTcpSocket error code when url doesn't exist
::connect on wasm seems to be returning 0 in the instance that the
server url does not exist.
So we ignore that and look at errno, which returns ENOENT
which makes no sense here.

Fixes: QTBUG-132191
Pick-to: 6.9
Change-Id: I2ff6642dd836324e1af6c288c53880de028ce158
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-03-18 02:30:10 +00:00
Thiago Macieira
1a580ca2a9 qHashMulti*: use the seed argument in the template and noexcept traits
This shouldn't change support for existing types in Qt 6, because we
have a catch-all that calls qHash(t) and XORs the seed in. Come Qt 7,
that changes of course.

[ChangeLog][QtCore][QHash] Fixed an issue that caused qHashMulti() and
qHashMultiCommutative() to fail to compile if used with a type that
provided the required 2-argument qHash() function without providing a
default seed.

Task-number: QTBUG-126659
Fixes: QTBUG-134683
Task-number: QTBUG-134690
Change-Id: Ife742fdbd53c7bd12652fffd70f35db250db2027
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-17 21:56:50 +00:00
Marc Mutz
e15ef96bcb tst_QConcatenateTablesProxyModel: extend shouldMergeRoleNames() with removal
We should also test removal, not just addition.

Amends 5ffb9d7ae6d60fb370b79f8222dab7d7e628fa4f.

Pick-to: 6.9
Change-Id: I0842a6be6230362e2095f6c8b2b1ced230826c5e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-17 22:43:29 +01:00
Marc Mutz
26ba78900d QSqlQueryModel: restore RVO in data()
The return of a default-constructed QVariant 'v' from three branches
invites NRVO, but most compilers won't let it kick in, because there
are two return statements that don't return 'v'.

Return an rvalue from each branch, so RVO is guaranteed (since C++17)
to kick in.

Amends the start of the public history.

Picking back all the way, since it's risk-free.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I495885bee3ebba63c9e52640903c792011c1dee2
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-03-17 22:43:24 +01:00
Tor Arne Vestbø
d038f3d692 Add note to QWindow::setGeometry of why we set the screen first
Change-Id: I1c497bb240b23ef96c45c7942d5fd1b650006942
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-03-17 20:14:01 +00:00
Tor Arne Vestbø
babae98401 windowflags: Remove unused argument in paintEvent
Change-Id: I2deee9e334e0944913eae28a5992015a613db149
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-03-17 21:14:01 +01:00
Tor Arne Vestbø
d56dbdd48c windowflags manual test: Add option to force window recreation
Not all flags have an affect on an already created window, depending
on the platform and existing flags. Add option to force recreating
the window.

To aid debugging we also now log platform destruction/recreation events.

Pick-to: 6.9
Change-Id: I7822cb58eaed51d72ed4ea3244f1f4113964cff7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2025-03-17 20:14:01 +00:00
Shawn Rutledge
1750acc392 DropSite example: handle application/x-color
Show the color that is dragged in, both graphically and textually.
Revert to default palette for other data types. Prioritize colors
over text: if an application (such as kolourpaint) offers both x-color
and text, the color is probably the intention, and the text may be
just a hex string for placing into a color text field.

Pick-to: 6.8 6.9
Fixes: QTBUG-134313
Change-Id: I6c19f1220712881d2057bc9758bbc8cbd9247c81
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-03-17 21:14:01 +01:00
Axel Spoerl
70b8dd2b7e Re-implement QPlatformTheme::requestColorScheme() in QKdeTheme
QKdeTheme remained unresponsive to programmatic color scheme changes,
after QPlatformTheme::requestColorScheme() had been introduced.

Add functionality to QKdeTheme.
Fall back to qt_fusion_palette, when the requested color scheme isn't
supported by the current KDE theme (e.g. Adwaita-dark doesn't support
light mode).

Functionality has to be manually tested with the widget gallery
example.

Task-number: QTBUG-132929
Fixes: QTBUG-134023
Change-Id: I37e56cc36803dcb8527a897ddcada29b322a5ada
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
2025-03-17 20:41:29 +01:00
Giuseppe D'Angelo
dd70656166 QNetworkAccessManager: protect more QElapsedTimer with isValid() checks
It might be redundant, but I can't definitely prove that these timers
are already started by the time we call elapsed() or restart() on them;
I "just" think they are because the CI is happy with the existing code,
even when adding assertions into QElapsedTimer.

As a precautionary measure, add more isValid() protections to QNAM code.
Also replace restart() with start() since the return value is unused.

Pick-to: 6.9 6.8 6.5
Change-Id: Ic64ab27116d8b1cb6c14e18dee79a15aa40844ce
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-17 19:41:29 +00:00
Giuseppe D'Angelo
585471b138 Fix calls to non-started QElapsedTimer functions
It's illegal to call elapsed() or restart() (sic) on a non-started
QElapsedTimer, so don't do that. In QNAM code, this has been observed by
adding assertions into QElapsedTimer, which then make network tests
crash. (While I am unable to run the network testsuite, this is
reproducible locally by running tst_QNetworkDiskCache::setCookieHeader).

The QTextStream test also calls restart() without a start(), but then it
calls elapsed()+start() which is the whole point of restart(), so amend
accordingly.

Pick-to: 6.9 6.8 6.5
Change-Id: I5cfe308f64b631b68b92843b409777a6b9176828
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-17 20:41:29 +01:00
Morten Sørvig
0eba6478ee wasm: Use the new QWasmEventHandler class
Also saves one malloc call per event handler.

Change-Id: I33a72916b101e27d2e4139ebb1dc5227b0793273
Reviewed-by: Lorn Potter <lorn.potter@qt.io>
2025-03-17 19:46:02 +01:00
Shawn Rutledge
209a2145f9 Initialize QLastCursorPosition with a large number rather than infinity
Infinity has caused some problems when the floating-point position gets
converted to QPoint. We are trying to be stricter about overflows now
(cf 1145e1709d1072f7dd45683e9c25a14615603854). And we still have the
QTBUG-40856 fix in place in Qt Quick: on touch release, we pretend that
the mouse moves back to its last-known position. It should not re-visit
infinity in that case.

Why 2^23? Worst case, qreal might be a 32-bit float. If we store 2^24,
x() - 1 in floating-point ought to be accurately computed:
https://en.wikipedia.org/wiki/Single-precision_floating-point_format#IEEE_754_standard:_binary32
But often manhattanLength() is used with mouse positions, so with a
number half as big, that should also be accurately computed, even if
both operands have coordinates of 2^23.

Another way to look at this is we just need to say that the mouse cursor
is initially offscreen, until it moves to a known location. The actual
coordinate doesn't matter, as long as it's very obviously offscreen, no
matter how big the desktop's cluster of screens is.

Amends c5792dcfd631abb4f9e2b92cd6e88d7e5c373406

Fixes: QTBUG-134718
Change-Id: I246865e1ba389503aadbc833a0308b60f9b91d93
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2025-03-17 18:45:12 +01:00
Joerg Bornemann
7d25a1a0fd CMake: Remove unused variable from qt_internal_add_module
The targets_to_export variable is unused. Remove it.

Amends commit fbbf4ace0188b9718b6d7808021c0b887fd52d9f.

Change-Id: I67f171738532c274e2b4fe8943fffd0c03cce55a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-03-17 17:35:07 +01:00
Wladimir Leuschner
92a14cdc36 WindowsQPA: Add default icon to custom titlebar
In case that no application icon was provided, use the IDI_APPLICATION
icon when Qt::WindowTitleHint was provided.

Fixes: QTBUG-133941
Pick-to: 6.9
Change-Id: Ifb479a7056e0841215d525c2346938bda31fc1c6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2025-03-17 17:03:22 +01:00
Wladimir Leuschner
b24b9bba68 WindowsQPA: Adjust close button and hover color for custom titlebar
Adjust toe color of the close button to match the native color. Adjust
the hover text color for the close in light mode to match the native
behavior.

Fixes: QTBUG-133945
Pick-to: 6.9
Change-Id: I2c9fafba9fee65f45f3878168b67b0d0a4b2a54c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2025-03-17 16:03:22 +00:00
Marc Mutz
39ec71237f ECMEnableSanitizers.cmake: fix GCC's "note: variable tracking size limit exceeded" when using asan
Upstream pull requests:
- https://invent.kde.org/frameworks/extra-cmake-modules/-/merge_requests/519
- https://invent.kde.org/frameworks/extra-cmake-modules/-/merge_requests/521

Says the commit message:

> Set the max-vartrack-size parameter to 0 (= unlimited) to avoid
> GCC's "note: variable tracking size limit exceeded with
> -fvar-tracking-assignments, retrying without" message you get when
> you compile with asan sometimes.
>
> This is reported¹ to speed up compilation, not slow it down.
>
> ¹ https://stackoverflow.com/a/75704837/134841

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I2489bbe3d3cb12cc52d7041499e38bb05c73aa3a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-17 16:46:33 +01:00
Alexey Edelev
7106e492bc Fix the condition that enables/defaults exceptions
Not sure why it worked at implementation time. But now it definitely
doesn't. We may check the EXCEPTIONS flag value, since it's the
equivalent of its presence/non-presence in the argument list.

Amends f98fd705290ac7bd9434552a07e38b775e6a6dbf

Task-number: QTBUG-118901
Pick-to: 6.9
Change-Id: I9769b4921a2f72d31aea2b0bffd2511edd89f88f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-17 10:29:45 +01:00
Tor Arne Vestbø
027624b4d5 macOS: Preserve styleMask bits that we don't control when updating mask
We use QCocoaWindow::windowStyleMask to compute a new styleMask for the
NSWindow, based on the QWindow flags. However, some styleMask bits we
do not control in this function, so we need to preserve them in case
they were already set on the NSWindow, as otherwise we end up clearing
those bits. We did this already for NSWindowStyleMaskFullScreen, but now
we do it for all style mask bits we don't control.

This fixes an issue after QCocoaWindow::applyContentBorderThickness()
started calling setWindowFlags to control NSWindowStyleMaskTexturedBackground,
after the introduction of the Qt::NoTitleBarBackgroundHint window flag in
a1e6fed44964a3eb14045bf819d232d6cbad9f59 and then
bddc0198297828ba29e5cf4b39e07412a506a551.

The symptom was losing the NSWindowStyleMaskDocModalWindow style mask
for sheets or other modal windows with a QTabWidget in them, as that
widget ends up calling applyContentBorderThickness().

Fixes: QTBUG-134447
Pick-to: 6.9
Change-Id: Ie3e9ca3ff14f84ce70438d3633bd283fb78b9e8c
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit b90b473ee01bc3dfce88cce3d0f6ebb8ee0f7f57)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-03-16 19:33:19 +00:00
Thiago Macieira
606ba10507 QDirListing/Win: improve performance by setting WinLnkType earlier
This line in QDirListingPrivate::checkAndPushDirectory() was causing a
call to GetFileAttributesEx() for every single directory entry when
recursion was enabled:

    // Follow symlinks only when asked
    if (!iteratorFlags.testAnyFlags(F::FollowDirSymlinks) && entryInfo.isSymLink())
        return;

That happened because QFileSystemIterator::advance() never set
QFileSystemMetaData::WinLnkType in knownFlagsMask, because QFSMD is
supposed to contain the information about what that .lnk was pointing to
and we don't want to read it unnecessarily.

However, we *do* when the directory entry is *not* a .lnk file. For
those cases, we can set WinLnkType in knownFlagsMask, which will cause
QDirEntryInfo::isSymLink() to return false without having to make
further system calls.

This change is fragile and this code deserves a bit of refactoring
(starting with getting rid of The Boolean Trap). All calls to either
fillFromFindData() or fillFromFileAttribute() are currently protected by
a .lnk filename check (all of them are either in this function or inside
of QFileSystemEngine::fillMetaData()).

Fixes: QTBUG-134699
Pick-to: 6.9 6.8
Change-Id: I87b19f89035bcd7e1c1ffffd14eac5fb5ac3e693
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-03-16 01:08:39 +00:00
Lars Schmertmann
a9e251332c Fix usage of API functions on Windows 1607 (Build 14393)
* Windows Server 2016, Windows 10 LTSB 2016 and Windows 10 version 1607:
  SetThreadDescription is only available by Run Time Dynamic Linking in
  KernelBase.dll. See [1].
* According to [2] UiaRaiseNotificationEvent should be available on
  Windows Server 2016 but in fact it is not.

[1] https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreaddescription
[2] https://learn.microsoft.com/de-de/windows/win32/api/uiautomationcoreapi/nf-uiautomationcoreapi-uiaraisenotificationevent

Fixes: QTBUG-134075
Pick-to: 6.8 6.8.3 6.9 6.9.0
Change-Id: I3c4c733a4112a72b75f91f017a278dff2454e100
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-15 21:18:50 +01:00
Marc Mutz
a405834ae6 QSimplex: split QConcreteSimplexVariable from QSimplexVariable
The latter was used both as a concrete type as well as a base class,
driving Coverity nuts because it couldn't prove that we weren't
deleting derived classes (AnchorData) through a QSimplexVariable
pointer.

This is the same issue that Coverity took with QBrushData (CIDs
218724, 11772), and the solution is the same
(cf. 3bbc9e29ef59683351cf35c19a8bd4a030615c64):

Split the Janus-headed class into one that acts only as the base class
(and has a protected dtor) and one that only acts as a concrete class
(and we can mark it final).

The protected dtor in the former now statically ensures we don't
delete a derived class object through a QSimplexVariable pointer.

We don't need to modify AnchorData subclasses, because AnchorData
introduces a virtual destructor.

Coverity-Id: 390828
Pick-to: 6.9 6.8 6.5
Change-Id: I981c02e69af44ebacd4ba3aec76792e14eb15836
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-03-15 15:47:09 +00:00
Marc Mutz
871564434c tst_QStringApiSymmetry: fix -Wunused-parameter
Amends 5fc1e9fa0c1925654412af5bf46ff95da99bc190.

Pick-to: 6.9 6.8 6.5
Change-Id: I399c74874e7824ac32c76f8b093123bd8ba07fdd
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-03-15 15:26:36 +01:00
Giuseppe D'Angelo
a43453d9a2 QTimeLine: do not restart() an invalid QElapsedTimer
It's UB (as per docs). Creating a QTimeLine and calling
setCurrentTime() will end up calling restart() without having called
start() first. Moreover, the return value of restart() isn't used,
so that's useless work.

Pick-to: 6.9 6.8 6.5
Change-Id: I53c80838f60fae406a44ffe2cf578c6c79cc9df4
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-15 14:26:35 +00:00
Valentin Batz
5db60be476 Remove zone id from IPv6 host in prepareRequest
Ensure that link-local IPv6 addresses in a HTTP Request do not
include the zone identifier in the 'Host' header, as per RFC 6874.
This prevents connection failures due to invalid host syntax.

Fixes: QTBUG-134727
Change-Id: I7067a991f67d44241717a89b656a3fcbda1fcd3a
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-15 07:46:21 +01:00
David Faure
3cc947e98f QRhi: fix data race on rubLogEnabled
* Handle QSG_INFO with the proper macro rather than with an invalid
  const_cast
* Remove the racy bool rubLogEnabled, read the atomic from the
  logging category directly

WARNING: ThreadSanitizer: data race (pid=427588)
  Write of size 1 at 0x7f89d5be2530 by thread T12:
    #0 QRhiImplementation::prepareForCreate(QRhi*, ...) qrhi.cpp:8863
  Previous read of size 1 at 0x7f89d5be2530 by thread T11:
    #0 QRhiResourceUpdateBatchPrivate::free() qrhi.cpp:9907

Pick-to: 6.9 6.8
Change-Id: Ied5171ea5bb97372daced8afe3ad894d49961069
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-03-15 01:47:51 +01:00
David Faure
8500343037 Export QLoggingRegistry::instance()
so we can use Q_LOGGING_CATEGORY_WITH_ENV_OVERRIDE outside QtCore.

Otherwise clang++/macos says
Undefined symbols for architecture x86_64:
"QLoggingRegistry::instance()", referenced from:
QLoggingCategoryWithEnvironmentOverride::QLoggingCategoryWithEnvironmentOverride(char const, char const) in qrhi.cpp.o

As Thiago suggested, don't export the whole class to autotests,
export only the symbols they need. This simplifies the code.

Pick-to: 6.9 6.8
Change-Id: Id653385376a2a7604dddd2f520a0a90de5a541f6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-15 01:47:50 +01:00
Eirik Aavitsland
5ef9b4efe1 Add Qt-Security tags to texture file reading code
According to QUIP-23

Pick-to: 6.9 6.8
Change-Id: I286f76e72a253b67b033a88d24bacdefb714e58f
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-03-15 00:12:29 +00:00
Marc Mutz
eeefa8c278 tst_QByteArray: remove unused constexpr variable isByteArray
Amends 57d91d8029064b592dee8adf819bde676763df28, which removed the
last remaining user.

Task-number: QTBUG-134079
Change-Id: Ie4447f85e9e49c80b505b2241149605886f992cc
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-03-15 01:08:28 +01:00
Dennis Oberst
d693a06522 Fix mixed-type usage of qFuzzyCompare
When building Qt with a non-double qreal type, i.e.
QT_COORD_TYPE=float, mixing types on qFuzzyCompare will result
in ambiguities since only

        qFuzzyCompare(float, float)
        qFuzzyCompare(double, double)

are accepted.

Pick-to: 6.9 6.8
Change-Id: I4450516ffdf019ef8288aefd99a8e729c039bcd1
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-03-14 17:30:56 +01:00
Christian Ehrlicher
b0dec15d2d Windows11Style: allow overriding of palette for QPush/ToolButton
Honor the palette set by the stylesheet when drawing a
QPush/ToolButton.

Pick-to: 6.9 6.8
Fixes: QTBUG-134497
Change-Id: I33b9cdf8d4999e1fccdae250543db541b66b3b7d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-14 15:06:40 +00:00
Thiago Macieira
0de9b3f126 QSettings/Doc: fix the information about what's case-sensitive and not
The docs didn't match the implementation.

Fixes: QTBUG-40283
Pick-to: 6.9 6.8
Change-Id: I054a22409aa8b2d198b0fffd6346b9859c55681a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-14 15:06:40 +00:00
Andreas Eliasson
9e61bd2465 Doc: Don't add padding to div that wraps the pre element
The current style adds padding to non-pre elements, such as any p or div
elements. The final html adds a wrapping div with a .pre class that
also gets padding added to it. This patch removes the padding from this
wrapping div.

Fixes: QTBUG-133710
Pick-to: 6.9 6.8 6.5
Change-Id: I6411dcda9cfed5f0f82d8bd9ea8dc809b1a3b4d6
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
2025-03-14 13:03:41 +00:00
Giuseppe D'Angelo
41ffc92f18 sequential_erase: amend the predicate passed to erase_if
LWG4135 applies to the quoted Standard paragraph (and therefore
to our own code as well).

https://cplusplus.github.io/LWG/issue4135

Pick-to: 6.9 6.8
Change-Id: I05caa4cba001ecc473412c789738480d8eafa0c5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-14 13:44:32 +01:00
Eirik Aavitsland
ca26e80450 Doc: QPicture uses QDataStream, forward warning against untrusted data
Make this explicit, with a link.

Pick-to: 6.9 6.8
Change-Id: I8b8b64c88daacba43df1eecf5a347c0a89d837e1
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-03-14 11:14:37 +00:00
Marc Mutz
912388b306 Mark QSimplex{,Constraint} final, AnchorData non-copyable
These final touch-ups for CID 390828 make the code easier to
understand and safer, because more unsafe operations are now forbidden
(subclassing and copying).

Coverity-Id: 390828
Pick-to: 6.9 6.8 6.5
Change-Id: I2e43be71d8c3db59d95e69ec16c41c1547a2f180
Reviewed-by: Magdalena Stojek <magdalena.stojek@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-03-14 10:11:31 +01:00
Thiago Macieira
eb1342a3c2 qHash: break up the long line and add constexpr to the 1-arg catch-all
Amends 798c23189c7fb73629c1a98361cb1f50446fecf1.

Task-number: QTBUG-126659
Task-number: QTBUG-134683
Task-number: QTBUG-134690
Pick-to: 6.9 6.9.0
Change-Id: I7ab4e1f9170366c6495bfffd37b61336b10d4da6
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-14 02:58:49 +00:00
Marc Mutz
bee49bde04 qhighdpiscaling: de-pessimize optional<> use
std::optional::value_or() should not be used when its argument is a
non-trivial type, because the argument is created and destroyed
independent of whether it is used in the end. In this case, we don't
even need an optional, because parseScreenScaleFactorsSpec() takes
the output of qEnvironmentVariable() (not -OptionalString) as-is, so
we can just drop the unneeded optional-(un)wrapping.

Since this patch apparently removes the last user of
qEnviromentVariableOptionalString(), mark that function as
[[maybe_unused]]. Outright removal may cause cherry-picks to fail,
so will come as a follow-up.

Amends 4d1f13f3549a73f5ca4e64dac9137e83138080fa.

Pick-to: 6.9 6.8 6.5
Change-Id: Ic2bb8a3aa8e946b957047ff4faf48c4082fc9c01
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-03-13 21:40:43 +00:00
Marc Mutz
a2e60ebee3 QImage: introduce a class invariant that format() is in-range
Coverity complains that image.format() is used to index into
qPixelLayouts[] when it may be NImageFormats.

Most code paths (e.g. QImageData::create()) defended against that, but
e.g. QImage::reinterpretAsFormat() did not (at least not overtly), as
didn't some of the backend functions.

Add checks, document the invariant on 'format' and assert it in
QImage::format().

If this doesn't convince Coverity, we'll need to turn qPixelLayouts[]
into a function, so that it can defend itself against out-of-bounds
access.

Pick-to: 6.9 6.8
Coverity-Id: 390711
Coverity-Id: 390720
Coverity-Id: 390758
Change-Id: I29431193face3cae8be56f01da8dced19c3abb38
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-03-13 22:09:19 +01:00
Morteza Jamshidi
1593220552 Fix header generation issue with multiple qt6_add_win_app_sdk calls
Use EXISTS path insead of using find_path because find_path finds the
last target's generated headers, but we want to generate headers for
each target separetely.
Ammends 95c70bbc5bed906fc3d24eebfb00592d48b30a74

Pick-to: 6.9
Fixes: QTBUG-124800
Change-Id: Ib2b9ceefbc6d11f9bf67fdc6ce25dea3366afe3d
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-03-13 19:59:06 +01:00
Bartlomiej Moskal
7ca68d0e2e Android: Fix for opening Url with authority
It seems that even we correctly get Uri from FileProvider, we still do
not used it. This patch started to use Uri received from FileProvider.

Additionally, to avoid the issue of case insensitivity, we started using
QString directly instead of QUrl for the openURL method.

Fixes: QTBUG-133702
Pick-to: 6.9 6.9.0 6.8 6.8.3
Change-Id: Ia3b5b6f1562194af4211b9d5bf6a0d56b43c1b05
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-03-13 18:59:06 +00:00
Bartlomiej Moskal
4a54c32e6b Android: Update qtprovider_paths.xml file
The qtprovider_paths.xml is used by FileProvider[0]
The file defines the different file locations that can be used for
sharing content (with other apps). Previously it used only the
files-path type (for private files inside internal storage).

According: qstandardpaths_android.cpp file, we need much more here.

This commit adds more file types to qtprovider_paths.xml

[0]https://developer.android.com/reference/androidx/core/content/FileProvider

Task-number: QTBUG-133702
Pick-to: 6.9 6.9.0 6.8 6.8.3
Change-Id: I29c8eb3d00490e9127d0aa646b4c50643b5f51ac
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-03-13 18:59:05 +00:00
Joerg Bornemann
1185f651e3 QMake: Add ability to link against xcframeworks with Xcode
This adds rudimentary support for linking against xcframeworks. We can
now do
    LIBS += /absolute/path/to/some.xcframework
and this will end up in the frameworks section of the Xcode project.

This is required for linking against the FFmpeg xcframeworks we're
providing for iOS.

Pick-to: 6.8 6.9
Task-number: QTBUG-86387
Task-number: QTBUG-129651
Change-Id: Id212700d3554689160d23eafb26d99ac43b91062
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-13 18:25:37 +00:00
David Faure
4472d1cd10 QWaylandWindow: fix data race on mWaitingForUpdate
Caught by TSAN when running examples/quick/particles/system/.
deliverUpdateRequest() is called from the main thread (and doesn't lock)
and handleUpdate() is called from the render thread (and locks
mFrameSyncMutex).

I made the bool atomic (like others in this file), rather than
locking mFrameSyncMutex.

Pick-to: 6.9 6.8
Change-Id: Ic2f2eafc2d91cc9676dee5a7cd1872f91dff09e2
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-03-13 15:14:26 +00:00
David Faure
7d77e1d9f8 QWaylandDisplay: fix data race on m_quitting
WARNING: ThreadSanitizer: data race (pid=247514)
   Write of size 1 at 0x7214000026f5 by main thread (mutexes: write M0):
     #0 QtWaylandClient::EventThread::stop() (libQt6WaylandClient_tsan.so.6+0xbb696)

   Previous read of size 1 at 0x7214000026f5 by thread T3:
     #0 QtWaylandClient::EventThread::waitForReading() (libQt6WaylandClient_tsan.so.6+0xbbbf9)
     #1 QtWaylandClient::EventThread::run() (libQt6WaylandClient_tsan.so.6+0xbba27)

Pick-to: 6.9 6.8
Change-Id: I4a5dc95668619d337181e6c5055cc94bbc5fc7ae
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-03-13 13:46:03 +00:00
Morten Sørvig
83b6139149 wasm: use QWasmWindow::fromWindow()
Make it test for null QWindow and handle(), use it
instead of C-style casting handle().

Change-Id: I7ffb1ef5d3d3c09c8ae44ec0141e93530a04abe6
Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
2025-03-13 12:57:10 +01:00
Morten Sørvig
bdc9665494 wasm: set jspi and wasm-exceptions flags for qmake
These are linker options, and need to be present in
order to link in the respective run-time support.

Change-Id: Ieeb0cc5f068d2652303d3cd5e27759b49ce62771
Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
2025-03-13 12:57:00 +01:00
Morten Sørvig
90a6c5aaf8 wasm: set MAXIMUM_MEMORY to 2GB when JSPI is in use
Work around Emscripten bug which triggers runtime exception

   WebAssembly.promising(): Argument 0 must be a
   WebAssembly exported function

This was already done for cmake, this adds the qmake
part.

Change-Id: Ieb3e89e9931a25f16c23ba2bce27bef33a91de53
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
2025-03-13 11:56:58 +00:00
Joerg Bornemann
bd2f1e2f90 CMake: Prevent creation of private modules without private headers
QtConcurrent and QtOpenGLWidgets don't have any private headers. There's
no point in creating private modules for them.

Task-number: QTBUG-132526
Change-Id: I2a19ae13d11232b47fd72e46173e8d8cb34a4189
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-03-13 11:55:43 +01:00
Joerg Bornemann
58be29388d CMake: Warn on creation of private modules without private headers
Private modules without private headers don't make much sense and
needlessly create CMake packages and QMake module pri files.

In qt_finalize_module we check whether the module has any private
headers. But the private module was already created before in
qt_internal_add_module. Moving the creation of the private module or the
CMake package files to the finalization phase would be a bigger
refactoring that's probably not worth the hassle.

An easier way to avoid the package creation issue is to mandate that a
Qt module must be created with NO_PRIVATE_MODULE if it doesn't have any
private headers.

Add a warning if a Qt module without private headers is created without
NO_PRIVATE_MODULE. Also warn if a Qt module with private headers is
created with NO_PRIVATE_MODULE.

This allows us to easily spot the places where NO_PRIVATE_MODULE is
missing.

Task-number: QTBUG-132526
Change-Id: I897f25790a99eaa320c39cd8c2728f26bceb824e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-13 11:55:43 +01:00
Audun Sutterud
9155b2ecb4 tests: Wait for output in tst_reconnect
The test must wait for the output to have a client before placing a
surface on it. If it fails to do so, flakiness may occur.

Task-number: QTBUG-132699
Change-Id: I272742d3bee7ae1fe61b8df629aba2947785fc6c
Reviewed-by: David Redondo <qt@david-redondo.de>
2025-03-13 10:43:08 +00:00
Giuseppe D'Angelo
7d22a9c75a qxp::is_detected: add an autotest
It was lacking one.

It seems that all compilers have trouble at checking accessibility in
SFINAE contexts (with various degrees of incompatibilities), therefore
I'm disabling all the tests that try checking for accessibility.

Change-Id: I1456acd3c40f802367a27610b0374f0806e403f5
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-13 07:06:18 +01:00
Thiago Macieira
7df128675a 3rdparty: update TinyCBOR to v0.6.1
[ChangeLog][Third-Party Code] The copy of TinyCBOR in Qt was updated to
0.6.1.

Pick-to: 6.9 6.9.0 6.8 6.8.3 6.5 5.15
Change-Id: If5d5ef6220874ae8858efffd1712a567597b6317
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-12 20:38:22 -07:00
Ahmad Samir
8786a930d1 QCryptographicHash: centralize resizeForOverwrite() call
hashLengthInternal() already returns the size for each algorithm, so call
resizeForOverwrite() in one place. The hash lengths are specified by the
respective RFCs, so they have to be the same with/without OpenSSL
(confirmed by looking at the OpenSSL source code). So use
hashLengthInternal() in the EVP code paths and replace
result.resizeForOverwrite(EVP_MD_get_size()) call with an assert.

MD4_RESULTLEN isn't available when USING_OPENSSL30 is defined,
hashLengthInternal() returns 16 for md4, since MD4_RESULTLEN == 16,
just use 16 directly.

Pick-to: 6.9
Change-Id: I5526d5e840b4882f3e5229df239b86924daee475
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-13 03:14:04 +02:00
Marc Mutz
ddf69669d3 QCssParser: statically verify QCssKnownValue arrays
Port from explicit array sizes to implicit ones, followed by an
explicit size check. This prevents mistakes where, due to missing
initializers, value-constructed trailing elements cause lower_bound()
to be called out-of-contract, such as the one
5d8f815e101da3ae9cd6a666cc097853f52b21da fixed.

Also statically verify that the arrays are sorted. This doesn't work
on GCC < 10, e.g. QNX, so guard it the same way we did in
qhttpheaders.cpp in e3fe3997ebd2baaafdfa7aa3c1eb95e8048268f8.

Task-number: QTBUG-103721
Pick-to: 6.9 6.8 6.5
Change-Id: Ia55149102013fa4e1619be68a69bc52b46e0f006
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-13 00:51:40 +01:00
Marc Mutz
3aa431e3fe QGraphicsAnchorLayout: make createSlack() return a proper struct
... instead of std::pair.

This is in preparation of breaking QSimplexVariable up into
QSimplexVariable (with protected dtor) and trivial subclass
QConcreteSimplexVariable, to statically ensure that we're not deleting
derived classes (AnchorData) through QSimplexVariable pointers (which
is UB, and subject to a Coverity complaint).

This is basically the same program we did for QBrushData, culminating
in 3bbc9e29ef59683351cf35c19a8bd4a030615c64.

This second patch modernizes the code a bit and, by scoping the
variable holding the return value of createSlack() tighter, allows the
use of auto and therefore isolates the code from the changes in the
final patch of the series.

Pick-to: 6.9 6.8 6.5
Coverity-Id: 390828
Change-Id: I15b51a3118c7ef33e8351a3e198abaebf4300d61
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-03-12 23:51:40 +00:00
Marc Mutz
49809c6e41 QSimplex: scope iterators tighter in for loops
This is in preparation of breaking QSimplexVariable up into
QSimplexVariable (with protected dtor) and trivial subclass
QConcreteSimplexVariable, to statically ensure that we're not deleting
derived classes (AnchorData) through QSimplexVariable pointers (which
is UB, and subject to a Coverity complaint).

This is basically the same program we did for QBrushData, culminating
in 3bbc9e29ef59683351cf35c19a8bd4a030615c64.

This first step scopes iterators of for loops in the for-loop, and, as
drive-bys, makes them use auto and the shorter cbegin()/cend(), so
they fit into a single line, and fixes the extra {} around single-line
bodies (only in touched lines).

Pick-to: 6.9 6.8 6.5
Coverity-Id: 390828
Change-Id: I439e0a10ebb316a33e92c42c255ee209139d47a2
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-03-12 23:51:39 +00:00
Thiago Macieira
8a029843a3 qobject_cast: optimize when the target is marked final
If it is, then we can perform a direct meta object pointer comparison.
Comparing meta objects is, after all, what QMetaObject::inherits() and
QMetaObject::cast()) are doing:

    const QMetaObject *m = this;
    do {
        if (metaObject == m)
            return true;
    } while ((m = m->d.superdata));

But if we know the class is final, we know an object can either be
exactly of the type we want or not be so at all.

Change-Id: If6333547d215c1d84d1cfffdfd82c04e75251608
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-12 23:51:39 +00:00
Thiago Macieira
01ad117b32 QGenericUnixTheme: Fix build, adding missing #includes
qdbuslistener.cpp:105:5: error: ‘QJsonParseError’ was not declared in this scope
qgenericunixtheme.cpp:247:21: error: invalid use of incomplete type ‘class QDBusConnectionInterface’
qkdetheme.cpp:91:109: error: ‘QSettings’ was not declared in this scope; did you mean ‘QString’?
qkdetheme.cpp:712:30: error: ‘QStandardPaths’ has not been declared

Probably amends 53fb13456fffe8bfd192f9197c6d1703854b49a2.

Change-Id: I673a2fa3f34c162d4d76fffdf160ed8a7af1fc66
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-03-12 16:43:47 -07:00
Alexey Edelev
6685da4ec9 Ensure optional_arg is reset in qt_internal_add_global_definition
Othewise there is a risk that variable is taken from other scopes.
(Random finding).

Pick-to: 6.5 6.8 6.9
Change-Id: I2517adec5d82639e95ac2758633109413811cf9a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-12 22:55:19 +01:00
Kai Uwe Broulik
d28881fa33 QTabWidget: Draw base for corner widget only if QTabBar::drawBase
QTabBar draws PE_FrameTabBarBase only when drawBase is enabled,
so QTabWidget should honor this as well.

Otherwise, there will be an awkward line below the corner widgets
but not the tab bar when disabling drawBase on the built-in QTabBar.

Pick-to: 6.9 6.8
Change-Id: I7621476d66c3580282846dc924cd0b3700ce250f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-12 21:36:58 +01:00
Ivan Solovev
dd54e32d9a qdbusxml2cpp: remove unneeded newlines in the end of the cpp files
The tool was writing too many newlines, which either produced unneeded
newlines directly in the end of the file, or before the moc-related
include.

Amends 351b7a31aa24a704dba09121d91cb34190892315.

Task-number: QTBUG-133611
Change-Id: I38046cabe86625ecc3da827c434db0dca09a0d63
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2025-03-12 19:32:22 +01:00
Ivan Solovev
94465265ac qdbusxml2cpp: remove stray whitespaces in the end of the line
Found when trying to commit the updated QtBluetooth proxies into the
repo.

Amends 351b7a31aa24a704dba09121d91cb34190892315.

Task-number: QTBUG-133611
Change-Id: Ifadd6fd8402a23a14e46cdb6beceae6b59e1dca1
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2025-03-12 19:32:22 +01:00
Marc Mutz
eb3df4edbc Long live Q_PRE/Q_PRE_X!
As decided with lazy consensus on the development ML¹, we'd like to
separate precondition checking from internal consistency checking.

Add a new Q_PRE/Q_PRE_X macro for the former, to leave Q_ASSERT/_X for
the latter.

As requested in review, modernize Q_PRE_X vis-a-vis Q_ASSERT_X by
skipping the `where` parameter (defaulting it to Q_FUNC_INFO).

Added as undocumented API, for now, to pick back to all active
branches without actually promising semantics different from Q_ASSERT,
a change that, realistically, will only happen for 6.10 at the
earliest. But by making the macro available to all active branches, we
avoid conflicts when picking changes back, and the change is rather
risk-less.

Apply to QStringView, to have at least one user.

¹ https://lists.qt-project.org/pipermail/development/2024-August/045588.html Items 1-3.

Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-98965
Change-Id: Ia04248a64c8feba80cce10f8f5cbde580436db88
Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-03-12 19:32:22 +01:00
Joerg Bornemann
3223c06d43 CMake: Show the "Docker image ... not found" warning only once
...when configuring Qt with QT_BUILD_TESTS=ON and without
QT_SKIP_DOCKER_COMPOSE=ON. There's no point in flooding the output with
the same warning.

Change-Id: Ic7ab38dc0ca7d6cec31501da4c79170cf26e66a1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-12 19:32:22 +01:00
Lucie Gérard
e70d7e611e Update licensing of files with infrastructure type
A QUIP 18[1] update sets git files, REUSE.toml and licenseRule.json
as infrastructure type files. They are licensed with:
LicenseRef-Qt-Commercial OR BSD-3-Clause

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

Pick-to: 6.9 6.8
Change-Id: Ia7b9ae097ff80bd184256e0b7efa0dd7cfa63def
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-03-12 16:04:26 +01:00
Shawn Rutledge
2a85bdc77a Mark HTML, CSS and Markdown parsers as security-critical
Pick-to: 6.8 6.9
Task-number: QTBUG-134508
Change-Id: Ib973b9344a19fa2f8c79e2a2ceddf530d9ab62cd
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-12 15:05:09 +01:00
Wladimir Leuschner
5d8c3a5985 WindowsQPA: Add default window title to custom titlebar
In case that no window title was provided use the
QCoreApplication::applicationName when Qt::WindowTitleHint was provided.

Fixes: QTBUG-133942
Pick-to: 6.9
Change-Id: Ieeff0ba97bd996225c6f83f691fc1c149e3d7172
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-12 13:59:34 +01:00
Marc Mutz
8492ba01ba qdrawhelper: (attempt to) fix Coverity warning about op being uninit'ed
Unlike in other cases of structs, Coverity doesn't say which field,
exactly, it considers uninitialized in `op` upon return from
getOperator(). Manual checking confirms that all fields are written in
all branches (and all configs, btw), with the following exceptions:

- src* fields are not written in QSpanData::None mode, but this branch
  is marked as Q_UNREACHABLE()

- `linear`/`radial` are only written in QSpanData::Linear- or
  RadialGradient mode, which means that their (unnamed) union is not
  written in Solid/ConicalGradient/Texture modes

Assuming it's the latter branch that trips Coverity, introduce a
std::monostate member, noGradient, to said union, and initialize it
Solid/ConicalGradient/Texture modes. This makes the union a kind of
optional, but without the churn of actually introducing a
std::optional<Union>.

The effect is that in those modes the active union member is now the
empty monostate, so static analyzers will not complain about `linear`
or `radial` being uninitialized (because they're not active members).

'noGradient' being the active union member should also help statically
and dynamically (ubsan, one day?) detect accesses to `linear` or
`radial` when they're not active. Before, I believe the first declared
of the two was implicitly active.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5
Coverity-Id: 11400
Change-Id: I743363cc06af3778f85c205bfb6880c696229f92
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-03-12 11:39:19 +00:00
Magdalena Stojek
275396b013 Expand Qt XML documentation on behavior changes in Qt 6
Adds a more detailed overview of behavior changes between Qt 5 and Qt 6
in the Qt XML module. This update is based on multiple reported tickets
highlighting behavior differences, where users requested further
explanations.

Fixes: QTBUG-134503
Pick-to: 6.9 6.8
Change-Id: I2e25268c6de7fd7e3a0e0244b83bb2ba616ef60e
Reviewed-by: Safiyyah Moosa <safiyyah.moosa@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-03-12 11:13:35 +01:00
Moss Heim
7bec2f6b42 Docs: fix typo
\l instead of \\l

Amends d3117e97014af029b2c117daef9695b87103ab25.

Pick-to: 6.9 6.8 6.5
Change-Id: I0b6aaef6de839f29e0671d382d4555f8ab0afe47
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-12 08:29:10 +00:00
Volker Hilsheimer
87965f0556 Build system: reduce verbosity of documentation commands
Cmake will print the entire command line for custom targets if no
COMMENT field is set. Add that to reduce the verbosity and make the
output a bit more manageable; verbose builds will still print the entire
command.

Change-Id: Ifedcb75fed4614788ffa9a6b121e2b435810a379
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-12 09:29:10 +01:00
Christian Ehrlicher
9684691d51 QIcon: call qt_findAtNxFile for all devicePixelRatios available
QFile::addFile() was searching for '@N' - image file where N corresponds
to the devicePixelRatio of the QGuiApplication. Since we can have more
than one screen, all different devicePixelRatios should be considered.

Pick-to: 6.9
Change-Id: I7c844e163c5b5ca8752d8461139d7abf39c2e8a5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-12 09:29:09 +01:00
Mitch Curtis
b35ea9b974 Make dprgadget manual test directly openable in Creator
This avoids the need to run qt-cmake-standalone-test and then import
the test, as described in QTCREATORBUG-25389.

Pick-to: 6.9 6.8 6.5
Change-Id: Ie9694569c24dc0c714c2538819e7d9d8ff7e44e4
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-03-12 14:07:37 +08:00
Eirik Aavitsland
523973f16b Add Qt-Security tag for ICC profile parsing
According to QUIP-23

Pick-to: 6.8 6.9
Change-Id: I7c7b24d8a2d0ca8ae0b330573839723497fdfd38
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-03-12 06:11:07 +01:00
Eirik Aavitsland
5157ce7c59 Add Qt-Security tags to gui image, icon and imageio files
According to QUIP-23

Pick-to: 6.9 6.8
Change-Id: I10d6109d2365e9252ab60f5c3bdfc8de2d606f15
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-03-12 06:11:07 +01:00
David Faure
ada885dfd5 QKeySequence: tolerate spaces when parsing a key sequence string
Fixes: QTBUG-130063
Pick-to: 6.9 6.8
Change-Id: I0f0aff0ca0824cd1c9297cd18a1f5cf9a2a44951
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2025-03-12 03:39:01 +00:00
Marc Mutz
67e9e2a7e2 QCssParser: shrink indexOfId by half
All offsets fit into [0:255], so use uchar instead of short to store
them, cutting the storage requirement of the array in half (-86 bytes).

As drive-bys
- make the array constexpr
- fix formatting (only in touched lines)
- port from explicit to implicit bounds with explicit bounds checking

The latter has the advantage that we don't get value-initialized
elements appended silently, cf. 5d8f815e101da3ae9cd6a666cc097853f52b21da.

Pick-to: 6.9 6.8 6.5
Change-Id: I336f850a586fd2fde8f62c65223f547402fbaa75
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-12 04:04:56 +01:00
Marc Mutz
e62bebb263 Revert "Init QWidget::data to nullptr"
This reverts commit 58b9250aea0b1b41c8cbd1033149371a93a5b2c1.

Reason for revert: This change was obsoleted by
bcd29a9eab00c77bc402b9d4242f097d19c92044.

Change-Id: I161dfeb471d23a6fdcbf547c1c559784581a5211
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-12 02:55:17 +00:00
Mikhail Paulyshka
1b8d085322 qsimd: perform RDSEED sanity check in case if available
Fixes: QTBUG-134538
Pick-to: 6.5 6.8 6.9
Change-Id: Iab51337b9b27ccf48a0e60c08cf14706112b6235
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-11 17:45:45 +00:00
Aurélien Brooke
e67568706f rhi: gl: allow readbacks for all texture formats
Texture readbacks other than RGBA8 (e.g., R32UI) are often not supported
on OpenGL ES but are fully supported on Desktop OpenGL 3.0+. So, do the
same as the float formats: always send the correct glReadPixels command,
as it should work on Desktop OpenGL.

Use the toGLTextureFormat and textureFormatInfo helpers to reduce code
duplication and support new texture formats automagically in the future.

Use QByteArray::resizeForOverwrite to avoid unnecessary zero-
initialization before glReadPixels writes data.

[ChangeLog][RHI] All readback texture formats supported by the OpenGL
implementation can now be used with the Qt RHI.

Change-Id: I537a5fceff50c2909c16702d66596dfd2fc1119e
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-03-11 18:45:45 +01:00
Marc Mutz
8761fa5b8b QHttpHeaders: de-pessimize Private::replaceOrAppend()
All callers of replaceOrAppend() (present and future) pass an rvalue
`value`, so take advantage of C++17 guaranteed copy elision, take
`value` by value and move it into place.

Even for implicitly-shared classes, a move (pointer swap) is cheaper
than a copy (atomic ref-count upping/downing; ca. 100x slower than a
normal int).

Amends d8f6425fef1050525480afec662a417a7645c22e.

Pick-to: 6.9 6.8
Change-Id: Ia52a2ec2c079f515f92b0890e42669d4ba435c20
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2025-03-11 18:45:40 +01:00
Even Oscar Andersen
53bfe72967 wasm: Honor invisible and disabled when setting visibility for a11y
Task-number: QTBUG-115926
Change-Id: I04ccf9371af4eb4890a9cfe21cc6d8f005a3cc44
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-03-11 17:45:40 +00:00
Even Oscar Andersen
c1fba2d4ee Add QAccessible::LocationChanged to QWidget
Issue the event when geometry has changed to match QML.

Task-number: QTBUG-115926
Pick-to: 6.9 6.8
Change-Id: I31d87a2b07c1cbdb31063bdbf146f21310103798
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-11 17:45:40 +00:00
Volker Hilsheimer
df96b28f65 QDockWidget: fix documentation of the new dockLocation property
Follow the standard syntax for property documentation.

Amends cbd2f56c14159a1a566f4e423b910256724fdb6a.

Pick-to: 6.9 6.9.0
Change-Id: I3557eba1990b684a35ab70f95e7f8ccf33850537
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-11 18:45:40 +01:00
Marc Mutz
1d2dda041a QQOpenGLProgramBinaryCache: split FdWrapper to fix a Coverity UNINIT warning
Coverity complained that mapSize was used in ~FdWrapper uninitialized
when the object was destroyed before map() had been called on it. This
is a False Positive, because in that case, ptr == MAP_FAILED, and we
wouldn't be reading mapSize.

But be nice and split the FdWrapper class into two, by creating an
object managing only the mmap() part of equation and returning it from
map(). The most-natural choice for such an object would be a
unique_ptr with a custom deleter, but that has built-in knowledge of
nullptr (ie. doesn't call the deleter on nullptr), which, at least
theoretically, is a valid return value of mmap() (the error case is
(void*)-1), so write a small struct ourselves.

Coverity-Id: 390668
Pick-to: 6.9 6.8 6.5
Change-Id: I43d635617bd26120cf402241bf59680fe63d071a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-03-11 17:06:23 +01:00
Marc Mutz
ab1ce95c8c [docs] QString: fix link and formatting in the qPrintable() discussion
The old code used a `<QString>` to indicate an object of QString
type. I have not seen this pattern used elsewhere, so rewrite the
expression to say "call X on the QString" instead of "call
<QString>.X".

Also, the constData() link in the expression ('X' in the previous
paragraph) was unqualified, so resolved to QString::constData(), but
the result of toLocal8Bit() is a QByteArray, and it's thence the link
should point to. Redirect it manually whereever we fell into that
trap.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I2204522351976be0f045bfd60a30c82c9e784dd6
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-11 17:06:23 +01:00
Marc Mutz
b83f104889 Extend tst_QByteArray::replaceWithEmptyNeedleInsertsBeforeEachChar()
Add rows with needles and haystacks whole length is > 1 (to avoid only
hitting paths that use single-char matching).

Amends 5fc1e9fa0c1925654412af5bf46ff95da99bc190.

Pick-to: 6.9 6.8 6.5
Reported-by: Ahman Samir <a.samirh78@gmail.com>
Change-Id: Ie4c695f54d84cdb56b93fee6b7224d93faf00f75
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-03-11 17:06:22 +01:00
Marc Mutz
9b849eea41 QTimeZone: return a shared copy from utc()
The UTC time-zone never changes, not even under a locale change, so
memoize utc() using a Q_GLOBAL_STATIC cache. Check its isDestroyed()
and fall back to the current implementation in that case. This keeps
the function available even in late shutdown stages.

_This_ is a knife^Woptimization:

 PASS   : tst_QTimeZone::utc()
 RESULT : tst_QTimeZone::utc():
-    33.1472430 nsecs per iteration (total: 331,472,431, iterations: 10000000)
+    12.8953219 nsecs per iteration (total: 128,953,219, iterations: 10000000)
-    150.5929452 CPU cycles per iteration, 4,54 GHz (total: 1,505,929,452, iterations: 10000000)
+    60.3382987 CPU cycles per iteration, 4,68 GHz (total: 603,382,988, iterations: 10000000)
-    396.0402927 instructions per iteration, 2,630 instr/cycle (total: 3,960,402,928, iterations: 10000000)
+    84.0138436 instructions per iteration, 1,392 instr/cycle (total: 840,138,437, iterations: 10000000)
-    96.0069811 branch instructions per iteration, 2,9 G/sec (total: 960,069,811, iterations: 10000000)
+    28.0024131 branch instructions per iteration, 2,17 G/sec (total: 280,024,132, iterations: 10000000)

Amends HEAD^.

Change-Id: I4496f3a4c1f64b0615930337662bcd04af0a2ade
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-03-11 17:06:22 +01:00
Giuseppe D'Angelo
b3c75be5e0 QTimeZone::utc(): micro-optimize it
QTimeZone::utc() goes through the QTimeZone(int) constructor,
passing 0 to it. That in turn calls the QUtcTimeZonePrivate(int)
constructor, which ends up matching the zero offset and doing some
string comparisons.

I think we can bypass this mechanism and simply have QTimeZone::utc()
create a QUtcTimeZonePrivate and set it.

Compare the following results for tst_QTimeZone::utc benchmark as
built on a machine with:

    Config: Using QtTest library 6.10.0, Qt 6.10.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 14.2.1 20250207), arch unknown

Before:

    36.708812 nsecs per iteration (total: 36,708,776, iterations: 999999)
    169.024518 CPU cycles per iteration, 4,6 GHz (total: 169,024,349, iterations: 999999)
    601.286607 instructions per iteration, 3,557 instr/cycle (total: 601,286,006, iterations: 999999)
    139.051610 branch instructions per iteration, 3,79 G/sec (total: 139,051,471, iterations: 999999)

After:

    29.204813 nsecs per iteration (total: 29,204,784, iterations: 999999)
    129.981345 CPU cycles per iteration, 4,45 GHz (total: 129,981,216, iterations: 999999)
    408.260941 instructions per iteration, 3,141 instr/cycle (total: 408,260,533, iterations: 999999)
    85.047524 branch instructions per iteration, 2,91 G/sec (total: 85,047,439, iterations: 999999)

Relative Delta:

            before   after    improvement
    nsecs    36.7     29.2    1.26x
    cycles  169.0    130.0    1.30x
    instr.  601.3    408.0    1.47x
    branch  139.1     85.0    1.63x

Change-Id: Ic6fe605a3c6a83096315e2cb4309b9f67e83bccc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-03-11 17:06:22 +01:00
Matthias Rauter
fcde54148d Fix mistakes and inconsistencies in string overview
Amends 80b6f2e63dc537f419186585a528ff749f9ff739

Pick-to: 6.8 6.9 6.9.0
Task-number: QTBUG-133882
Change-Id: I8aa5f79838aba0b7fb73e1b884c1a1ceb96aec9d
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-03-11 17:06:22 +01:00
Marc Mutz
66081c52b5 QCssParser: attempt to fix Coverity OVERRUN issue
Coverity complains, for each findKnownValue() call, that "forming the
address of the element at index numValues of buffer start requires the
index to be no more than the number of elements in the buffer", citing
QCss::NumKnownValues (e.g.) as the out-of-bound index.

Since it's complaining about the initialization of `start` in
findKnownValue(), I can only assume that it is bothered by the `+
numValues` (which moves the pointer out of range) followed by the - 1
(which brings it back into range), so make sure we subtract 1 before
adding to `start`.

That array + numValues would be considered outside the array
(incl. one-past-the-end) is highly irregular, and, AFAICT, caused by
the arrays not storing the resp. "unknown" entry at index 0,
effectively turning the arrays into Pascal (base-1) ones.

Shot in the dark (and a sign of poor/overly-strict deduction
capabilities in Coverity, if this is actually fixing the issue), but
worth a try.

Amends previous fix attempt 204b6c99089bcf7893be326e7d0076402b7abf0c.

Pick-to: 6.9 6.8 6.5 5.15
Coverity-Id: 183557
Coverity-Id: 183559
Coverity-Id: 183560
Coverity-Id: 183569
Coverity-Id: 183573
Coverity-Id: 183574
Coverity-Id: 183579
Coverity-Id: 183584
Coverity-Id: 183585
Coverity-Id: 183586
Coverity-Id: 183589
Task-number: QTBUG-83817
Change-Id: I3ad1f744986fe3223571a919b8a537c544ef314c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-11 17:06:22 +01:00
Marc Mutz
455e0ff42a QUnicodeTools: collapse adjacent identical case statements
They were left in to for easier reviewing when the old function
pointer table was changed to this switch. In this second step, we can
now collapse adjacent duplicates into one each.

Pick-to: 6.9 6.8 6.5
Change-Id: I7b7fa8991817895a01c63251ab3b0ecc95b5756b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-11 17:06:22 +01:00
Marc Mutz
f18e8cebfc QMovableArrayOps::Inserter cleanup [3/3]: cut out the where middle-man
It turned out that we've been maintaining both displaceFrom and its
copy, `where`, in parallel.

This is not needed, so only maintain displaceFrom.

Pick-to: 6.9 6.8 6.5
Change-Id: I8c13420ae3fd284e362c4dd1f1b06d2847780c86
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-03-11 16:01:14 +00:00
Eskil Abrahamsen Blomfeldt
2198cdc406 Mark low-level text classes as security critical
These files process raw end user provided data and
apply structure to it, through layout and Unicode algorithms.

Extra care should be taken when reviewing changes to these
files.

Pick-to: 6.8 6.9
Change-Id: Iba86aec1a185bbbcd40aa2b8d4d0d839bb99ba0d
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-03-11 17:01:14 +01:00
Eskil Abrahamsen Blomfeldt
6704e55a9c Mark font code as security critical
These files process raw font tables from untrusted files.

Pick-to: 6.8 6.9
Change-Id: Ie7fbfb667984e2d003b343a2ce011ad0e5aa04d2
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-03-11 17:01:14 +01:00
Morten Sørvig
57f98a095e wasm: implement move for QWasmEventHandler
Implement move by copying the emscripten::val member
variables, and clearing the moved-from ones. This ensures
that the moved-from val is in a known state ("undefined").

Also move the non-default constructor declaration up to
the top of the class.

Change-Id: If9574cc91a53d4029d49b29b89819d98319acaa3
Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-03-12 02:01:13 +10:00
Aurélien Brooke
dc033758a3 rhi: support partial region readbacks in QRhiReadbackDescription
Add a `rect` property to QRhiReadbackDescription, enabling users to
specify a sub-rectangle for texture or backbuffer readbacks. This is
particularly useful for scenarios where full texture readbacks are
unnecessary, like reading only one single pixel.

[ChangeLog][RHI] Added support for specifying a sub-rectangle for
readbacks in QRhiReadbackDescription. This allows partial texture or
backbuffer readbacks.

Change-Id: If7465e97bc90907442e2d2981826e1e26b0e4a50
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-03-11 17:01:13 +01:00
David Redondo
58e68f1981 Move client hardware integration sources into the plugin folder
Change-Id: I49629ce1d55d8762ab30c33062fb78b05fdb05d4
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-03-11 16:45:25 +01:00
David Redondo
ab73b6c286 Consolidate the platform plugins
Instead of having multiple platform plugins, have one that switches
behavior depending on the requested platform. From the outside there
is no behavior difference. Requesting wayland-egl or wayland-brcm
fails if the feature was not enabled and initializes the client
integration early.

Task-number: QTBUG-133223
Change-Id: I6fbaec7309b78cfcc470ad18dd6b63008119760e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-03-11 14:22:16 +01:00
Marc Mutz
57d91d8029 QByteArray: make replace() consistent with QString's
Assuming QString has seen a lot more effort put into this, simply copy
the preamble of QString::replace(ptr, n, ptr, n, cs) over to the
corresponding QByteArray::replace(view, view) function, so they behave
the same.

On reviewer request, change d.size == 0 to isEmpty(), in both functions'
preambles.

[ChangeLog][QtCore][Important Behavior Changes][QByteArray] replace()
is now consistent with QString::replace() in its treatment of empty
haystacks and needles.

Fixes: QTBUG-134079
Change-Id: I2366febee7de4646d6b33c39d2338760b58f2ec4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-03-11 14:00:45 +01:00
Kai Uwe Broulik
61c2d3f101 QTabWidget: Guard QTabBar in documentMode
While QTabBar is created by the QTabWidget and therefore doesn't
need to be guarded, QTabBarPrivate::init calls QStyle::styleHint
which might result in QStyleSheetStyle querying properties on
the QTabWidget while its QTabBar isn't assigned yet.

Pick-to: 6.9 6.8 6.5
Change-Id: Ic832d3253c5dc54d8d718760c63f34f0b8bde000
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-11 13:00:45 +00:00
Laszlo Agocs
f9a625eb8c Add trusted content notes to QOpenGLShader(Program)
Pick-to: 6.9 6.8
Change-Id: I089044e6834ebbb992b36c898eb956959f430522
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-03-11 13:54:48 +01:00
Laszlo Agocs
8612bd8345 rhi: Add doc notes about security considerations
Pick-to: 6.9 6.8
Change-Id: Iee3ef375a5f08a0bac5fed2b45ff1d7a3b146dc5
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-03-11 13:54:48 +01:00
Laszlo Agocs
30dc9ed13f rhi: vulkan: Double buffer the descriptor sets backing an srb always
This is almost always the case in a typical Quick or Quick 3D rendering
sequence, since there is almost always a uniform buffer, which is almost
always a QRhiBuffer::Dynamic buffer, thus triggering double (or triple,
whatever max_frames_in_flight is) buffering and using multiple
descriptor sets.

This breaks down e.g. when using a compute pipeline and a
texture for imageLoad/store in the srb. If the texture is rebuilt
between frame N and N+1, then in frame N+1 the srb sees that the
descriptor set needs to be rewritten, but that's wrong since frame
N might still be in flight, using that descriptor set.

From now on, pretend that an srb always needs double buffering,
regardless of what kind of resources it references.

Also drop unused code paths. The updateShaderResources function's
argument was never -1, for example, so no point in keeping that logic.

Pick-to: 6.9 6.8
Change-Id: If8abb42fd9a2de5aad59ab6ceab3c8086aebae68
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-03-11 13:54:48 +01:00
Laszlo Agocs
e9fa3e4244 rhi: gl: Fix an srb tracking issue
Have two pipelines that are used with the same srb:

setPipeline(a);
setShaderResources(s);
draw
setPipeline(b);
setShaderResources(s);
draw

If this is repeated each frame, then on the second an subsequent frames
the uniforms for the program behind pipeline b will not be set,
i.e. the glUniformxx calls will be missing.

This is due to the pipeline's own srb tracking
(currentSrb/currentSrbgeneration) works: in the second frame
setShaderResources(s) for pipeline b will do nothing, since
the command buffer's tracked current srb is already s, and
also b's currentSrb is already s.

The problem remains hidden usually because Quick or Quick 3D
does not generate sequences like the above (same srb with different
pipelines).

Pick-to: 6.9 6.8
Change-Id: I56b962f0ba12370e0de7c87fb7178a0b9e4b0178
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-03-11 12:54:48 +00:00
Laszlo Agocs
25394fab9a rhi: gl: Fix exposing 3D and array textures as load/store images
The expectation, based on what the other backends do, is that all array
layers and 3D texture slices are exposed (i.e., the whole texture).
Same for cubemaps (all six faces), that at least was in place
already.

This is what the odd-named 'layered' argument of glBindImageTexture
controls. Set it accordingly.

Pick-to: 6.9 6.8
Change-Id: If6808069dfc9f3df124e508e40abf8c3423289da
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-03-11 13:54:47 +01:00
Laszlo Agocs
efc911aa58 rhi: gl: Specify 3D textures with mipmaps correctly
When used with load/store, it is already correct due to using
glTexStorage3D. On the other code path however, individually
calling glTexImage3D for all the mip levels requires adjusting
the depth for each level, as it is done for width and height.

Pick-to: 6.9 6.8
Change-Id: I440cc10303687b686d78da4c614da4325840803a
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-03-11 13:54:47 +01:00
Laszlo Agocs
ff7dfd7216 Expose the Vulkan 1.4 core API
Non-trivial update this time. Recent vk.xml adds the option of listing
"vulkiansc" in the api attribute, which we did not handle before in
qvkgen for command elements at all, and was not treated as a
comma-separated list for feature elements. Fix these up.

Also add 1.4 in QVulkanDefaultInstance, so that 1.4 goes into
VkApplicationInfo.apiVersion, when available, incl. in Qt Quick.

[ChangeLog][QtGui] QVulkanFunctions and QVulkanDeviceFunctions are
updated to expose the Vulkan 1.4 API as long as Qt is built against
Vulkan 1.4 headers.

[ChangeLog][Third-Party Code] Updated vk.xml to 1.4.308.

Change-Id: I8bc4bb578575bcbb189286a26617cd0052241be5
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-03-11 13:54:47 +01:00
Ilya Fedin
5e9c9eba0f client: Attempt to request activate even if there's no last input device
The compositor is likely to display some indication
even if the activation fails but it doesn't happen
if there were no input due to the last input device condition,
resulting in no indication of activation failure on first window show.

Amends 41a9ffeb0c7309e9e2b84c3b3666a423dedce317
Amends 0fc235c5030ee6fb70dd145b1faad1567cf39788

Pick-to: 6.9 6.8
Change-Id: I08308c3338c0d3fa2c36004eb8f75ad0c1bcce4f
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-03-11 14:25:51 +04:00
Kai Uwe Broulik
732ea4faca QWaylandShmBackingStore: Clear in beginPaint based on surface format
It's the surface format that matters not the backing image format.
Now that QWaylandShmWindow sets a proper QSurfaceFormat, we can
actually check it.

Change-Id: Ia17a9f06cd335b6e8f6989051bc9d0cef9bfe3f3
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-11 10:36:03 +01:00
Axel Spoerl
53fb13456f Refactor qgeneericunixthemes_p.h/cpp
Header and implementation file of QGenericUnixTheme contained several
helper functions and classes. It also contained the implementation of
QGnomeTheme and QKdeTheme, both of which are not generic.

Split qgenericunixthemes_p.h/cpp up into separate files.
Group all helpers as static member functions in QGenericUnixTheme.
Inherit QGnomeTheme and QKdeTheme from QGenericUnixTheme.

Task-number: QTBUG-132929
Change-Id: Idfa6198a2b7f669edd009dc165375a9b2960fcad
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
2025-03-11 10:02:39 +01:00
Marc Mutz
3bbc9e29ef Verify correctness of QBrushData handling
Ensure that QBrushData itself is never deleted nor created as-is,
but only through its subclasses.

Coverity-Id: 11772
Coverity-Id: 218724
Change-Id: If3348da676331dd575ba61c5c618faa283dd6889
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-10 20:14:20 +00:00
Marc Mutz
b615c477f6 Don't leak memory when tst_QOpenGL::fboTextureOwnership() fails
Hold 'fbo' in a (const) unique_ptr instead of a raw pointer, so it is
deleted even if a following QVERIFY/QCOMPARE fails.

This shows that the leak (cf. QTBUG-134557) is not due to the test
itself.

Amends dcbb16a45212d263496df1e5875da6205e4f5f53.

Pick-to: 6.9 6.8 6.5 5.15
Task-number: QTBUG-134557
Change-Id: I2f854d5ff036b7ca5e51d2e9ecb1d04bf7a39a61
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-03-10 21:14:20 +01:00
Marc Mutz
7a1cd692e0 tst_QOpenGL: don't leak 1399341 byte(s) [...] in 1439 allocation(s)
That's what asan reported for a run of this test executable.

Create `ctx` on the stack instead of the heap to fix the leaks.
For `fbo`, use a std::optional.

After these fixes, the test still leaks 64 bytes in 2
allocations. These seem to be QOpenGLSharedResourceGuards in a
QOpenGLFramebufferObject. Created QTBUG-134557 to track the issue.

Amends
- 68974d8e647febb80a47d9cf6ce9452f3ce4fa21 (fboHandleNulledAfterContextDestroyed())
- bb760d9514ed617ee8e7344152b3fa697b2c4171 (bufferMapRange()/bufferCreate())
- 0541516907da117c391b6c8d9820209673fcd9cd (vaoCreate())

Pick-to: 6.9 6.8 6.5 5.15
Task-number: QTBUG-134557
Change-Id: Icc318cd76b9f3ddf71bc294cb96d88485c42d7bc
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-03-10 21:14:20 +01:00
Marc Mutz
75df3a250d QMovableArrayOps::Inserter cleanup [2/3]: mark most data members const
This makes explicit that the only thing that should be changing is
displaceFrom, which tracks the hole-filling process.

Requires rewriting of the dtor a bit, to skip the nInserts
modification.

Pick-to: 6.9 6.8 6.5
Change-Id: I1f0ce17cbeb171704f789624ad1be6ef70e58245
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-03-10 17:27:24 +00:00
Marc Mutz
82d4a81df1 QMovableArrayOps::Inserter cleanup [1/3]: inline displace()
Since the ctor is now the only caller of displace(), we can inline the
latter into the former, using ctor-init-list to initialize the
members.

Also fix decltype(bytes) to be size_t, which is what memmove(), the
only user of the value, expects, and ptrdiff_t * sizeof(T) yields
(found by GCC -Wnarrowing complaining).

Pick-to: 6.9 6.8 6.5
Change-Id: I3f93e28eebc6deefee8a182eb71a3b0958718ba0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-10 18:27:24 +01:00
Fabian Kosmale
c170381f33 moc: Add a hidden option to make QML macro warnings fatal
We don't want to make them fatal by default, as that could break user
projects with identifiers whose name collide with the macros (which is
fine if they don't actually want to use the registration macros).

However, when using qt_add_qml_module, we can assume that anything
looking like a registration macro should actually be one.

Prepare for this by adding a flag which makes the warning fatal,
and which can then be set in qtdeclarative.

Task-number: QTBUG-134148
Change-Id: I3a49968b05d66e4e4ca3a8a2dae1a7b543471c68
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-03-10 17:09:52 +00:00
Emir SARI
d5f00591cd QProgressBar: Make the default value translatable
QProgressBar currently does not expose the default value
for translation automatically. This is an issue for languages
that use a different percent formatting other than the
standard 100%. Default format has to be made explicitly
available for translation, and it is not common among the
most Qt and KDE software. This aims to fix the issue via
making it available for translation, so that it could be
translated at one source instead of fixing it in various
software.

Fixes: QTBUG-127713
Change-Id: Icd73cf48ad3cdf441e8e7aba58151cc538adff6a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-10 15:33:25 +00:00
Volker Hilsheimer
9c87c99180 QAIM: return false if nothing was (or could be) done in setItemData
Setting item data on an invalid index, or with an empty map, surely is
not a successful operation.

[ChangeLog][Core][QAbstractItemModel] Calling setItemData with an
invalid index or empty map of data returns false.

Change-Id: Id087581243c8fa39a8cc78b811ecd087deea4466
Reviewed-by: David Faure <david.faure@kdab.com>
2025-03-10 16:33:25 +01:00
Tim Blechmann
39015c049b cmake: don't pass ftemplate-depth with clang-cl
clang-cl does not support -ftemplate-depth. so we should not pass it
when MSVC is defined.

Pick-to: 6.8 6.9
Change-Id: I7f411187c476fa275b677f96a19f782262dc4545
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-10 21:39:27 +08:00
Kai Uwe Broulik
dfed8e3c3d QWaylandShmBackingStore: Implement scroll
Allows to more efficiently scroll existing buffer contents
as opposed to having them redrawn by the application.

Change-Id: I1005b718a18f078f6bbf47f08dbda4f87b3ab0f5
Reviewed-by: David Redondo <qt@david-redondo.de>
2025-03-10 15:16:30 +02:00
Cristian Le
3617409325 Make RunCMake compatible with CMake<3.18
Avoid using `cmake_language`.

Reverting commit:
67f97f5478

Pick-to: 6.9 6.8
Change-Id: I8311508c904cbc66aa663a0b62f861b7b056b526
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-03-10 13:34:21 +01:00
Tim Blechmann
1bdf5059ce unreachable: silence warning with clang-cl
clang-cl does not warn about return after unreachable, but would warn
about the unused variable after return.

Pick-to: 6.8 6.9
Change-Id: Ia0fcff4f536d51d56eb915a9130cc3f72437d8d1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-10 18:12:21 +08:00
Kai Uwe Broulik
12e55c95b2 Honor request for (no) alpha channel in SHM windows
Currently, all QWaylandShmWindows are ARGB32, even if the
application did not request an alpha channel (most toplevel
windows without client-side decoration).

Instead, create an ARGB32 or RGB32 buffer depending on whether
the surface requested an alpha channel. In order to do this,
set the red/green/blue channel of the QSurfaceFormat to 8 (since
that's all we support right now). Alpha channel is set to 8 or 0
depending on whether the surface requested alpha.

Due to client-side decorations we cannot know in advance whether we
need an alpha channel, so we have to update the surface format in
setWindowFlags.

While it doesn't particularly matter from the compositor's POV
(ARGB and XRGB are the same size and there's the opaque region
on the surface), Qt's backing store can skip certain steps in
the rendering, such as clearing the paint region before painting
when the surface is opaque.

Change-Id: I7b74f19ddb05d8ca9ae325f8fd5f42f41875cc51
Reviewed-by: David Redondo <qt@david-redondo.de>
Reviewed-by: Xaver Hugl <xaver.hugl@kde.org>
2025-03-10 09:47:37 +01:00
Marc Mutz
aa8e8ffd32 QMovableArrayOps::Inserter: move the displace() call into the ctor
Coverity complained that ~Inserter() will access at least displaceFrom
and displaceTo uninitialized, which is correct, if none of the
insert() overloads have been called in-between. This is a brittle
construct, even though, currently, all users of the class comply.

To help Coverity (and other readers of the code) understand what's
going on, move the displace() call that creates the hole in the
container which the insert() overloads then fill from said overloads
into the ctor, original-RAII style (ctor acquires the hole, dtor closes
it, if needed). This means all fields are initialized in the ctor now.

This is safe, as displace() cannot fail by itself (just a memmove()),
but requires moving the (pos, n) (= hole) information into the ctor
instead. The displace() call in the insert() overloads now becomes a
read of its return argument, displaceFrom.

(Incidentally, that shows that we have maintained the same pointer
twice in the insert overloads, something we'll clean up in a
follow-up.)

In order to verify the insert() post-condition (ie. that we filled the
whole hole created by the ctor, or threw an exception trying),
continue to pass the count to insert().

As a drive-by, rename the insert()-overloads to insertRange() and
insertFill() to match the existing insertOne() function, and to better
express what their purpose is.

Pick-to: 6.9 6.8 6.5
Coverity-Id: 378364
Coverity-Id: 378461
Coverity-Id: 378343
Change-Id: I1a6bc1ea0e5506d473f6089818797b02d09ba13e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-03-10 06:21:32 +00:00
Marc Mutz
74765ebe65 QUnicodeTools: reduce unneeded relocations
Turn the charAttributeFunction array of function pointers into a
switch. This has two benefits:

- The compiler now warns when we introduce a new QChar::Script value
  and statically forces us to think whether a new attribute handling
  function is needed.

- A table of function pointers requires relocations. A switch might
  not. GCC uses a jump table to implement this switch, jumping to
  distinct lea instructions fetching distinct function pointer values,
  and thereby removes relocations, while Clang actually forms a
  function pointer table and turns the switch into an indexing
  operation (with compiler-generated guards). I didn't check whether
  Clang's table actually requires relocations, relinfo.pl doesn't
  report any reductions, but it's become unreliable over the years,
  because it doesn't for GCC, either.

Difference:
  qunicodetools.cpp.o:
- 0000000000000000 l     O .data.rel.ro.local     0000000000000108 QUnicodeTools::Tailored::charAttributeFunction
  0000000000000000 l    d  .data.rel.ro.local     0000000000000000 .data.rel.ro.local

See
  https://stackoverflow.com/questions/19067010/finding-where-relocations-originate/19338343#19338343
for the script to generate this output.

See https://www.akkadia.org/drepper/dsohowto.pdf Section 1.6 for why
we care.

Instead of collapsing identical return statements from adjacent case
statements into one, keep the per-case return statements for now, to
aid review, and clean up in a follow-up commit.

Amends dd7d8304bbe599320b163b94e9a4ad9a6f35b740.

Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-100536
Change-Id: Ic5b6bd29e3a3a88f0d194fa7d76272a4770b9840
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-10 07:21:22 +01:00
Aurélien Brooke
ec2e3e7ac9 QMessagePattern: add the %{threadname} placeholder
The thread name is often more meaningful than a number or pointer.

[ChangeLog][QtCore][Logging framework] QMessagePattern /
QT_MESSAGE_PATTERN now support the %{threadname} placeholder.

Change-Id: I7ad8821c8b887e428023144d6e93e20c53bf757e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-10 01:28:25 +01:00
Christian Ehrlicher
c8338d8e77 QFusionStyle: Disable SH_EtchDisabledText
SH_EtchDisabledText is not widely used in fusion style and where it is
used it
 - does not make any real difference for light mode
 - makes the text look like one missed the glasses

Therefore disable this hint for fusion.

Pick-to: 6.9 6.8
Fixes: QTBUG-134533
Change-Id: I42fc20349603cf610ee725802f1095008eafd183
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-09 20:32:23 +01:00
Thiago Macieira
6763e25cbc QThread/Unix: split the destruction of the exiting thread's QThreadData
As noted in the comment, we had a chicken-and-the-egg problem with
plugins and the event dispatchers: we need to destroy the event
dispatcher when plugins are still loaded (otherwise we could and did
crash) but we also wanted the QThreadData to exist when the plugins
unload.

The solution for that is to split the work: destroy the event dispatcher
first, then unload pugins, then destroy the current thread's
QThreadData. On ELF systems, this is guaranteed to work because we set
the init_priority to call destroy_current_thread_data() to higher than
QLibraryStore. In other systems, it's a best effort with dynamic
libraries and not guaranteed at all with static builds (don't even
report bugs).

Fixes: QTBUG-134080
Fixes: QTBUG-133861
Task-number: QTBUG-132697
Task-number: QTBUG-102984
Task-number: QTBUG-132381
Pick-to: 6.9 6.9.0 6.8
Change-Id: Ifaa28bb87338f4117d51fffdf721da68c0762e5a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-03-09 07:30:28 -08:00
Thiago Macieira
37485e9661 QFactoryLoader: move QPluginParsedMetaData to qplugin_p.h
Which is a more central header, with no other dependencies. This is just
a declarative structure with no .cpp requirements, so it fits there.

This way, qlibrary_p.h won't depend on qfactory_p.h. QLibrary,
QPluginLoader and QFactoryLoader are inextricably linked (the
plugin-parsing code is in qfactoryloader.cpp because QFactoryLoader
needs it to parse metadata too). This will later allow me to make
qfactory_p.h depend on qlibrary_p.h.

Change-Id: I0544826807f97d366142fffde0ebdc802273ffc2
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-03-09 07:30:18 -08:00
Thiago Macieira
e6a6757c14 tst_Q*Application: avoid race conditions during exitFromThread
Amends commit bfbd1a281dd00c47df315c06e895bf5d53cd8764. I've noticed
this on my Mac, because the main thread crashed at the same time as the
exitFromThread() thread was exiting and was running ~QLibraryStore:

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x106)
  * frame #0: 0x00007ff8020533be libobjc.A.dylib`getMethodNoSuper_nolock(objc_class*, objc_selector*) + 47
...
    frame #19: 0x0000000103839694 QtCore`QCoreApplication::exec() at qcoreapplication.cpp:1454:32
    frame #20: 0x0000000101fc94ea QtGui`QGuiApplication::exec() at qguiapplication.cpp:1993:12
    frame #21: 0x0000000100004b59 apphelper`exitFromThread(argc=1, argv=0x00007ff7bfeff318) at apphelper.cpp:50:5
  thread #8, name = 'QThread'
...
    frame #11: 0x00007ff8020c4f94 dyld`dyld4::APIs::dlclose(void*) + 178
    frame #12: 0x0000000103e82476 QtCore`QLibraryPrivate::unload_sys(this=0x0000600001254160) at qlibrary_unix.cpp:252:24
    frame #13: 0x0000000103e793fc QtCore`QLibraryPrivate::unload(this=0x0000600001254160, flag=UnloadSys) at qlibrary.cpp:561:36
    frame #14: 0x00000001039740c8 QtCore`QFactoryLoader::~QFactoryLoader(this=0x00000001029e5e70) at qfactoryloader.cpp:438:21
    frame #15: 0x00000001039745e9 QtCore`QFactoryLoader::~QFactoryLoader(this=0x00000001029e5e70) at qfactoryloader.cpp:425:1
    frame #16: 0x0000000101eb723c QtGui`void std::__1::__destroy_at[abi:sn180100]<QFactoryLoader, 0>(__loc=0x00000001029e5e70) at construct_at.h:67:11
    frame #17: 0x0000000101eb7209 QtGui`void std::__1::destroy_at[abi:sn180100]<QFactoryLoader, 0>(__loc=0x00000001029e5e70) at construct_at.h💯3
    frame #18: 0x0000000102046762 QtGui`QtGlobalStatic::Storage<QFactoryLoader, (anonymous namespace)::Q_QGS_piLoader>::destroyYourself(nextState=Destroyed) at qglobalstatic.h:61:9
    frame #19: 0x0000000102046736 QtGui`QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_piLoader, (anonymous namespace)::Q_QGS_piLoader>::~Holder(this=0x00000001029e5e61) at qglobalstatic.h:83:9
    frame #20: 0x00000001020465d9 QtGui`QtGlobalStatic::Holder<(anonymous namespace)::Q_QGS_piLoader, (anonymous namespace)::Q_QGS_piLoader>::~Holder(this=0x00000001029e5e61) at qglobalstatic.h:82:5
    frame #21: 0x00007ff8022f4231 libsystem_c.dylib`__cxa_finalize_ranges + 402
    frame #22: 0x00007ff8022f4052 libsystem_c.dylib`exit + 35
    frame #23: 0x000000010000755a apphelper`exitFromThread(int, char**)::$_1::operator()(this=0x000060000175612c) const at apphelper.cpp:47:9

Pick-to: 6.9 6.9.0 6.8
Change-Id: Ib1c72c7975b247cc2d17fffd6c5de89a95c22dad
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-03-09 07:27:25 -08:00
Thiago Macieira
0f9860618f tst_Q*Application: debug a crashing application
Implemented for lldb and gdb. MSVC comes with lldb.exe (it doesn't work,
but maybe some day). I couldn't find out even how to install cdb.exe, so
that's left as a task for someone else.

Pick-to: 6.9 6.8
Change-Id: I9d93747476531d4cfd53fffddecc5b3339d2fd7c
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-03-09 07:27:24 -08:00
Thiago Macieira
b03921eb9f tst_Q*Application: centralize even more the running of the helper app
Instead of having to make changes to both tst_qcoreapplication.cpp and
tst_qapplication.cpp.

Pick-to: 6.9 6.8
Change-Id: Ib451048e40b163c2c3a3fffdf7b39bcb28c9cccf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-03-09 07:27:23 -08:00
Thiago Macieira
00a30f4312 tst_Q*Application: centralize the mainAppInAThread skipping
By adding a way for the apphelper to let the caller know that it must
skip this test.

Pick-to: 6.9 6.8
Change-Id: I750e7188b8f54cea7278fffd584f8fbf433f496b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-03-09 12:27:21 -03:00
Giuseppe D'Angelo
a72077a889 Disable -Werror=tsan on GCC < 15
QGlobalStatic has a warning suppression for -Wtsan because of its
usage of std::atomic_thread_fence, which TSAN doesn't support.
That header is included in QtCore's PCH, and that triggers a GCC bug
that causes the warning to be emitted despite the suppression [1].

In a developer build, the warning turns fatal.

We could either disable PCHs in such a build configuration
(TSAN+developer-build+GCC < 15), or: simply make the warning non-fatal
on earlier compiler versions.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64117

Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-134415
Change-Id: If80a4acdb1372d00804a60361f6c3d6893b96106
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-08 05:50:36 +01:00
Marc Mutz
d429fceeeb QTriangulator: Q_DISABLE_COPY_MOVE(QInt64Set)
The class is unsafe for copy, as it would double-delete m_array,
and the move operations aren't implemented, either.

Found while fixing CID 11295.

Pick-to: 6.9 6.8 6.5 5.15
Coverity-Id: 11295
Change-Id: I8a615aaea3a8a4ad6abc8a5a9990c2dba5cfa65d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-08 03:42:51 +00:00
Marc Mutz
9fee7cdfcc Simplify QLocale::formattedDataSize()
- Introduce symbolic constants for the magic numbers 3 (= log10(base))
  and 10 (= log2(base)).

- Add and use QtPrivate::log2i() instead of manual bit fiddling. This
  makes the two cases nicely symmetric now.

Amends 9d23aebb271ea534a66cb3aceb2e63d9a1c870d6.

Pick-to: 6.9 6.8 6.5
Coverity-Id: 474294
Change-Id: I657f34878bc3a9b67b03a4d014b91e6d4de31e13
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-03-08 03:42:51 +00:00
Eskil Abrahamsen Blomfeldt
81bbbc3fc4 windows: Fix rendering monochrome glyphs in color fonts
If we encounter a normal, monochrome glyph in a color font, we
go via the normal glyph rendering code path. But since we are
drawing into a color-capable glyph cache, we need to make sure
the image we draw has an alpha channel.

This was inadvertedly broken by the refactoring in
1b85143d217042876209794bf8d0361b7ce8834f, causing black
backgrounds on all such glyphs. Since the default font in Qt Creator
is a color font, it was noticed when upgrading this to 6.9.

Pick-to: 6.9
Fixes: QTBUG-134473
Change-Id: Iee7eb73a5727324e2ff3bacc2d9ae45cb64fd0b9
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
(cherry picked from commit 54555755f8780e4e7c665a1502309da9fa807066)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-03-08 03:31:21 +00:00
Marc Mutz
f8647f8951 QHttpHeaderParser: remove unneeded relocations
Instead of a static constexpr QL1SV object (which force the compiler
to allocate storage and therefore causes relocations), use a mere
automatic constexpr object (which doesn't). There never was a need to
make this object static, as constexpr is enough to force the compiler
to constant-fold them. The lambda doesn't have access without a
capture, of course, but that is easily solved my moving the object
definition into the lambda itself.

See
  https://stackoverflow.com/questions/19067010/finding-where-relocations-originate/19338343#19338343
for the script to detect these issues.

See https://www.akkadia.org/drepper/dsohowto.pdf Section 1.6 for why
we care.

Amends 18aff2b424577b4560b32698038e9bcf68a54b88.

While at it, remove the static from the lambda, too. While it doesn't
cause relocations, it might, on weaker compilers, cause a thread-safe
static prologue to be emitted, and it's not needed, either.

Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-100536
Change-Id: Iaede4d02a84ea2e49b42f3da93a77cb8391df5bb
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-07 20:45:55 +00:00
Benjamin Buch
697aad4b8c Add returnPressed signal to spin boxes
This differs from `editingFinished`, which is also triggered when the
focus is lost. `returnPressed` is useful if the user is to explicitly
confirm the acceptance of the value, for example by means of an Apply
button next to the SpinBox.

The corresponding signal of the internal QLineEdit cannot be used as
access to it is protected.

Change-Id: Ie9a146212e6aeac5cc9e4592b1633156323426dd
Fixes: QTBUG-99797
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-03-07 15:59:43 +01:00
Edward Welbourne
e323d46cda Distinguish system locale from corresponding CLDR-derived one
Previously it was displayed as if it had been constructed from its
language, script and territory; but it is distinct from the locale
constructed in this way and may produce different results.

Report the system locale as QLocale::system() with its language,
script and country within /*...*/ following it, instead of as
QLocale(...) with these as its parameters. Add a test of the debug
output, verifying that it has the form intended.

[ChangeLog][Important Behavior Changes][QLocale] Message logging now
distinguishes the system locale from the corresponding locale -
generated from its language, script and territory - based on CLDR
data.

Pick-to: 6.9
Fixes: QTBUG-133922
Change-Id: Ic6fb137821fb7bf29d0f6446a46225cadd54b82a
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-03-07 14:47:17 +01:00
Edward Welbourne
92ec27e461 Narrow some #if-ery on QT_BUILD_INTERNAL to test more normally
Only a small early part of tst_QTimeZone::utcTest() actually needed
access to internal APIs, so only apply the #if-ery to that part.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Ifebd70005f87bbef5d03fa24fe33134fd802e2e5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-07 14:47:17 +01:00
Edward Welbourne
0b67d44656 Turn a comment in a test into an actual check
Saying the code should produce no warnings is all well and good, but
testing it produces no warnings is obviously better.

Pick-to: 6.5 6.8 6.9
Change-Id: Iafa82027fde9ef6c7157b42ff3bbcccb3d097230
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2025-03-07 14:47:16 +01:00
Aurélien Brooke
1b3b62d1b9 CMake: add a DISCARD_FILE_CONTENTS option to qt_add_resources
[ChangeLog][CMake] Added a DISCARD_FILE_CONTENTS option to
qt_add_resources().

Change-Id: I75e28b1b885b66da826c72fedcb34ae0d911e6d0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-07 14:47:16 +01:00
Carlo Bramini
1008628b34 Corelib: check if TIOCNOTTY is supported before using it
On CYGWIN, the build process fails at this point:

qtbase/src/corelib/io/qprocess_unix.cpp:878:31: error: ‘TIOCNOTTY’ was not declared in this scope; did you mean ‘TIOCSCTTY’?
  878 |             int r = ioctl(fd, TIOCNOTTY);
      |                               ^~~~~~~~~
      |                               TIOCSCTTY

TIOCNOTTY is not defined on CYGWIN because we don't need to
do anything more to disconnect our controlling terminal.
According to the man page for termio(7) from a SYSV 3.2
system, it says:

"The first terminal file opened by the process group leader
of a terminal file not already associated with a process
group becomes the control terminal for that process group.
The control terminal plays a special role in handling quit
and interrupt signals, as discussed below.  The control
terminal is inherited by a child process during a fork(2).
A process can break this association by changing its process
group using setpgrp(2)."

Change-Id: I2719f91d814ce7b71598853c4b1c70a99a4af33a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-07 14:47:16 +01:00
Carlo Bramini
48573ddda3 Tests: avoid use of stderr as name for variables and objects
On CYGWIN, I configured with -developer-build option and the build
process fails at this point:

qtbase/tests/auto/tools/moc/tst_moc.cpp: In member function ‘void tst_Moc::initTestCase()’:
qtbase/tests/auto/tools/moc/tst_moc.cpp:940:9: error: expected primary-expression before ‘const’
  940 |         const QByteArray stderr = p.readAllStandardError(); \
      |         ^~~~~
qtbase/tests/auto/tools/moc/tst_moc.cpp:941:25: error: request for member ‘isEmpty’ in ‘__getreent()->_reent::_stderr’, which is of pointer type ‘__FILE*’ (maybe you meant to use ‘->’ ?)
  941 |         QVERIFY2(stderr.isEmpty(), stderr.data()); \
      |                         ^~~~~~~

It looks like that it doesn't like to use stderr word in that manner.
Inside VERIFY_NO_ERRORS macro, I just renamed stderr to standardError
and the problem was solved.

Change-Id: I21e5a785b35db518efffccecf796b88c78ebc725
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-07 14:11:51 +01:00
Carlo Bramini
05d090b8e7 Corelib: implement support for COFF-PE & DLLs in CYGWIN
Much of the code was already implemented for WIN32.
The patch adds relevant code and implements few exceptions for CYGWIN.

Change-Id: I0621075a8a989f64a4c2391d25220ef1686342d8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-07 14:11:50 +01:00
Carlo Bramini
b98c251bfa 3rdparty: fix linking of cygQt6Core on CYGWIN
On CYGWIN, the final link of cygQt6Core process fails at this point:

qtbase/src/corelib/CMakeFiles/Core.dir/io/qprocess_unix.cpp.o:qprocess_unix.:(.rdata$.refptr.__interceptor_vfork[.refptr.__interceptor_vfork]+0x0): undefined reference to `__interceptor_vfork'
collect2: error: ld returned 1 exit status

so we just avoid that.

Change-Id: Iafe935981b507aa1449ed41e89fe6e86b9298dde
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-07 14:11:50 +01:00
Carlo Bramini
25d8db7967 Corelib, fix runtime platform detection on CYGWIN
On CYGWIN, the build process fails at this point:

In file included from qtbase/src/corelib/global/qsysinfo.cpp:40:
qtbase/src/corelib/global/qoperatingsystemversion_win_p.h:19:10: fatal error: qt_windows.h: No such file or directory
   19 | #include <qt_windows.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.

Besides the fact that qt_windows.h doesn't exist into the build
directory when compiling a POSIX-like platform, when compiling
under CYGWIN, the operating system is CYGWIN, not Windows.
So, it is better to collect those information by using Q_OS_UNIX
tools instead.

Change-Id: I496eedb58c4a3d1ce2da9fb3526a6ec5ed67f638
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-07 14:11:50 +01:00
Carlo Bramini
87c1985e52 3rdparty: fix build if POSIX monitor wait states are unsupported
On CYGWIN, the build process fails at this point:

qtbase/src/corelib/io/../../3rdparty/forkfd/forkfd.c: In function ‘convertForkfdWaitFlagsToWaitFlags’:
qtbase/src/corelib/io/../../3rdparty/forkfd/forkfd.c:253:20: error: ‘WEXITED’ undeclared (first use in this function); did you mean ‘WIFEXITED’?
  253 |     int woptions = WEXITED;
      |                    ^~~~~~~
      |                    WIFEXITED
qtbase/src/corelib/io/../../3rdparty/forkfd/forkfd.c:253:20: note: each undeclared identifier is reported only once for each function it appears in
qtbase/src/corelib/io/../../3rdparty/forkfd/forkfd.c:255:21: error: ‘WNOWAIT’ undeclared (first use in this function)
  255 |         woptions |= WNOWAIT;
      |                     ^~~~~~~

The error itself is correct since CYGWIN doesn't support WEXITED and WNOWAIT.
Looking on top of the file, you can see this:

if !defined(WEXITED) || !defined(WNOWAIT)
  undef HAVE_WAITID
endif

So, testing HAVE_WAITID is can be good way for filtering this error.
Just before convertForkfdWaitFlagsToWaitFlags(), there is a block of
code, protected with a test checked by the preprocessor:

ifdef HAVE_WAITID
...
endif

so, I just moved that function in this control block for fixing the
issue.

Change-Id: Ia6dce926d1c8181cc0fb8dc8840d8982b37d80ca
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-07 14:11:49 +01:00
Carlo Bramini
4c0dcb0cda Corelib: statvfs64 is unsupported on CYGWIN
On CYGWIN, the build process fails at this point:

In file included from qtbase/include/QtCore/6.9.0/QtCore/private/qcore_unix_p.h:1,
                 from qtbase/src/corelib/io/qstorageinfo_unix.cpp:11:
qtbase/src/corelib/io/qstorageinfo_unix.cpp:59:28: error: ‘::statvfs64’ has not been declared
   59 | #    define QT_STATFS    ::statvfs64
      |                            ^~~~~~~~~

This is correct, CYGWIN doesn't support that, although it provides support for large files.
Looking the code, you can see that also Haiku OS has the same behavior, so I just added an
additional test when defining QT_STATFSBUF and QT_STATFS

Change-Id: Ib250ccffc1a83e235a117b13b602194db617e75a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-07 14:11:49 +01:00
Carlo Bramini
dd9ac87532 Fix broken qplatformdefs.h for cygwin-g++ platform
This patch corrects several bugs into qplatformdefs.h for cygwin-g++:
- _GNU_SOURCE must be the very first macro to be checked on top of
the file.
- features.h must be the one to be included for activating the needed
functions, so I moved unistd.h near all other standard headers.
- nowadays, CYGWIN supports sys/ipc.h and sys/shm.h by long time.

Change-Id: Ib32df1746f1b5579698921641408d278104ce128
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-07 14:11:49 +01:00
Carlo Bramini
1582dd5da1 CMake: fix missing _GNU_SOURCE macro in CYGWIN
Compiling qtbase in CYGWIN shows several errors like this one:

In file included from qtbase/include/QtCore/6.9.0/QtCore/private/qcore_unix_p.h:1,
                 from qtbase/src/corelib/global/qlogging.cpp:61:
qtbase/src/corelib/kernel/qcore_unix_p.h: In function ‘int qt_safe_pipe(int*, int)’:
qtbase/src/corelib/kernel/qcore_unix_p.h:283:14: error: ‘::pipe2’ has not been declared; did you mean ‘pipe’?
  233 |     return ::pipe2(pipefd, flags); // pipe2 is documented not to return EINTR
      |              ^~~~~
      |              pipe

Actually, the error happens because pipe2() is available only when
 _GNU_SOURCE is defined:

https://man7.org/linux/man-pages/man2/pipe.2.html

CYGWIN doesn't define this macro by default, so this is reason because
the error happens. In my opinion, the best way for fixing the trouble
is adding the missing _GNU_SOURCE macro by using CMake.
Using qplatformdefs.h, which is also broken for cygwin-g++ target,
doesn't fix the issue, so the only way to solve the problem is to set
it with CMake or forcing it externally by using CPPFLAGS.

Change-Id: I6917630999b29582556258eee11d9989f439c37c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-07 14:11:49 +01:00
Carlo Bramini
6f891f3ccb Tests: avoid almostPlugin on CYGWIN
On CYGWIN, the build process of almostPlugin fails with this error:

qtbase/tests/auto/corelib/plugin/qpluginloader/almostplugin/CMakeFiles/almostplugin.dir/almostplugin.cpp.o: in function `AlmostPlugin::pluginName() const':
qtbase/tests/auto/corelib/plugin/qpluginloader/almostplugin/almostplugin.cpp:9.text+0x2c): undefined reference to `AlmostPlugin::unresolvedSymbol() const'
collect2: error: ld returned 1 exit status

This is correct, CYGWIN doesn't support that, like MinGW.
Attached patch fixes the error, according to the suggestions here:

Task-number: QTBUG-133778
Change-Id: I9fc261942200f62a5975cd91cb970472e5fca721
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-07 13:11:48 +00:00
Marc Mutz
d1539331dd Revert "QString::replace: fix a performance regression"
This reverts commit 315210de916d060c044c01e53ff249d676122b1b.

The change was not correct. If the newly-inserted reserve() call
actually grows the string, and `after` aliased a part of the old
string, it will now reference deleted data, as the q_points_into_range
check now comes too late.

Change-Id: I2e016b8b90f74126dfc7126800b7b7fde96a091e
Pick-to: 6.9 6.8 6.7
Task-number: QTBUG-127549
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2025-03-07 13:11:48 +00:00
Juha Vuolle
fcada7c5c3 qtwasmserver to serve assets from the provided path parameter
qtwasmserver accepts a positional path argument which tells where to
serve the assets from. The argument wasn't actually used, and this
resulted in always using the cwd.

In addition add a check for the path directory existence. Otherwise
this becomes only visible as a 404 Not Found error.

Amends: 156e5c8b690d01ad3043d2163168c4ea3608a046

Pick-to: 6.9
Fixes: QTBUG-134393
Change-Id: Iacfafe8a2fb2409169b09a17dbc9ffed0ad16fdf
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-03-07 13:02:47 +02:00
Joerg Bornemann
2a499eb8d7 Doc: Clarify building a separate SQL driver
Mention that one needs to build the SQL driver with Ninja after
configuring it with qt-cmake.

Fixes: QTBUG-105036
Change-Id: Ic51310e7a2ea3c71d9de1c2c4677fdc9cbb897e5
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2025-03-07 12:02:47 +01:00
Joerg Bornemann
9f86517cce CMake: Remove superfluous precompile_header feature and config test
Whether precompiled headers are used during the Qt build is controlled
by the CMake variable BUILD_WITH_PCH and the qt_auto_detect_pch
function.

The precompiled_header feature wasn't actually used. Remove it and the
corresponding configure test.

Fixes: QTBUG-134425
Change-Id: I9b2ff9cbcf4888899b6a39d22d260388a9375c5c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-07 12:02:47 +01:00
Joerg Bornemann
9df20860de CMake: Fix -no-prefix build with CMake < 3.26 on macOS
On macOS, Core has plugins that link against CorePrivate. In a
non-prefix build, user projects failed on find_package(Qt6 REQUIRED
COMPONENTS Core), because CorePrivate is required for these plugins in
a non-prefix build, but it's not automatically pulled in.

This is only an issue for CMake < 3.26, because these older CMake
versions lack the BUILD_LOCAL_INTERFACE generator expression.

Fix this by pulling in the private modules for non-prefix builds when
using CMake < 3.26. Also, issue a warning in this situation.

Fixes: QTBUG-134407
Change-Id: I7f182c9518686390e657663b452cad8101d870a2
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-07 12:02:47 +01:00
Joerg Bornemann
ba103a6fee CMake: Fix permissions of qt-internal-(strip|ninja).bat.in on Unices
These files should not have executable permissions.

Pick-to: 6.9
Fixes: QTBUG-125534
Change-Id: I893d4d373ee098864b64200dc6c88b57d05d6209
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-03-07 12:02:46 +01:00
Tim Blechmann
1d83bffb29 QWindows11Style: fix clang-cl warnings
QRect QRect rect and tableView are not used and clang-cl warns about
that.

Pick-to: 6.8 6.9
Change-Id: I35ae933b437952c6748e4b09d139cc06c9ce33cb
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-03-07 19:02:46 +08:00
Thiago Macieira
59a081dc7e QCborStreamWriter: add append(QUtf8StringView)
And test appendTextString() through it, which was apparently not
directly tested until now (only through appending Latin1 and UTF-16
strings).

[ChangeLog][QtCore][QCborStreamWriter] Added a QUtf8StringView overload
of append().

Change-Id: I4d306ab1561a4fd6e9a8fffd65f352bdb78b96b9
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-06 22:59:15 -08:00
Thiago Macieira
c17a934197 QCborStreamWriter: add append(QByteArrayView)
This required demoting the QByteArray overload to Q_WEAK_OVERLOAD to
avoid introducing ambiguities.

[ChangeLog][QtCore][QCborStreamWriter] Added a QByteArrayView overload
of append().

Change-Id: I3004bd691aca990cb67dfffde63b58bb378e3311
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-03-07 03:59:09 -03:00
Thiago Macieira
07a15916cc QThreadStorage: add a warning suggesting use of thread_local
thread_local can still be very broken for non-trivial types, 14 years
since C++11 was ratified, but it works plenty well for trivial types. So
suggest users use that (with a macro to opt-out).

[ChangeLog][QtCore][QThreadStorage] QThreadStorage will print a warning
suggesting the use of thread_local for use with primitive types that are
not pointers. In fact, switching to the C++11 functionality is advisable
for all types, but some runtimes have bugs concerning destruction order.
This warning can be suppressed by #define'ing the macro
Q_NO_THREAD_STORAGE_TRIVIAL_WARNING.

This code is actually very old (looks like it has pre-C++98
compatibility support for MSVC 6.0) and could use a refactor, but it's
not worth my time to do it or review it for such old content. Stop using
QThreadStorage if you can.

Task-number: QTBUG-117850
Change-Id: I906ba7872388fc578c78fffd92231118decfd67e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-07 03:59:05 -03:00
Michael Weghorn
1df6a48a89 a11y macOS: Support titleUIElement property
In the macOS accessibility bridge, bridge the QAccessible::Label
relation to the corresponding titleUIElement NSAccessibility property [1]:

> An element that represents another element’s static text title (id)

In case there are multiple targets for the QAccessible::Label relation,
just report the first one.

With this in place, Accessibility Inspector on macOS now e.g. shows
"Locale (text) [QMacAccessibilityElement]" as the "Title UIElement"
of the corresponding combobox it labels in the calendarwidgets example
as expected and VoiceOver now says e.g. "English/Germany Locale General
Options, menu button" instead of just the current combobox value and
role "English/Germany, menu button", so the context and semantics of
the combobox becomes clearer to the user.

[1] https://developer.apple.com/documentation/appkit/nsaccessibility-swift.struct/attribute/titleuielement

Change-Id: I814658628c481fe71f17853f71dc5690971507b1
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2025-03-07 02:59:37 +00:00
Axel Spoerl
738c180c4f Re-implement QPlatformTheme::requestColorScheme() in QGtk3Theme
QGtk3Theme remained unresponsive to programmatic color scheme changes,
after QPlatformTheme::requestColorScheme() had been introduced.

Add functionality to QGtk3Theme.
Fall back to qt_fusion_palette, when the requested color scheme isn't
supported by the current GTK3 theme (e.g. Adwaita-dark doesn't support
light mode).

Functionality has to be manually tested with the widget gallery
example.

Fixes: QTBUG-134022
Task-number: QTBUG-132929
Pick-to: 6.9 6.8
Change-Id: I1160c7afc1f1fcb6ec93d65ef54cb45a65a63863
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2025-03-07 02:21:20 +00:00
Marc Mutz
db6f8821fc QTextMarkdownWriter: reduce unnecessary relocations
Instead of a static constexpr QL1SV object (which force the compiler
to allocate storage and therefore causes relocations), use a mere
automatic constexpr object (which doesn't). There never was a need to
make this object static, as constexpr is enough to force the compiler
to constant-fold them.

Difference:
  qtextmarkdownwriter.cpp.o:
- 0000000000000000 l     O .data.rel.ro.local     0000000000000010 maybeEscapeFirstChar(QString&)::specialFirstCharacters
  0000000000000000 l    d  .data.rel.ro.local     0000000000000000 .data.rel.ro.local

See
  https://stackoverflow.com/questions/19067010/finding-where-relocations-originate/19338343#19338343
for the script to generate this output.

See https://www.akkadia.org/drepper/dsohowto.pdf Section 1.6 for why
we care.

As a drive-by, port from QL1SV to _L1 UDL.

Amends ca4774131b9b8ee40b4d7f5c1ba296af4700207f.

Pick-to: 6.9 6.8
Task-number: QTBUG-100536
Change-Id: I31e124962e03b8b40df9153b09f627e8e22a8119
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
2025-03-07 01:01:35 +00:00
Marc Mutz
692f1a38a4 QUrl: add a missing std::move()
The deslashified QString can be moved into place here.

Found by Coverity.

Amends 5e936b60fc921e21b8153a83113886a1de333b57.

Pick-to: 6.9 6.8
Coverity-Id: 477475
Change-Id: Ibdaae0a9acae56960e16d5a6fd77fc1e08036af0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2025-03-06 23:01:56 +01:00
Marc Mutz
e3a4cf013c QBrush: enable -Wswitch in strategic places
Since we rely on the brush style to distinguish between the three
different QBrushData subclasses, we should grab all the help we need
to not mess up, so replace default case labels with the expanded list
of brush styles, so that -Wswitch shall always prompt those adding new
styles to add them to the the correct branch of each switch, rather
than having them treated as Basic by default.

Coverity-Id: 11772
Coverity-Id: 218724
Change-Id: Id6280695a4d9cb8af6dedd283aa4cc4be73806fa
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-06 22:01:56 +00:00
Marc Mutz
13965b020e QBrush: symmetrize QBrushData subclasses
Coverity complains that QBrushData, a class with no virtual
destructor, has subclasses, but is in some code paths deleted as a
QBrushData, which, if the object deleted was actually an instance of a
derived class, would be undefined behavior.

This warning has already unearthed a real bug, since fixed in
8082c0dc81b50c44a0cf1984cb2c484b007c64a4, but it became clear that
Coverity does not see through the tying of d->style to a particular
subclass, probably because we're mixing hierarchy levels.

So try to guide Coverity better by inheriting an empty subclass from
QBrushData for those styles that are neither textures nor gradients,
and create and destroy only derived classes now.

This greatly simplifies the analysis, since to check this patch for
correctness, I basically only needed to make the QBrushData ctor and
dtor protected (something we should eventually do, but is not included
in this patch, yet (might be BiC)).

Coverity-Id: 11772
Coverity-Id: 218724
Change-Id: I374a0e45160f6ef16f813d782fecc797966ddf78
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-06 22:01:56 +00:00
Marc Mutz
511ee39570 QFontEngine: reduce unnecessary relocations
Instead of static constexpr QL1SV objects (which force the compiler to
allocate storage for them and therefore cause relocations), use mere
automatic constexpr objects (which don't). There never was a need to
make these objects static, as constexpr is enough to force the
compiler to constant-fold them.

Difference:
  qfontengine.cpp.o:
- 0000000000000040 l     O .data.rel.ro.local     0000000000000010 QFontEngine::findGlyph(QLatin1String) const::gid
- 0000000000000000 l     O .data.rel.ro.local     0000000000000010 QFontEngine::findGlyph(QLatin1String) const::uni
  0000000000000000 l    d  .data.rel.ro.local     0000000000000000 .data.rel.ro.local

See
  https://stackoverflow.com/questions/19067010/finding-where-relocations-originate/19338343#19338343
for the script to generate this output.

See https://www.akkadia.org/drepper/dsohowto.pdf Section 1.6 for why
we care.

Amends 176816f21324bf736389037c62538a25f2522808.

Pick-to: 6.9
Task-number: QTBUG-100536
Change-Id: I3cdf42c9758ec32654b378a2b27b565a6c92c26b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
2025-03-06 21:57:23 +00:00
Marc Mutz
1370ecf293 QGenericUnixTheme: reduce unnecessary relocations
Instead of static constexpr QL1SV objects (which force the compiler to
allocate storage for them and therefore cause relocations), use inline
functions or mere automatic objects (which don't).

We'd normally call the inline functions fooKey() { return "foo"_L1; },
but since one of them "foo"s ends with "Key" already, put them into a
namespace instead, the name of which is taken from the comment that
used to introduce the static constexpr objects in the old code.

For the QL1SVs in the ctor: port them to QStringLiterals, because
their only use is to pass them to a function taking const QString&, so
this saves allocations. There never was a need to make these objects
static, as constexpr would be enough to force the compiler to
constant-fold them.

Unlike my earlier advice about how to create an empty QString most
efficiently, don't keep using ""_L1, use u""_s. This is because
there's no shared empty QString in Qt 6 anymore. It might still make
sense to add a more light-weight way to create an empty QString,
esp. one which is not referencing local data, but QString::_empty, to
extend the lifetime of the payload until QtCore unload time, but that
is outside the scope of the current patch.

Difference:
  qgenericunixthemes.cpp.o:
- 0000000000000000 l     O .data.rel.ro.local     0000000000000010 QGenericUnixThemeDBusListener::QGenericUnixThemeDBusListener()::signal
- 0000000000000040 l     O .data.rel.ro.local     0000000000000010 QGenericUnixThemeDBusListener::QGenericUnixThemeDBusListener()::interface
- 0000000000000080 l     O .data.rel.ro.local     0000000000000010 QGenericUnixThemeDBusListener::QGenericUnixThemeDBusListener()::path
  00000000000000c0 l     O .data.rel.ro.local     0000000000000010 QGenericUnixThemeDBusListener::QGenericUnixThemeDBusListener()::service
  0000000000000000 l    d  .data.rel.ro.local._ZTV24QGenericUnixThemePrivate      0000000000000000 .data.rel.ro.local._ZTV24QGenericUnixThemePrivate
  0000000000000000 l    d  .data.rel.ro.local._ZTV16QKdeThemePrivate      0000000000000000 .data.rel.ro.local._ZTV16QKdeThemePrivate
  0000000000000000 l    d  .data.rel.ro.local._ZTV18QGnomeThemePrivate    0000000000000000 .data.rel.ro.local._ZTV18QGnomeThemePrivate
  0000000000000000 l    d  .data.rel.ro.local._ZN13QMetaSequence12MetaSequenceI5QListIN2Qt3KeyEEE5valueE  0000000000000000 .data.rel.ro.local._ZN13QMetaSequence12MetaSequenceI5QListIN2Qt3KeyEEE5valueE
  0000000000000000 l    d  .data.rel.ro.local     0000000000000000 .data.rel.ro.local
- 0000000000000000 l    d  .data.rel.ro.local._ZN29QGenericUnixThemeDBusListener6s_rootE  0000000000000000 .data.rel.ro.local._ZN29QGenericUnixThemeDBusListener6s_rootE
- 0000000000000000 l    d  .data.rel.ro.local._ZN29QGenericUnixThemeDBusListener9s_signalsE       0000000000000000 .data.rel.ro.local._ZN29QGenericUnixThemeDBusListener9s_signalsE
- 0000000000000000 l    d  .data.rel.ro.local._ZN29QGenericUnixThemeDBusListener9s_settingE       0000000000000000 .data.rel.ro.local._ZN29QGenericUnixThemeDBusListener9s_settingE
- 0000000000000000 l    d  .data.rel.ro.local._ZN29QGenericUnixThemeDBusListener10s_providerE     0000000000000000 .data.rel.ro.local._ZN29QGenericUnixThemeDBusListener10s_providerE
- 0000000000000000 l    d  .data.rel.ro.local._ZN29QGenericUnixThemeDBusListener9s_dbusKeyE       0000000000000000 .data.rel.ro.local._ZN29QGenericUnixThemeDBusListener9s_dbusKeyE
- 0000000000000000 l    d  .data.rel.ro.local._ZN29QGenericUnixThemeDBusListener14s_dbusLocationE 0000000000000000 .data.rel.ro.local._ZN29QGenericUnixThemeDBusListener14s_dbusLocationE
  0000000000000000 l    d  .data.rel.ro.local._ZN9QtPrivate25QMetaTypeInterfaceWrapperIvE8metaTypeE       0000000000000000 .data.rel.ro.local._ZN9QtPrivate25QMetaTypeInterfaceWrapperIvE8metaTypeE
  0000000000000000 u     O .data.rel.ro.local._ZN13QMetaSequence12MetaSequenceI5QListIN2Qt3KeyEEE5valueE  00000000000000d8 QMetaSequence::MetaSequence<QList<Qt::Key> >::value
  0000000000000000  w    O .data.rel.ro.local._ZTV24QGenericUnixThemePrivate      0000000000000020 .hidden vtable for QGenericUnixThemePrivate
  0000000000000000  w    O .data.rel.ro.local._ZTV18QGnomeThemePrivate    0000000000000020 .hidden vtable for QGnomeThemePrivate
  0000000000000000  w    O .data.rel.ro.local._ZTV16QKdeThemePrivate      0000000000000020 .hidden vtable for QKdeThemePrivate
- 0000000000000000 u     O .data.rel.ro.local._ZN29QGenericUnixThemeDBusListener6s_rootE  0000000000000010 .hidden QGenericUnixThemeDBusListener::s_root
- 0000000000000000 u     O .data.rel.ro.local._ZN29QGenericUnixThemeDBusListener9s_signalsE       0000000000000010 .hidden QGenericUnixThemeDBusListener::s_signals
- 0000000000000000 u     O .data.rel.ro.local._ZN29QGenericUnixThemeDBusListener14s_dbusLocationE 0000000000000010 .hidden QGenericUnixThemeDBusListener::s_dbusLocation
- 0000000000000000 u     O .data.rel.ro.local._ZN29QGenericUnixThemeDBusListener9s_dbusKeyE       0000000000000010 .hidden QGenericUnixThemeDBusListener::s_dbusKey
- 0000000000000000 u     O .data.rel.ro.local._ZN29QGenericUnixThemeDBusListener10s_providerE     0000000000000010 .hidden QGenericUnixThemeDBusListener::s_provider
- 0000000000000000 u     O .data.rel.ro.local._ZN29QGenericUnixThemeDBusListener9s_settingE       0000000000000010 .hidden QGenericUnixThemeDBusListener::s_setting
- 0000000000000000 u     O .data.rel.ro.local._ZN9QtPrivate25QMetaTypeInterfaceWrapperIvE8metaTypeE       0000000000000070 .hidden QtPrivate::QMetaTypeInterfaceWrapper<void>::metaType
  RELOCATION RECORDS FOR [.data.rel.ro.local._ZTV24QGenericUnixThemePrivate]:
  RELOCATION RECORDS FOR [.data.rel.ro.local._ZTV16QKdeThemePrivate]:
  RELOCATION RECORDS FOR [.data.rel.ro.local._ZTV18QGnomeThemePrivate]:
  RELOCATION RECORDS FOR [.data.rel.ro.local._ZN13QMetaSequence12MetaSequenceI5QListIN2Qt3KeyEEE5valueE]:
- RELOCATION RECORDS FOR [.data.rel.ro.local._ZN29QGenericUnixThemeDBusListener6s_rootE]:
- RELOCATION RECORDS FOR [.data.rel.ro.local._ZN29QGenericUnixThemeDBusListener9s_signalsE]:
- RELOCATION RECORDS FOR [.data.rel.ro.local._ZN29QGenericUnixThemeDBusListener9s_settingE]:
- RELOCATION RECORDS FOR [.data.rel.ro.local._ZN29QGenericUnixThemeDBusListener10s_providerE]:
- RELOCATION RECORDS FOR [.data.rel.ro.local._ZN29QGenericUnixThemeDBusListener9s_dbusKeyE]:
- RELOCATION RECORDS FOR [.data.rel.ro.local._ZN29QGenericUnixThemeDBusListener14s_dbusLocationE]:
  RELOCATION RECORDS FOR [.data.rel.ro.local._ZN9QtPrivate25QMetaTypeInterfaceWrapperIvE8metaTypeE]:

See
  https://stackoverflow.com/questions/19067010/finding-where-relocations-originate/19338343#19338343
for the script to generate this output.

See https://www.akkadia.org/drepper/dsohowto.pdf Section 1.6 for why
we care.

Amends 0328e4297e339de8a2acd84979c667936f6fadf8.

Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-100536
Change-Id: I1fd65e3ed5bceeb2a49141834dbd12f4bf42cc8c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-06 22:57:23 +01:00
Marc Mutz
dfaa43331a QPen: QDebug-stream Pen{,Join}Style etc as enums
Coverity complained that PEN_STYLES[p.style()] may be an out-of-bounds
access, and it is, since setPen() doesn't sanitze its argument and we
have Qt::PenStyle::MPenStyle as an extra (hidden) enumerator that
Coverity doesn't know we never use.

Instead of fixing the issue with the array lookup, realize that all
three enums are Q_ENUM_NS in namespace Qt and use the "magic" QDebug
stream operator for Q_ENUMs to do the numeric -> string conversion,
making invalid enum values SEP.

Not picking to older branches, since it's changing the output.

[ChangeLog][QtGui][QPen] The debug stream operator now prints the
names of capStyle() and joinStyle() (was: numerical values).

Coverity-Id: 390701
Change-Id: Icc593fac3ab02c56a4b39b2a7c8a5d423d626ce3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
2025-03-06 22:57:23 +01:00
Marc Mutz
7a32a2238f qurlrecode.cpp: fix Coverity ARRAY_VS_SINGLETON issue
Coverity has this checker where it complains if you use a T as a
T[1]. The C++ standard says that this is fine¹, but qurlrecode.cpp,
specifically, is security-critical, so we shouldn't leave Coverity
issues unfixed in there.

So replace ucs4 with a buffer[1] array and make both dst and ucs4
point to buffer's first (and only) element.

Amends 2b82923c8fba5dcff707e344acdf9db8c444a55e.

¹ https://eel.is/c++draft/basic.compound#3.sentence-11

Pick-to: 6.9 6.8 6.5
Coverity-Id: 378435
Change-Id: I8ab2f70b542088e90dc43e616a0202e8c756f204
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-06 21:57:23 +00:00
Marc Mutz
4eb9e0d3ee ucstricmp8: fix Coverity ARRAY_VS_SINGLETON issue
Coverity has this checker where it complains if you use a T as a
T[1]. The C++ standard says this is fine¹, but qstring.cpp,
specifically, is security-critical, so we shouldn't leave Coverity
issues unfixed in there.

So replace uc1 with a decoded[1] array and make both output and uc1
point to decoded's first (and only) element.

Amends 45838673df6e64a6fd42570c4e8874c5181f7717.

¹ https://eel.is/c++draft/basic.compound#3.sentence-11

Pick-to: 6.9 6.8 6.5
Coverity-Id: 378348
Change-Id: Ib149386defd8b263df522a4f12b1af1b3fc1a20c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-06 21:57:22 +00:00
Marc Mutz
a817ba8e9c QZip: fix Coverity warning about reading uninit'ed fields from z_stream
Coverity complains that inflateInit2() will read stream.opaque, which
wasn't initialized by us. At least in the copy of zlib that is
contained in Qt, this is false.

But xxflate() in qbytearray.cpp value-initializes its z_stream (and
therefore doesn't manually need to set .zalloc and .zfree), so do that
here, too.

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5
Coverity-Id: 310213
Change-Id: I487072a0d2375a932f3ffb9a1f252fec9e2f2d0d
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-06 22:57:22 +01:00
Christian Ehrlicher
f142bd121c QIcon::pixmap() make sure to always return a correctly sized pixmap
Some icon engines might not be able to return a properly sized pixmap.
Therefore we must make sure within QIcon::pixmap() to return a pixmap
with the requested size. This is done by simply adjusting the device
pixel ratio instead scaling to avoid the loosy scaling until the icon is
drawn later on.
The dpr adjustment was already done for dpr == 1.0 so the function
returned different results for different device pixel ratios ...

Pick-to: 6.9 6.8
Fixes: QTBUG-133412
Change-Id: I66f2ac76ebf240a625649171b4553a3b95d7c3a1
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-06 22:39:57 +01:00
Volker Hilsheimer
129b914051 JNI: use conversion function from Traits in QJniArray
Remove the special handling for various object-types, use the Traits
specialization instead when the type we want is an object type.

Change-Id: Ia7f3c3a11b5687d2fb8a6c3ab0cea15963dacea5
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-03-06 22:39:57 +01:00
Volker Hilsheimer
5342046ff8 JNI: refactor conversion logic into Traits struct
This disentangles and simplifies the code a lot, making it each
type's own responsibility to implement the conversion to and
from JNI. In order to be able to specialize the Traits for any
type with a certain predicate being true (e.g. all arrays, or
containers usable via QJniArray) we have to introduce a second,
defaulted template parameter through which we can SFINAE-in
relevant specializations.

LocalFrame's convertTo/FromJni now become thin wrappers around
the implementation in the Traits specialization, just taking
care of some special cases for local reference frame management.

Change-Id: Ic0e8af89f9e3d9a606b67d5238c1c793114ac38f
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-03-06 22:39:57 +01:00
Jøger Hansegård
6d1384034d Add missing comparison operators for Microsoft::WRL::ComPtr on MINGW
MINGW's implementation of Microsoft::WRL::ComPtr lacks comparison
operators, and calling operator==() on them will implicitly convert them
to bool before comparing the resulting bool values. Two non-zero ComPtr
instances will therefore always compare equal, even if they point to
different interfaces.

This patch adds ComPtr comparison operators if they are missing, and
replaces existing includes to wrl.h or wrl/client.h with
QtCore/private/qcomptr_p.h

Pick-to: 6.9 6.8
Change-Id: I8123d9d874ae53ebfd6d381b69097e75527848b6
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-03-06 22:22:53 +01:00
David Faure
d1462ec5a3 tst_qthread: use QSemaphore to fix a race and a harmless TSAN warning
The current code with two QWaitConditions, a mutex and a bool lead
to a TSAN warning about lock order inversion: the first for loop locks
mutexes M0, M1, M2 etc. and then the second for loop calls QWaitCondition::wait(M0)
which unlocks+relocks M0, while M1 is locked.

It was also racy, in my opinion: with QWaitCondition there's the risk of
calling wakeOne before the other thread calls wait, and then the
notification is missed.

Ported to QSemaphore which doesn't have either problem.

Change-Id: I41574e944a2631cf42a81d3923abb658c862c25d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-06 22:22:52 +01:00
Cristian Le
10affadd12 Use _qt_internal_dealias_target
Pick-to: 6.9 6.8
Change-Id: Iffc1148ed7655c724ea0609be01978ab7d5e7f8f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-06 22:09:06 +01:00
Cristian Le
86c4a179e5 Add helper function _qt_internal_get_real_target
Also a shortcut `_qt_internal_dealias_target`

Pick-to: 6.9 6.8
Change-Id: Ic772896f7bf2f3fb05dd4799b1a8aabbc4379930
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-06 22:09:06 +01:00
Frédéric Lefebvre
4994d1aff9 Unblacklist tst_QWidget::raise on Opensuse
Unblacklist tst_QWidget::raise() on Opensuse as it is no longer flaky.

Change-Id: I3a6157566bcb8d1452ac777bb54479d3e5195719
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-06 21:09:06 +00:00
Alexandru Croitor
ce0004dff7 CMake: Add a special skip genex marker when walking libs
Useful to annotate certain linking expressions that need to be skipped
for inclusion in prl file generation. E.g. $<TARGET_OBJECTS>
expressions that represent propagated object libraries, which are
handled by the rcc_objects walk lib code path, and thus need to end up
in prl RCC_OBJECTS section, instead of the
QMAKE_PRL_LIBS_FOR_CMAKE one.

Pick-to: 6.8 6.9
Change-Id: Ib08b00200b6b06d32eab15ecb15c0820eec2a908
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-03-06 21:28:52 +01:00
Juha Vuolle
4755f52c08 Allow unhandled custom uri-scheme opens to create QFileInfoEvent
On macOS custom uri-scheme opens may generate a QFileOpenEvent that
the applications can handle. However when adding support also for
QDesktopServices::setUrlHandler(), this delivery mechanism stopped
from working because the event was unconditionally consumed /
delivered to only the url handler.

Instead change the logic such that if the url handler does not
handle it, allow a QFileInfoEvent to be created.

Amends: 664c7ffb212eb898ed03f7b19c883400fa027b6b

Fixes: QTBUG-134316
Pick-to: 6.9 6.9.0 6.8 6.8.3
Change-Id: Ib1ed371ef531586bf549cf473b2a54748584d91d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-06 22:28:52 +02:00
Matthias Rauter
feefea87b7 Correct the diagrams in string overview
Amends 80b6f2e63dc537f419186585a528ff749f9ff739

Pick-to: 6.8 6.9 6.9.0
Task-number: QTBUG-133882
Change-Id: If53f8feb73255f8ba035290944b10af2cdf6baf9
Reviewed-by: Mate Barany <mate.barany@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-03-06 20:02:26 +01:00
Rami Potinkara
997a1fae98 Android: bump Android target API level to 35
This patch
-updated target API level to 35 into build tools
-updated target API level to 35 in build.gradle files

Task-number: QTBUG-129461
Task-number: QTBUG-130284
Pick-to: 6.9 6.9.0
Change-Id: Iebdc99e6f607352652c3f0022f17de60eae97d58
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-03-06 18:43:38 +00:00
Assam Boudjelthia
1f3c5f8f90 Android: account for edge-to-edge in tst_android
When running on Android 15 with target sdk set to 35 (Android 15),
the new edge-to-edge behavior is enforced, so the test needs to
account for that and take the full screen size instead of deducting
the insects.

Pick-to: 6.9 6.9.0 6.8
Task-number: QTBUG-132311
Change-Id: I178265b02878206ba95c8f83507963ce0bd0d732
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-03-06 18:43:37 +00:00
Mitch Curtis
6b361119ef Improve QList::move docs
- State that both arguments must be within bounds.
- Add example.

Pick-to: 6.5 6.8 6.9
Change-Id: Ieba9c3469a2c8cf8c20d867abff5865d96c3ee6e
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2025-03-06 16:36:29 +08:00
Fabian Kosmale
c0f9e99611 moc: Add an error overload taking a Symbol and a message
This allows deferring warnigs about a certain error until later, by
storing the symbol (while still allowing to print a custom message).

Change-Id: Id434eec9b344b1f8b18c504dfda8fed90167cf12
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-03-05 22:41:05 +01:00
Fabian Kosmale
fd88f44c15 Warn about QML registration macro without include
In some setups, e.g. when using precompiled headers, the compiler will
see all definitions necessary to compile a class containing a QML
registration macro. However, moc won't be able to resolve the macro to
its expanded text, and thus miss the information.

This leads to a runtime failure when the QML engine cannot find the
type, because it has not been registered (as qmltyperegistrar relies on
the information collected by moc).

To avoid this, teach moc about the registration macros, and warn
when encountering them. We do this by comparing identifiers inside
classes against the names of the QML registration macros.
We do not error out, as a user might use the names of the macros as
normal identifiers, especially in a non-QML project (as unlikely as this
might be).

Warning out when finding a registration macro might sound
counter-intuitive, but works because moc should not actually see the
macros at this stage: When the header is included, macro expansion will
replace the macro with its expansion; only when the header is missing
will we ever see the macro as an identifier.

Task-number: QTBUG-134148
Pick-to: 6.8 6.9
Change-Id: I2f213444993a9d782a027c2dc25ffcbe0824ddca
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2025-03-05 22:41:05 +01:00
Lucie Gérard
38e39902c6 Remove unnecessary comment
Pick-to: 6.9 6.8
Change-Id: I8407ddb117941bc9e28b18998ff1e824ded2b1d9
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-03-05 20:47:11 +01:00
Allan Sandfeld Jensen
06b50e5d6c Add copyright holder to the SPDX line
Fixes: QTBUG-134392
Pick-to: 6.9
Change-Id: I50f36af1c4ff91e3ab51db0abaf5b2b088fd8742
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-05 20:47:10 +01:00
Ivan Solovev
ff6bf61b17 QFuture: avoid warnings about unreachable code with /W4 in MSVC
... when instantiating the MetaTypeQFutureHelper for QFuture<void>.

Simply enabling /W4 for tst_qfuture also generates this warning, but
also much more. So I'm not providing any unit-test here.

Amends 90d9a86c2e762c9426d0facbd54ed5dbff574ecd.

Fixes: QTBUG-133406
Pick-to: 6.9 6.9.0 6.8 6.5
Change-Id: I22a53b872818763b80f333f597ddd19a1c1e30ac
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-05 20:47:10 +01:00
Eskil Abrahamsen Blomfeldt
550db195af Upgrade Harfbuzz to 10.4.0
[ChangeLog][Third-Party Code] Upgraded Harfbuzz to version
10.4.0.

Fixes: QTBUG-134282
Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Ib36df2ae6b0fa4cf667b25d460473d45e8b34350
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit ecc8ca605c30ce7268a3d05c2fe6f6f6e337de5d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-03-05 19:47:10 +00:00
Giuseppe D'Angelo
077412a3cf CMake: map more -sanitize options in the doc
These were supported by Qt 5's configure.

Pick-to: 6.9 6.8
Change-Id: I3d902bb9e211f1dfecbf0835203e7b9e60fb41f6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-05 20:47:10 +01:00
Giuseppe D'Angelo
84d6309cf1 QThread: disable pthread_clockjoin_np when building under TSAN
TSAN does not support intercepting pthread_clockjoin_np (only join,
tryjoin and timedjoin), and will claim that an application leaks threads.
Disable the clockjoin codepath when building under TSAN.

Unfortunately I can't seem to find a version check for the sanitizers to
apply here and know if and when TSAN will get this support.

Pick-to: 6.9
Change-Id: If12419e5d600e519bf4315d27f74d74a87dcf792
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-05 19:16:42 +01:00
Volker Hilsheimer
03efe9a21b Doc: fix documentation warning for QByteArray::fromCFData
\brief tags are not used for member function documentation.
Explicitly set the prototype for qdoc instead, it doesn't seem to
know what to do with the definition in an ObjectiveC file and
produces link warnings.

Pick-to: 6.9 6.9.0
Change-Id: I89252e7b84586e987ed6d950d90142e916d8f1df
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-05 18:33:02 +01:00
Topi Reinio
b6a01d7d22 Doc: Fix incorrect \fn signatures
Several \fn signatures were either incorrect or missing qualifiers
required to make QDoc match the documentation with the declarations.

These were not caught in the CI when testing documentation builds due
to a bug in QDoc.

Pick-to: 6.9
Task-number: QTBUG-134250
Change-Id: I7a4af11d9bc3687597b348cc2d4ee15212e0281f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-05 15:43:42 +00:00
Matthias Rauter
351b7a31aa Add namespaces to qdbusxml2cpp
[ChangeLog][QtDBus][qdbusxml2cpp] The Qt D-Bus XML compiler
(qdbusxml2cpp) now supports the command-line argument -namespace
<namespace>, which encapsulates all generated classes within the
specified namespace to prevent class name conflicts.

Fixes: QTBUG-133611
Change-Id: Ic3473dfc33dcf22f5be727236fe546b70b2b015b
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-03-05 10:06:19 +01:00
Christian Ehrlicher
611031e4f0 QDrawUtil: Cleanup qDrawPlainRoundedRect/qDrawPlainRect
Cleanup the drawing code to avoid useless drawings by only calling
drawRect once with the correct parameters. This also removes rendering
artifacts due to e.g. rounding errors with a dpr != 1.

Fixes: QTBUG-132187
Pick-to: 6.9 6.8
Change-Id: Ib5eff89c8bdcbd0c86954e78dadaad83346c92ff
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-05 02:35:56 +01:00
Christian Ehrlicher
98653cca45 QStyleHelper: fix compilation with disabled features
When certain features are disabled, qguiapplication.h does not get
included which results in a compiler error. Therefore add it directly.

Pick-to: 6.9 6.9.0 6.8
Fixes: QTBUG-134235
Change-Id: I7836fc52c5037ca15c7ce48617c9f814d71963aa
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-03-05 01:35:56 +00:00
Thiago Macieira
9c4c5dc9f9 a11y uia: fix build: MinGW has those macros
Don't do proxy checks for the thing you want to test. Whenever possible,
test the thing you want to test.

We can't check for the definition of certain structs, though. Those have
to remain a proxy check.

Pick-to: 6.9 6.9.0 6.8
Change-Id: I5003e785706cd66923e4fffd6b11254233d09dc5
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-04 21:59:19 +00:00
Morten Sørvig
665acc02cf wasm: disable text drag for text edits
Disable text drag if asyncify is not enabled.

Fixes: QTBUG-131256
Pick-to: 6.8 6.9
Change-Id: I6589f11dda42c2f41db610e7cfece8a3db6573db
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-03-04 17:50:11 +00:00
Marc Mutz
43874ec9f8 QGridLayout: make QHVContainer's preconditions machine-readable
Coverity complains that other() computes an address that's out of
m_data's bounds, and that's correct, if the argument isn't either
Qt::Horizontal or Qt::Vertical (they're flags, so Coverity assumes
that 0 and Vertical|Horizonal are valid arguments, too), but as the
doc block above the class suggests, this is not supported. So add
Q_ASSERTs to map() and mapOther(), and drop the noexcept of functions
that call these now.

Not picking to older branches in case Coverity is right and I am
wrong.

Amends 46a1cf915096ab056ad3bfd1d42fd504c04763cd.

Coverity-Id: 427374
Change-Id: I47a2821e99dd99666a170f2bb2859c1d6351b50e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-04 17:19:46 +01:00
Marc Mutz
bcd29a9eab QWidget: init data in ctor, not Private::init()
This should fix Coverity's hallucination that QWidget::data is used
uninitialized, or, after 58b9250aea0b1b41c8cbd1033149371a93a5b2c1,
dereferenced while it's still nullptr.

Coverity-Id: 475552
Coverity-Id: 475551
Coverity-Id: 475550
Coverity-Id: 475549
Coverity-Id: 396828
Pick-to: 6.9 6.8 6.5
Change-Id: I49705b8bc44082fc68a59c2c98c4e37a6d841b19
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-04 16:30:45 +01:00
Leena Miettinen
c770015876 Doc: Use Qt Design System colors also in help CSS
- Replace colors in offline-dark.css
- Do not use the note and attention icons in offline templates

Task-number: QTBUG-133761
Pick-to: 6.9 6.9.0 6.8
Change-Id: I55e81d6c3887764542e23c8f85f4d46e273b3885
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2025-03-04 16:00:50 +01:00
Kai Uwe Broulik
9194366923 QCssParser: Add missing palette roles
Qt CSS allows to read palette colors by using "palette(role)" but
the supported roles haven't been updated since at least Qt 5.12,
therefore placeholder-text and accent are not recognized.

An "accent-color" property has been added to *set* the accent
color on an object when it was introduced but it wasn't possible
to *read* the accent color, even though it was documented to work.

For sake of completeness, add tooltip-base and tooltip-text as well.

Also amend the comment in QPalette to mention QCss and add a
static_assert so this doesn't happen again.

Pick-to: 6.9 6.9.0 6.8
Change-Id: I59ed09dc91fa18ca0356857c8ddb43946b309035
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-04 14:27:23 +00:00
David Faure
93694e99c2 QSortFilterProxyModel: don't call index(row, 0) if there are no columns
This is invalid, e.g. it asserts in
QConcatenateTablesProxyModel::index()

Fixes: QTBUG-134210
Pick-to: 6.9
Change-Id: I21acad9497d423b0366991296e8dd498d51395ea
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-04 10:01:27 +01:00
Christian Ehrlicher
254fc6a978 QCssParser: don't allow negative values for cuts in border-image
The spec does not allow this and qDrawBorderPixmap can not handle it.

Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-107904
Change-Id: I5873dec2312865fb96ccccd3cc2292c6b9e1d4f0
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-04 06:10:31 +01:00
Christian Ehrlicher
49f462b7f8 QWidget: Don't offset the clip region for windows using effects
When a top-level widget has a graphic effect applied,
QWidgetPrivate::clipToEffectiveMask() must not use the parent widget for
the mask calculation as this prevents the loop below from bailing out in
the first loop (w->isWindow()) and might mess up the clip region when
there is a widget with a mask in the parent chain.

Pick-to: 6.9 6.8
Fixes: QTBUG-131893
Change-Id: I5d5777e730bee309db21ad5eb65387d19321ee6c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-04 05:10:29 +00:00
Christian Ehrlicher
3bff7e575e QCommonStyle: use arrows from Qt Icon Library
Replace all standard arrow icons with the icons from Figma/Qt Icon
Library.

Task-number: QTBUG-128665
Change-Id: I8b0c3426eaba7f55436f942428eef73fac827483
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-04 06:10:28 +01:00
Christian Ehrlicher
5436c4a363 QStyleSheetStyle: fix CT_MenuItem with custom font
When a menu has a custom font size set, the size was adjusted to reflect
this *after* the additional widths for icon or checkmark was added.
When the used font is larger, the additional width added for the icon or
checkmark will not be honored then.
Therefore the size with the new font has to be added before adding the
size for the icon/checkmark.

Pick-to: 6.9 6.8
Fixes: QTBUG-115356
Change-Id: I33e83022bea9e3a531ac8e1651d8655076d88b4b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-04 06:10:27 +01:00
Assam Boudjelthia
75367d1cfe Android: fix uncompressed libs loading from split APKs
When split APKs, when an AAB is used for example, the native libraries
are kept in a separate APK and not under the main app APK, thus, we
need to use that instead to get the path of the native libs otherwise
the app would crash failing to load Qt libraries.

Amends 0db5b424cdaede8724886e8a1eda1380382d9aaf.

Pick-to: 6.9 6.9.0
Fixes: QTBUG-134101
Change-Id: I930ba005aaefc15e4500b7290167892dc2428066
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-03-03 23:49:06 +00:00
Milian Wolff
c67659149f Optimize QUtcTimeZonePrivate common case for UTC id/name
When the name/id is "UTC" then we can reuse the interned
string literals, which allows us to get rid of extra memory
allocations (and frees later on) for these strings.

This patch brings another hefty relative improvement to my benchmark.
Compare the following results for tst_QTimeZone::utc benchmark as
built on my machine with:

    Config: Using QtTest library 6.10.0, Qt 6.10.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 14.2.1 20250207), arch unknown

Before:

    102.004937 nsecs per iteration (total: 102,004,835, iterations: 999999)
    452.836869 CPU cycles per iteration, 4,44 GHz (total: 452,836,417, iterations: 999999)
    1,182.801068 instructions per iteration, 2,612 instr/cycle (total: 1,182,799,886, iterations: 999999)
    267.143901 branch instructions per iteration, 2,62 G/sec (total: 267,143,634, iterations: 999999)

After:

    36.708812 nsecs per iteration (total: 36,708,776, iterations: 999999)
    169.024518 CPU cycles per iteration, 4,6 GHz (total: 169,024,349, iterations: 999999)
    601.286607 instructions per iteration, 3,557 instr/cycle (total: 601,286,006, iterations: 999999)
    139.051610 branch instructions per iteration, 3,79 G/sec (total: 139,051,471, iterations: 999999)

Relative Delta:

            before   after    improvement
    nsecs   102.0    36.7     2.78x
    cycles  452.8    169.0    2.68x
    instr.  1182.8   601.3    1.97x
    branch  276.1    139.1    1.98x

Pick-to: 6.9 6.8
Change-Id: I4aae3ac59edc173f96751d7e05335ad6b63f7275
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-03 23:08:02 +01:00
Milian Wolff
7651936939 Optimize QTimeZone::utc()
Instead of using the QTimeZone ctor taking a string representing
UTC which then first needs to be parsed, use the offset-from-UTC
ctor with an offset of 0.

This approach is much faster, compare the following results for
the tst_QTimeZone::utc benchmark as built on my machine with:

    Config: Using QtTest library 6.10.0, Qt 6.10.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 14.2.1 20250207), arch unknown

Before:

    358.686871 nsecs per iteration (total: 358,686,513, iterations: 999999)
    896.524312 CPU cycles per iteration, 2,5 GHz (total: 896,523,416, iterations: 999999)
    2,227.000427 instructions per iteration, 2,484 instr/cycle (total: 2,226,998,200, iterations: 999999)
    560.000375 branch instructions per iteration, 1,56 G/sec (total: 559,999,815, iterations: 999999)

After:

    102.004937 nsecs per iteration (total: 102,004,835, iterations: 999999)
    452.836869 CPU cycles per iteration, 4,44 GHz (total: 452,836,417, iterations: 999999)
    1,182.801068 instructions per iteration, 2,612 instr/cycle (total: 1,182,799,886, iterations: 999999)
    267.143901 branch instructions per iteration, 2,62 G/sec (total: 267,143,634, iterations: 999999)

Relative Delta:

            before   after    improvement
    nsecs   358.7    102.0    3.52x
    cycles  896.5    452.8    1.98x
    instr.  2227.0   1182.8   1.88x
    branch  560.0    267.1    2.10x

This is quite a significant change for such a trivial patch.

Pick-to: 6.9 6.8
Change-Id: I5872fe8f1158ff9f6bf306ca8b069559cb59beec
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-03 23:08:02 +01:00
Milian Wolff
7a79ce13a9 Add explicit test coverage for QTimezone::utc
Basically this should work exactly the same as constructing the
QUtcTimeZonePrivate directly. Follow-up performance optimizations
should not change any of this behavior.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I2a3e78965f3a553b8b70cb12f7772b9fdfbf7bf7
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-03-03 22:08:02 +00:00
Marc Mutz
6626874286 QWidget: DRY the ctors, use ctor delegation
Don't repeat the body in the two QWidgets ctors, call one from the
other instead.

This will help fighting Coverity's hallucination that QWidget::data is
used uninitialized, or, after 58b9250aea0b1b41c8cbd1033149371a93a5b2c1,
dereferenced while it's still nullptr.

Coverity-Id: 475552
Coverity-Id: 475551
Coverity-Id: 475550
Coverity-Id: 475549
Coverity-Id: 396828
Pick-to: 6.9 6.8 6.5
Change-Id: I1f9a8b93871143b420b9c8f247e49d57510a2379
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-03 23:08:02 +01:00
Thiago Macieira
5e936b60fc QUrl: decode square brackets in fromLocalFile()
QUrl has an intentional deviation from RFC 3986 when it comes to those
characters, matching the behavior of major browsers: we distinguish the
forms '[' and ']' from their encoded forms. However, for local files,
they are definitely identical, because there's no such thing as a
percent-encoded file names.

[ChangeLog][QtCore][QUrl] QUrl::fromLocalFile() will now decode the
square bracket characters '[' and ']' to their percent-encoded forms.
This will be visible in calls to toString(), toEncoded(), or the encoded
form of path(). QUrl's comparison operator will consider the old
(created from an encoded URL string) and new forms to be different.

Pick-to: 6.8 6.9
Fixes: QTBUG-134073
Change-Id: I9eae083007103e34f73cfffd59a618069eba0e19
Reviewed-by: David Faure <david.faure@kdab.com>
2025-03-03 17:03:49 -03:00
Thiago Macieira
31753e722c tst_QUrl: improve toNSURL()/toCFURL() tests
This extends the test with a few more rows, and with delimiters that the
Apple APIs seem to encode differently. Rather, it's QUrl that deviates
slightly from the standard: we keep the delimiters unchanged,
regardless, like browsers do.

Task-number: QTBUG-134073
Pick-to: 6.9 6.8 6.5
Change-Id: I20a7b66a9959b17597cffffdf3652b9167d00d07
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-03 14:24:43 -03:00
Morten Sørvig
89d5b96b45 wasm: improve asyncify support
Rewrite the event dispatcher to use QWasmSuspendResumeControl
for asyncify suspend/resume.

This includes using the following helper classes which provides
additional functionality on top of QWasmSuspendResumeControl.

  - QWasmTimer: manages native timers on the main thread
  - QWasmEventHandler and qstdweb::EventCallback: input events
  - QWasmAnimationFrameHandler: animation frame events

Initialization differs slightly, depending on if QtGui and
the QPA machinery is in use, or of the app is a QtCore only
application. In the former case, QWasmSuspendResumeControl is
created early by QWasmIntegration in order to support registering
event handlers at startup, before the event dispatcher has
been created.

processEvents() now actually processes native events. This is
done by running a suspend-resume loop until the native event
queue has been exhausted. If WaitForMoreEvents is specified then
processEvents() will, in addition, also suspend and wait for
additional native events.

Timers on secondary threads are now managed by modifying the
wait condition timeout, instead of proxying timers to the main
thread. In effect secondary threads will now sleep until the
next timer should fire, and then wake up and process that timer.

Change-Id: I20e8afb6b67c64a7c52dbd89e9c50ffadba39594
Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
2025-03-03 18:24:43 +01:00
Morten Sørvig
9df167a013 wasm: introduce qwasmglobal_p.h
Global helpers/utils for Q_OS_WASM.

Move the thread proxying functions to qwasmglobal_p.h,
and update calling code.

qtstweb_p.h now contains C++ wrappers for native web
API only. The proxying functions will be removed from
qeventdispatcher_wasm in a later commit.

Change-Id: I08a56c211b08929750970895b63ca48d4a07a0a1
Reviewed-by: Lorn Potter <lorn.potter@qt.io>
2025-03-03 18:24:43 +01:00
Morten Sørvig
b80deb2628 wasm: add test for QWAsmSuspendResumeControl
Test via QWasmTimer and native timers.

Change-Id: Ie1ad8517de83e4ad50a7cdc7c391c34226261aef
Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
2025-03-03 18:24:43 +01:00
Morten Sørvig
de2a29a1fe wasm: add native event and timer helpers
These build on QWasmSuspendResumeControl and provide
support for registering C++ event handlers and native
timer callbacks.

Change-Id: I8370f91e42b3992ff7864e847efb9c225010e718
Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
2025-03-03 18:24:43 +01:00
Morten Sørvig
3c72f99770 wasm: introduce QWasmSuspendResumeControl
QWasmSuspendResumeControl manages transfer of control from
JS to the wasm instance, when the wasm instance is asyncify
suspended.

Supported use cases include registerEventHandler()-type
event handlers, and also JS APIs which take a callback
functions, such as timers and requrestAnimationFrame.

The specific use cases are handled by adapters (not included
in this commit), which call the QWasmSuspendResumeControl API to
register JS/C++ event handler pairs:

  uint32_t index = control->registerEventHandler([](val){ ... });
  val jsHandler = control->jsEventHandler(index);

The C++ handler contains the user code, while the JS handler
can be passed to registerEventHandler or be used as a callback.

Change-Id: Ia1b1fd8884f0906759690dc7bc949c65a0248618
Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
2025-03-03 18:24:43 +01:00
Alexandru Croitor
94e19f42e8 CMake: Remove semicolon from SBOM external document references
The external doc references need to be appended as strings, not list
elements, otherwise there will be semicolons in the output SPDX file.

This issue was inherited as-is from the upstream SBOM generation
project.

We are fortunate the json converted files are missing the semicolons
due to implementation specifics.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I2b91775d59d64709b72ff7130dd4f6b506ef8244
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-03-03 17:31:16 +01:00
Matthias Rauter
784e67926a Silence compiler warning in tst_qrhi.cpp
Amends: 51979cfa172ebd89cf0235c6d8b6ccb97610c04d

Pick-to: 6.9 6.8
Change-Id: Ia9c553568ba3326bb971c833839a6f9c24240046
Reviewed-by: Magdalena Stojek <magdalena.stojek@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-03-03 16:31:16 +00:00
Cristian Le
e3af89f7b4 Make qt_internal_set_warnings_are_errors_flags genex-ed
Fixes: QTBUG-132705
Change-Id: I57987f1ae1c6d6adc4a2d0151f365c24605b940e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-03 16:33:54 +01:00
Cristian Le
e070742ab5 Unit test qt_internal_add_compiler_dependent_flags
Pick-to: 6.8 6.9
Change-Id: I12e476e1d7e36492811d2becf58e13923b443caf
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-03 16:33:54 +01:00
Cristian Le
167b38712d Add qt_internal_add_compiler_dependent_flags helper
Helper function that groups together compiler specific options and conditions

Pick-to: 6.8 6.9
Change-Id: Ibec52a19852ad528007f50316a52d2f867b5fe37
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-03 16:33:53 +01:00
Wladimir Leuschner
6dcae3c144 Revert "Windows: Check for bitmask instead for equality for initial window flags"
This reverts commit 369be485101c856c626a85f77ea087603dcf8b6c.

Reason for revert: This breaks the customize window hints on Windows.

Fixes: QTBUG-133940
Change-Id: Ib553c3f3742a14e0487cda27d057a4f4d50f76e2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-03-03 12:01:26 +00:00
Christian Ehrlicher
9b35b477f7 Fusion style: Fix drawing mdi close button with dpr != 1.0
Fix the drawing of the SC_TitleBarCloseButton for fractional dpr by only
drawing two lines with a width of 2 instead 6 single ones as the single
ones might get disturbed due to rounding.

Pick-to: 6.9 6.8
Fixes: QTBUG-133834
Change-Id: I711cef885ed04fa695c24ee3e536697a0ebb3868
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-02 14:35:44 +01:00
Christian Ehrlicher
04e00e4e6c Fusion style: simplify CC_TitleBar paintings
The painting of the various icons for CC_TitleBar was done with the idea
to do some fancy alpha blending. But it actually was never used and just
makes the drawing code a lot more complex than needed. Therefore merge
the drawing code for textColor and textColorAlpha into one.

Fixes: QTBUG-131492
Change-Id: I89ac7bcf76f5264cb85cd8a00f0d74da4b85fd7c
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-03-02 14:35:28 +01:00
Christian Ehrlicher
6f813bcb44 Style: pass widget to styleHint() where appropriate
QStyle::styleHint() take the QWidget as optional third parameter. Add
this to calls to styleHint() where appropriate.

Task-number: QTBUG-2501
Pick-to: 6.9 6.8
Change-Id: I95b85d51ce98540920243b37473b97426eb40ab4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-02 13:34:59 +00:00
Christian Ehrlicher
5b320c146b Style: pass widget to styleHint() where appropriate
QStyle::styleHint() take the QWidget as optional third parameter. Add
this to calls to styleHint() where appropriate.

Task-number: QTBUG-2501
Pick-to: 6.9 6.8
Change-Id: I62aa251f7dd9d78178ea8aefc1e2882d3ac040be
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-03-02 13:34:58 +00:00
Giuseppe D'Angelo
df97b6b2de QtNumeric/QtMath: add assertions in number rounding
qRound, qCeil, qFloor convert the input floating point number to an
int, using various rounding strategies.

They all have UB if the input fp number is out of range for the target
representation. This is actually documented (at least for qRound, see
a47a5932a64a8867077cab7c8efa57587b637481), and just the reality of the
current implementation for all of them.

This commit therefore adds an additional check, which asserts if result
of std::trunc (applied to the FP number after rounding) overflows.
std::trunc has the very same semantics of FP->integral conversions in
the language (round towards zero / discard the fractional part).

Since qRound is constexpr, make the wrapper constexpr-friendly as well,
which requires C++23 or a suitable compiler (GCC has had constexpr cmath
since GCC 5 or so.)

Change-Id: I17740381c2af98ebdda4c240035e53aea26116b0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-02 03:21:12 +01:00
Milian Wolff
1f0bcec874 Add maybe_unused in benchmark to guard against nodiscard in the future
Requested by Marc Mutz when adding the utc() benchmark.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I6f97f9e4dab07d10718280b4fb7ac158e42b8d67
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-01 21:44:15 +01:00
Milian Wolff
29c7beac2e Add a benchmark for QTimeZone::utc
On my machine this gives me:

```
********* Start testing of tst_QTimeZone *********
Config: Using QtTest library 6.10.0, Qt 6.10.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 14.2.1 20250207), arch unknown
PASS   : tst_QTimeZone::initTestCase()
PASS   : tst_QTimeZone::utc()
RESULT : tst_QTimeZone::utc():
     358.686871 nsecs per iteration (total: 358,686,513, iterations: 999999)
     896.524312 CPU cycles per iteration, 2,5 GHz (total: 896,523,416, iterations: 999999)
     2,227.000427 instructions per iteration, 2,484 instr/cycle (total: 2,226,998,200, iterations: 999999)
     560.000375 branch instructions per iteration, 1,56 G/sec (total: 559,999,815, iterations: 999999)
PASS   : tst_QTimeZone::cleanupTestCase()
Totals: 3 passed, 0 failed, 0 skipped, 0 blacklisted, 374ms
********* Finished testing of tst_QTimeZone *********
```

Profiling shows some quite unexpected code paths that
I will try to optimize in follow-up patches. Note that
this function can be called frequently when deserializing
QDateTime over a QDataStream e.g. - I have stumbled over
it while profiling some KDE PIM code in akonadi.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I7439df53ae8512c766f63cb4b0d4f33d14aa3a01
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-01 21:44:10 +01:00
Giuseppe D'Angelo
c5608c675a Geometry classes: honor the documentation when it talks about rounding
The floating-point based geometry classes promise rounding in their
documentation, in at least two places.

1) when fp math is applied to an integer-based class, the result is
   the same integer class. For instance, QPoint(1, 2) * 3.14 yields
   a QPoint (!). The documentation says that the result is rounded to
   the closest integer.

2) when a fp-based class is converted to the corresponding integer-based
   one (e.g. QRectF::toRect()). These functions have the same notice.

Insofar qRound has been used in the implementation of these functions.
There's a problem: qRound does not actually honor the "round to closest
integer" contract. Specifically, if the input floating point is out of
range for the destination type, then the behavior is undefined
(cf. a47a5932a64a8867077cab7c8efa57587b637481).

Since we have reports of cases where out-of-range values are indeed
passed through these functions, I'm extremely wary of changing the
behavior to be UB. Instead, I'm making these functions actually do what
the documentation says they do.

To this end, refactor the various qRound overloads and split the
rounding part from the casting to the destination type. The rounding is
kept as private API, using the existing arch-specific implementations.
The casting is generic and it's in the public qRound overloads.

Then, add a private qSaturateRound which re-uses the casting, clamps to
range ("saturating" -- which is still casting to the closest integer
value), and casts to the final type (only int, at the moment). This new
API is then used in the geometry classes when they round.

Fixes: QTBUG-133261
Change-Id: Iba0d9baa17c136a976a945742c117e4cfac520b3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-03-01 18:21:23 +01:00
Ulf Hermann
177cd123d2 QByteArray: Make gcc 12 happy
It somehow concludes that asize may be negative and would then cast to
an obscenely large size_t. This produces the following warning:

.../qbytearray.cpp: In member function ‘replace.constprop.isra’:
.../qbytearray.cpp:2579:23: warning: ‘memcpy’ specified bound between 9223372036854775808 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
 2579 |                 memcpy(d + to, a, asize);
      |                       ^

Check for asize > 0 rather than asize != 0.

Pick-to: 6.9 6.8 6.5
Change-Id: I63bccb1bf3ff45d539af4efe6843d2c648d7cb86
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-28 23:14:55 +00:00
Giuseppe D'Angelo
1145e1709d Geometry classes: introduce check for overflows
The integer-based geometry classes all risk triggering UB via signed
integer overflow. Their representation and APIs exclusively use `int`.
This means that for instance one can build a QLine spanning from
x1=INT_MIN to x2=INT_MAX, and they try asking its delta-x (dx()),
causing an integer overflow in the computation.

So far, this has always been "undefined behavior that works in
practice", effectively wrapping values around on all of our supported
implementation. This choice however makes it impossible to have hardened
/ ubsan builds of Qt. It also causes some bizarre behaviors: for
instance, a maximal QRect (going from (INT_MIN, INT_MIN) to (INT_MAX,
INT_MAX)) reports "false" when asked if it contains() a 10x10 rectangle.
(That's because QRect::contains() overflows.). Users may not readily
notice what is going wrong here.

After some thoughts, I've decided that the burden here lies on Qt.
While it's true that these geometry classes are nothing but glorified
int holders, their representation and handling is entirely chosen and
controlled by Qt. The user is not supposed to know "in advance" that
QRect holds a couple of points and not, say, a point and a size.

Qt also chose the shape of the APIs, taking and returning ints, even
when some of these APIs cannot return meaningful results due to the
chosen representation.

The best we can do at this point is to trigger assertions if some
calculation overflows. Therefore, deploy the newly introduced private
checked integer class, that will assert if something goes wrong. In
release builds they will keep the pre-existing behavior (wraparound),
but they will remove the associated UB.

The changes are mostly mechanical:

1) change the representation of the geometry classes to use the checked
   integer (instead of plain `int`);
2) change getters/setters to deal with conversions from and to the
   checked integer;

plus some minimal fallout. Operator overloading on the checked integer
keeps the code 99% similar, and doesn't decrease readability. Some care
is necessary to try and make all internal calculations use the checked
int, instead of falling back to operations on `int`.

I've tried to keep the behavior identical as much as possible (except of
course for detecting overflow). In particular I haven't reengineered the
existing implementations to so something "smarter" or use 64 bit
arithmetic if possible or so.

The only exception is the QRectF constructor from QRect. Since a QRectF
can faithfully represent any QRect, in the conversion I'm taking
special care not to call width() or height() as they may overflow.
Instead, I calculate them using int64. This allows for a maximal QRect
to be converted to a QRectF without loss of information (instead of what
was happening before).

Some other remarks:

* operator/ checks that the divisor is not zero. This was done in
  several places already and just missing here and there.
* QRect::isNull had a bizarre behavior (autotested) where a maximal
  rectangle was considered null (because of wraparounds). I've decided
  to keep this behavior.
* Several test rows in tst_QRect were relying on overflow behaviors.
  However, many others were already commented out, with a comment
  saying "it would cause an overflow". Therefore I've commented them
  out as well.
* The integral classes sometime have functions taking qreal (e.g.
  `operator*`). In there, qRound is applied to keep the result integral.
  In principle qRound can also overflow and cause UB, but I've decided
  to tackle that separately because I'm not sure what should happen
  (QTBUG-133261). This also happens for the fp->integral conversion
  functions (e.g. QRectF::toRect()).
* The functions are marked constexpr, so add some minimal testing to
  make sure I'm not breaking it.
* Some functions are also marked noexcept. We need to have a broader
  discussion whether that's actually wrong, and how to recover from
  there.

Task-number: QTBUG-98965
Task-number: QTBUG-132947
Task-number: QTBUG-133261
Change-Id: Idde1daa5c6ca3e37ba0e402617576c5d130615f5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-28 23:40:58 +01:00
Eirik Aavitsland
56de113975 Raster engine: Fix painting of zero length, square cap wide lines
Such lines are rendered by drawing a capless line that is pen-width
long, i.e. a square, to represent the two line caps. However, the line
length offset was added before any transformation, so one could end up
with a long line being rendered if the world transform had a large
scale, say.

Pick-to: 6.9 6.8
Change-Id: Idff8a2de54c97e35facc8f4e09c43dfea7397588
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-02-28 21:04:48 +01:00
Thiago Macieira
9a753fa656 QColorDialogOptions: delete QSettings code and stop saving globally
[ChangeLog][QtGui][QColorDialogOptions] The class no longer
automatically saves settings such as the custom colors to a global
QSettings("QtProject") shared by all applications and no longer restores
custom colors from there. Applications that wish to retain the custom
color settings should use customColors() and setCustomColor() with their
own settings files.

Task-number: QTBUG-133805
Pick-to: 6.9
Change-Id: I49cd7312054f41ca4cdbfffdcb60d6ea242393fc
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-02-28 16:20:59 -03:00
Joerg Bornemann
a9f26c3f9a CMake: Fix building tests with qt-cmake-standalone-test
We now require user projects to use find_package(Qt6FooPrivate) if
the Qt6::FooPrivate target is used. We don't require this for Qt's
autotests. But configuring such a test with qt-cmake-standalone-test
failed.

Fix this by setting QT_FIND_PRIVATE_MODULES to ON in the CMake project
template for standalone tests.

Change-Id: I778cbfc16638a94b5fe538c175394501df106b82
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-28 19:07:43 +01:00
Marc Mutz
58b9250aea Init QWidget::data to nullptr
It's unconditionally set to &d->data in d->init(), but at least
Coverity doesn't see it as that. Turn a potential uninit'ed value
access into a proper nullptr deref, in case Coverity has a point.

Not picking to older branches (at least not yet) in the unlikely case
that this unearths something.

Coverity-Id: 390797
Coverity-Id: 390790
Coverity-Id: 390785
Coverity-Id: 390783
Coverity-Id: 390775
Coverity-Id: 390774
Coverity-Id: 390771
Coverity-Id: 390765
Coverity-Id: 390762
Coverity-Id: 390751
Coverity-Id: 390737
Coverity-Id: 390734
Coverity-Id: 390727
Coverity-Id: 390724
Coverity-Id: 390707
Coverity-Id: 390706
Coverity-Id: 390700
Coverity-Id: 390693
Coverity-Id: 390692
Coverity-Id: 390690
Coverity-Id: 390684
Coverity-Id: 390680
Coverity-Id: 390677
Coverity-Id: 390675
Coverity-Id: 390669
Coverity-Id: 390662
Coverity-Id: 390660
Coverity-Id: 390659
Coverity-Id: 390657
Change-Id: Ieba218117d4bfdb4cdf5069211e9d12517b26d24
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-02-28 18:30:39 +01:00
Cristian Le
9d78275f22 Copy qt_set01 to a central location
Change-Id: I05b3ef4d02dd1f8583eea9960c3776409f2f3b2e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-28 17:49:25 +01:00
Cristian Le
2d27183567 Make FEATURE_static and FEATURE_shared aliased features
Fixes: QTBUG-133407
Change-Id: Ic17315b0229a829689b77e272cd9bbd331c3b0d7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-28 17:49:24 +01:00
Cristian Le
a6140d8469 Allow Feature to be alias of Cache variable
Change-Id: I09b65cb038567a9f68a140e53a9e06eb15c8fc13
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-28 17:49:24 +01:00
Cristian Le
beda9c8249 Forward other qt_feature options in qt_feature_alias
Change-Id: Ic0b7479e071fc17020a04ea48386054f0bbf3151
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-28 17:49:24 +01:00
Cristian Le
6a93429fc0 Add NEGATE to qt_feature_alias
Change-Id: I9e10618a3bc76d285d7bd59ebbf5bc5e56de62d0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-28 17:49:24 +01:00
Cristian Le
4bbd324a0a Add qt_feature_alias
Unlike chaining a feature into its `CONDITION`, it has a guaranteed
one-to-one equivalence with the original target.

- An alias cannot be set if the main feature is already set
- Multiple aliases of a feature cannot be set at the same time

Change-Id: I5b17ec3af51761880a7edb0c47ad8144815f1f93
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-28 17:49:24 +01:00
Eskil Abrahamsen Blomfeldt
82a3357d00 Update Harfbuzz to version 10.3.0
[ChangeLog][Third-Party Code] Upgraded Harfbuzz to version
10.3.0.

Pick-to: 5.15 6.5 6.8 6.9
Change-Id: I3a4daaa9c0747c4f4717ac8f0f9e7baf9a9a449e
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-02-28 17:18:29 +01:00
Eirik Aavitsland
91f502a7d6 Add QPainterPath::trimmed(), returns a slice of a path by length
Path trimming is used in vector graphics and design.

Change-Id: Id5f32b570182f0e8f790835b2fbeb28b3432e40d
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-02-28 17:18:28 +01:00
Alexandru Croitor
dc5c7f9ead CMake: Add function to set up SBOM generation defaults
Move the setting up of options like QT_GENERATE_SBOM into a separate
function, that can be called by projects other than Qt.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I337c4e9b0b3154ff97f494887bf88ee01e8ed00c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-28 14:51:19 +01:00
Alexandru Croitor
cf9f09cd60 CMake: Include license and license file attribution in SBOM comment
Some attribution entries don't have a SPDX license id specified, in
that case it's good to at least include the free-form license name and
file path.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I75bb5c30645684ea74fe94da92ea30eb29965ad4
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-28 14:51:19 +01:00
Assam Boudjelthia
e5f79573fe Revert "Revert "Android: update to Gradle 8.12 and AGP 8.8.0""
This reverts commit bcbb1701abfee341cc55fc831af060dbf5e2e30a.

Reason for revert: Needed provisioning changes are now in

Change-Id: I87a2e0fbe1d79e1856de8b36c4c2c181044726ad
Reviewed-by: Jukka Jokiniva <jukka.jokiniva@qt.io>
2025-02-28 13:51:19 +00:00
Marc Mutz
b7a67b46e6 Long live \constraints!
We have divergence in the way we document function, operator and
constructor constraints. About half use \note, while the other
doesn't. Some say "if and only if" while others say just "participates
only if".

So add a qdoc macro, \constraints, to semantically mark up these
constraints. It expands to a section titled `Constraints`, and
uses a predefined sentence (prefix) for constraints.

Documentation for constraints is moved to the end of the comment
blocks to separate them from the rest of the text.

Apply them to all the standard-ish constraint documentation blocks
(grepped for "participate"). I didn't look for other, one-off, ways
documentation authors may have documented constraints, but I'm also
not aware of any.

Re-wrap lines only if the result fits into a single line.

As a drive-by, drop additional "if"s, as in "only if X and -if- Y" to
make the texts work with the `Constraints` section.

Fixes: QTBUG-106871
Pick-to: 6.9 6.8 6.5
Change-Id: I18c2f9f734474017264e49165389f8c9c7f34030
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-02-28 13:51:18 +00:00
Tor Arne Vestbø
abcea0d249 Remove old qmake .pri files
The .pro files for building the client and compositor modules
have been removed already, so we don't need the .pri helpers.

Change-Id: Ieb8ea7cc292e6b2c98e4f24932810ef426a54141
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-02-28 13:46:16 +01:00
Laszlo Agocs
6f89357f59 rhi: d3d: Fix 3D textures exposed via UAV
The docs for D3D11_TEX3D_UAV do not mention accepting -1 as WSize,
unlike D3D12_TEX3D_UAV. Hence passing in m_depth for D3D11.

Fixes: QTBUG-129300
Pick-to: 6.9 6.8
Change-Id: I517d23e076039543361d2bca1b91cddd47abcfaa
Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io>
2025-02-28 13:11:53 +01:00
Joerg Bornemann
0772749b2c CMake: Fix test_waylandclient
The test uses Qt6::WaylandClientPrivate and must now
find_package(Qt6WaylandClientPrivate).

Fixes: QTBUG-134205
Change-Id: Ia715ff9dd57ff4d19679f686fad64954c38289b6
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-28 12:58:41 +01:00
Marc Mutz
fff6928878 tst_QByteArray: check replace() doesn't replace the terminating \0
It doesn't.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Ica3fb2b8a65d0f9d14490ecdcce72eba82258916
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-02-28 12:23:40 +01:00
Marc Mutz
7c21630ce6 QByteArray::replace(): use std::string instead of QVLA<char>
QVLA preallocates space for 256 entries, and while that should be
enough for most uses, it may be too much in the way of stack usage.

Instead of using a QVLA with a non-standard preallocation, use the
more compact std::string benefitting from its SSO.

Pick-to: 6.9 6.8 6.5
Change-Id: Ia22543fb287a1976f316f7a4d27b23a22f511463
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-02-28 10:49:52 +00:00
Liang Qi
9c4cd93ab4 protocol: update version info of wayland.xml in qt_attribution.json
This amends d4492782ed03a2ef6fc27f8b22e93b805ce7e092 .

[ChangeLog][Third-Party Code] Update wayland.xml to 1.23.0.

Pick-to: 6.9
Change-Id: I07cfe6e8eb715c115444cf24288f0b1362754176
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-02-28 11:01:37 +01:00
Nicholas Bennett
9c6c6d7d38 Docs: Create \Q4A macro for "Qt for Android" and replace instances
"Android" is trademarked and needs to be referenced in a certain way.
The following steps were taken:
-Created qdoc macro.
-Updated "Qt Android" and "Qt for Android" to use \Q4A in qdoc files.

The macro will need to be adopted in all documentation projects.

Task-number: QAA-2836
Pick-to: 6.9 6.8 6.5
Change-Id: I4b52247a4ed52047242a06404e6d3aa19de9c16c
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-02-28 06:35:03 +00:00
Thiago Macieira
cb382450aa QCoreApplication: implement the ### Qt7 to rename requestPermission
Amends commit 207aae5560aa2865ec55ddb9ecbb50048060c0c0.

Change-Id: Iff0d62fb157087299faafffd6e14a2b95c2bc1de
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-02-28 00:52:10 -03:00
David Faure
d2efb6faba QAbstractItemDelegate: add handleEditorEvent()
QItemDelegate and QStyledItemDelegate had this exact implementation
already, the actual code being in QAbstractItemDelegatePrivate.

If someone writes their own delegate by deriving from
QAbstractItemDelegate, they had no way to call the default
event filter code (to get Enter to commit, Esc to abort editing etc.).

[ChangeLog][QtWidgets][QAbstractItemDelegate] The base class now
provides a handleEditorEvent() method, which provides the same event
handling as in QItemDelegate and QStyledItemDelegate, including Tab,
Enter, Esc keys and focus out handling.

Change-Id: I1b560d8a1b348e3b3bb5cfc3162f9b265b706684
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-02-28 00:02:16 +01:00
Alexandru Croitor
9245d0a0f0 CMake: Handle installing files with same name during SBOM generation
It's possible for a project to install a custom file with the same name
into different destination directories, and want to include them in
the SBOM.
Previously this failed at CMake generation time with an error like:

CMake Error: Files to be generated by multiple different commands:
qt_sbom/SPDXRef-PackagedFile-foo-bar.cmake

This happened due to using a non-unique filename for the generated
SBOM building file, as well as the spdx id the file name is based on.

Include a short hash based on the installed relative path of the file
to avoid spdx id clashes, and thus generated file name clashes.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I4c2ecd4652708504ef299af9b6f53d680d542382
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-02-27 16:19:46 +01:00
Marc Mutz
cef7892135 tst_QStringTokenizer: check when the lazy range may be empty
Only when using SkipEmptyParts...

Pick-to: 6.9 6.8 6.5
Change-Id: I7dd67b801fa0deaab14eb7bb7e9905f60891ec48
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-02-27 16:11:22 +01:00
Alexei Cazacov
baeed8e1e7 Doc: Move 'Classes for string data' topic to Qt Core and add it to TOC
Fixes: QTBUG-133954
Pick-to: 6.9
Change-Id: If51abefc39eaae29f7d533af2974017793ef9358
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
2025-02-27 17:11:21 +02:00
Alexandru Croitor
9db03c9dca CMake: Handle DIRECTORIES in SBOM custom file sets
Previously one could only pass an explicit list of FILES to
_qt_internal_sbom_add_files. Add a new DIRECTORIES option, which will
glob the given directory paths, and include the found files in the
SBOM.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: Ia27afa93460d9f2e4462a49e30e4d6338300e8f7
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-27 13:54:50 +01:00
Alexandru Croitor
ba93956be1 CMake: Extract Qt-specific license concluded handling
Extract the handling of the license concluded expression for Qt
entities into the Qt specific handling file.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: Ib6f9a64f66dae0c971c43e8fffbc54362487b271
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-02-27 13:54:50 +01:00
Alexandru Croitor
0d9106bf76 CMake: Unqtify THIRD_PARTY_SOURCES handling for SBOM attributions
Nested SBOM attribution targets were always created with the
QT_THIRD_PARTY_SOURCES type even in user projects.
Set an appropriate type depending on whether we are handling a qt
entity type or not.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: Id8144d1b8093de78f2987a611a6de8e6d4777084
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-02-27 13:54:49 +01:00
Alexandru Croitor
8b06d37fb0 CMake: Add a new SBOM entity type: THIRD_PARTY_SOURCES
It mirrors the Qt-specific QT_THIRD_PARTY_SOURCES one, to be used when
creating an SBOM attribution target that references a 3rd party
library's sources, as opposed to a complete 3rd party library.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I8f7f9f7386ffdc18dd8ae6ee32e39019639f5303
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-27 13:54:49 +01:00
Alexandru Croitor
17c482d818 CMake: Remove leftover code after refactoring
The assignment is not used anywhere.

Amends f1ac316191c010b1389f6f3549c9f0b4424b9936

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I3e6326b2782ab42dee8219353953ee6f4378ccfb
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-27 13:54:49 +01:00
Alexandru Croitor
a5c7eb97ce CMake: Re-order SBOM embedded qt_attribution.json fields
Put the attribution file path and entry first, followed by the id,
and the rest of the fields.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I478a48980e6207646189d6b80ec57dbc9efb4902
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-27 13:54:49 +01:00
Alexandru Croitor
a2ddd4fbd8 CMake: Allow creating nested SBOM attribution targets for all entities
Allow creating nested SBOM attribution targets also for non-Qt targets
in user projects. This will allow using qt_attribution.json files in
user projects.

Rename PARENT_TARGET to ATTRIBUTION_PARENT_TARGET to make it clear
what the parent target is for.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: Ia08ee934a9dc03827fcc26d0fc90e072499e8a21
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-27 13:54:49 +01:00
Alexandru Croitor
52045e51e7 CMake: Allow including specific attribution ids in SBOMs
Previously one could attach all attributions from a
qt_attribution.json file to a target, or a specific entry based on a
given numeric index.

This is not always practical, as the index of an entry can change, and
including all entries might be too much.

Allow specifying a list of attribution ids to include in the SBOM.
This will parse all the attribution entries and only include those
that match the given ids.

If a list of ids is provided, and any of them is not found, an error
will be shown.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I2ca442fe0cd6d18773861f90f32ab7380aaeacdd
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-02-27 13:54:49 +01:00
Alexandru Croitor
4a0b5661fd CMake: Sanitize nested SBOM attribution target names
To avoid issues with characters like "/" which might come from
attribution ids.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I65bec3b301f7fe1008cfd06aba3e1fbbb93f38c3
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-02-27 13:54:48 +01:00
Alexandru Croitor
6cd7f0c09b CMake: Remove type restriction on attribution file extra SBOM info
So it can be used in other non-Qt projects.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I11d81d2c6819906fffbffe81f4db1b7af28cb99b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-27 13:54:48 +01:00
Alexandru Croitor
422f5d859f CMake: Remove type restriction on attribution download location
So it can be read / used in other non-Qt projects. We don't have such
a restriction on other keys read from the qt attribution files.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I225d83b26c68323761a8b13b3e6442057b5f7c7f
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-02-27 13:54:48 +01:00
Marc Mutz
5fc1e9fa0c tst_QByteArray: check replace() with empty and null needles and haystacks
Some time ago, we spent a lot of time fine-tuning the behavior of
indexOf() and split() w.r.t. matching of empty needles, or in empty
haystacks. Make sure that (QByteArray) replace() is behaving
consistently.

It isn't. Filed QTBUG-134079 to track the issue.

Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-134079
Change-Id: I16af5d2bb5b309a56e81854be434fa9430ae284f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-27 08:05:50 +01:00
Sze Howe Koh
f5b874fd2d [Doc] QObject: Sync warnings of isSignalConnected() and receivers()
Extends e75c1a00e31723f1c9deb8427725fa0a58fae2a8 because calling
receivers() in disconnectNotify() can deadlock too.

As a drive-by, some statements are generalized further:
* "expensive initialization" -> "expensive operations" since that is
  what the relevant snippets actually show.
* The potential race condition is not limited to "after this function
  returns and before the signal gets emitted"

Task-number: QTBUG-106025
Change-Id: Iff014706b9e8d8147e3bbb9ac51542197eec5db3
Pick-to: 6.9 6.8 6.5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-27 14:21:06 +08:00
Thiago Macieira
6fb39ca2cb Use QThread::isMainThread() in a few places
It's thread-safe, whereas trying to load qApp isn't in Qt 6.x (will be
in 7.0) and dereferencing it to call QObject::thread() will probably
never be. It's also faster, being a single function call instead of two
or three.

This is not an exhaustive search, it's just a few places I found while
searching for QThread::instance().

Pick-to: 6.9 6.8
Change-Id: I3b4e1c75bb3966e2cd2dfffd79bfc8a40f6cf40b
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-02-26 17:54:59 -08:00
Axel Spoerl
7c7731a822 tst_QScroller::overshoot(): improve diagnostic output, blacklist on mac
Test is flaky on macOS.
Use QCOMPARE_LT instead of QVERIFY(a < b).
Blacklist on macOS.

Task-number: QTBUG-134105
Pick-to: 6.9 6.8
Change-Id: I8f1274ad67bd9ead392ecd0f9c9b7a01dc3edb1e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-02-27 00:14:03 +00:00
Giuseppe D'Angelo
1719379471 QPlatformDialogHelper: remove inheritance from QSharedData
None of the Private classes is now used as a refcounted entity,
therefore drop the inheritance from QSharedData.

Change-Id: I10708702969454f33cb88cf991560ea87b085aca
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-02-26 23:12:07 +01:00
Giuseppe D'Angelo
fe95781897 QColorDialogOptionsPrivate: clean up inheritance and RO5
It's unclear why the class inherits from QSharedData, since it's
never used as a refcounted entity. Instead, for some reason,
QColorDialogOptions+QColorDialogOptionsPrivate are combined into
one struct (ColorDialogCombined). Therefore, drop the inheritance
from QSharedData. Other platform dialog classes have the same issue,
will tackle them in a follow-up commit.

QColorDialogOptionsPrivate also declares a destructor. Since apparently
copies are needed, redeclare them, but suppress assignments (uncertain
use case). This fixes Clang's -Wdeprecated-copy-with-user-provided-dtor.

Change-Id: I335ef0e8ef541762fd03bf76b3e4fd4dd0828505
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-02-26 22:12:07 +00:00
Ahmad Samir
4275dfb7bf QDir: add mkpath/mkdir overloads taking std::optional<Permissions>
std::optional:
- it's already used in private API in QFileSystemEngine and
  QAbstractFileEngine and its subclasses, so there is no extra overhead
- less code duplication as it lets the existing overloads call the new
  ones with std::nullopt to make it use the platform default permissions
- adding a new enumerator, e.g. "PlatormDefault", wouldn't work:
    - 0x0 is ambiguous with setting the permissions to nothing
    - the new enumerator mustn't set any other permission bits, so it'll
      have to be > std::numeric_limits<short>::max(), which is
      potentially BiC as the underlying type of the enum will become int

[ChangeLog][QtCore][QDir] Added mkdir() method that takes a
std::optional<QFile::Permissions>; the new method transparently replaces
the older mkdir() overloads.

[ChangeLog][QtCore][QDir] Added mkpath() method that takes a
std::optional<QFile::Permissions>; this new method transparently
replaces the older mkpath() overload.

Task-number: QTBUG-132633
Change-Id: Ic2cd1e01e6ad1a2b6d3a6180c41b6a0b260a4e55
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-27 00:12:07 +02:00
Ahmad Samir
23981aae0e QDir: improve mkdir/mkpath API docs
Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-132633
Change-Id: Iafe4a20bacbbf55d19377e8cd04f940d4f2a66f6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-27 00:12:07 +02:00
Thiago Macieira
122979e3a1 QLibraryInfo/Win: use the ActiveQt-overridden handle for the main module
This applies to qaxserverdll only, where "the executable" is actually a
DLL.

Change-Id: I8ac1bc015b9e6f381de8fffd1f8ee185d923f1f4
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2025-02-26 11:59:42 -08:00
Thiago Macieira
64cd765531 QCoreApplication: speed up fallback path in applicationFilePath()
QCoreApplication::arguments() is not cached, so let's not call it twice.

And do move from the path we've just calculated.

Change-Id: Ibc00ec588aa93c19f676fffd400d129e251672b7
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-02-26 19:59:42 +00:00
Thiago Macieira
e178567bbb QCoreApplication: avoid extra work in applicationFilePath() if we can
In the four OSes where qAppFileName() returns non-empty, the returned
path is always absolute and canonical, so there's no need for us to
further canonicalize it. So let's have applicationDirPath() have an
early out for it and mark it as Q_LIKELY().

In the other OSes, qAppFileName() is static inline in this very file, so
the compiler will probably see that it's always empty and ignore the
Q_LIKELY().

That leaves the atypical cases of /proc/self/exe being empty on Linux (I
don't know when this could happen, but it's not impossible) or non-
bundle executables on Apple OSes.

Change-Id: Ic47b28bda60085bcbcc8fffd28a0f3b864e07fd5
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-02-26 11:59:42 -08:00
Thiago Macieira
d34a3536bf QCoreApplication: avoid QFileInfo in applicationDirPath()
QFileInfo allocates a lot of memory, so it's not very good a tool for
manipulating just strings. As this function is called very early in the
application's lifetime (by the first qDebug() or so), we can avoid
creating the QFileInfoPrivate by going straight to QFileSystemEngine,
which is what QFileInfo::path() would have done:

QString QFileInfo::path() const
{
    Q_D(const QFileInfo);
    if (d->isDefaultConstructed)
        return ""_L1;
    return d->fileEntry.path();
}

Change-Id: Ie911c42577113c477aa9fffd5dcbb7e6f24af8f6
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-02-26 11:59:42 -08:00
Thiago Macieira
87ba5348e9 QCoreApplication: remove the applicationDirPath() cache
It's just a string manipulation and it's not that important to keep
cached. Especially since we wouldn't update it when
applicationFilePath()'s cache was invalidated on argv[0] change:

    if (d->argc) {
        static QByteArray procName = QByteArray(d->argv[0]);
        if (procName != QByteArrayView(d->argv[0])) {
            // clear the cache if the procname changes, so we reprocess it.
            d->cachedApplicationFilePath = QString();
            procName.assign(d->argv[0]);
        }
    }

Amends commit e6f483c0e802969e79aca5b37ef3f4912a6e25d7.

Change-Id: I52a4cd2ebf500a941d5dfffd4b5e10ff22523d61
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-02-26 11:59:42 -08:00
Aurélien Brooke
383ed62676 rhi: add R8SI, R32SI, RG32SI, and RGBA32SI "exotic" texture formats
As a drive-by, fix the glformat of UINT formats: they should use
GL_XXX_INTEGER and not GL_XXX which is for float formats.

[ChangeLog][RHI] QRhiTexture gained R8SI, R32SI, RG32SI, and RGBA32SI
signed integer formats.

Fixes: QTBUG-109255
Fixes: QTBUG-125225
Change-Id: If64eab10023e99b0211a6e71292ab352096ed4e4
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-02-26 20:59:42 +01:00
Aurélien Brooke
b3b31d7c0e rhi: add an autotest that creates every supported texture format
This can be useful to check that we are not missing any precondition
when adding new texture formats.

Change-Id: Icb4b311ec5b903802e69ef5abd4896146fcce783
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-02-26 20:59:42 +01:00
Fabian Kosmale
7216eb292f QSignalSpy: Drop the RegisterMethodArgumentMetaType metacall
There's nothing the meta-call could achieve: If the argument tpye was
complete when the meta-object was created, we would already have created
the metatype-interface for it, and would return a QMetaType constructed
from it in QMetaMethod::parameterMetatype. If the type wasn't complete,
parameterMetatype would have done the name to type lookup.

Consequently, if the lookup failed so far, calling
RegisterMethodArgumentMetaType would not help either, unless we would
have a dynamic meta-object with a custom implementation of
RegisterMethodArgumentMetaType. Such an implementation does not exist in
Qt.

This removes the last remaining user of RegisterMethodArgumentMetaType.

Change-Id: I9b9abbc3b4ba573b242027ecaa230ea27cb2ebf6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-02-26 15:31:34 +01:00
Giuseppe D'Angelo
fb1824a9d6 Q_DECL_EQ_DELETE_X: properly version the check for Clang
Clang 20 has fixed the referenced issue. Once more this shows the
importance of versioning compiler-related checks...
Amends 1b1ae345025d1cac953985d4cfebd20fadb6bc99.

Pick-to: 6.9
Change-Id: Iea88d466883562b0130639d7c0f2f3b984acdbc2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-26 15:27:32 +01:00
Giuseppe D'Angelo
874be50e7b QStringView: introduce a user-defined literal operator
Although char16_t string literals implicitly convert to QStringView,
there are corner-cases where one may want to explicitly create a
QStringView out of them.

A couple of examples I've found is where these string literals decay
into pointers:

  // range is a std::initializer_list<const char16_t *>
  for (QStringView v : { u"foo", u"bar" }) { ... }

  // ternary will decay arguments
  void print(QStringView);
  print(check ? u"hi" : u"there");

When this happens the resulting code gets pessimized and polluted by
runtime calls to qustrlen in order to build the QStringView objects [1].

We can restore optimal codegen by directly dealing with QStringView
objects instead. Adding explicit conversions may make the code
cumbersome to read, so I'm introducing a UDL for QStringView, matching
the one for QString (and std::string_view).

[1] for instance: https://gcc.godbolt.org/z/eY7xvEje3

Apply the new operator to a couple of places.

[ChangeLog][QtCore][QStringView] Is it now possible to create
QStringView objects by using the u""_sv user-defined literal.

Fixes: QTBUG-123851
Change-Id: I8af7d2e211b356d284de160a222eab9e91d09500
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-26 15:27:32 +01:00
Michal Klocek
04d17b2e22 Enable building tests on WoA cross compile
Note this change has no impact on it own on current integrations,
as it barely adds tests compilation.

It is required for qtwebengine on WoA story.

Do not run some tests:
(required for qt5 patch introducing woa test node)
 * cmake test as host tools are provided by mingw,
   but tests are run natively by WoA platform.
 * dbus as this does not run natively on Woa anyway
   due to missing dbus service.

Change-Id: Ifdb3e1b76a7feb906a9031815984c716618e3882
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-26 15:27:32 +01:00
Rami Potinkara
7a7093eb87 Android: update Android SDK to version 35.0.1
This patch updates the macro AndroidBuildToolsVer to
version 35.0.1.

The version 35.0.1 is used elsewhere, see
b49421a984ac2b203b7995f3787b67184c990089

Amends: 9b475eadfcf04194a094454f65295c3a456000a4

Task-number: QTBUG-129462
Pick-to: 6.9 6.8 6.5
Change-Id: Ic15e12c563fa3d16315daa13b6f6b6ef19535954
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2025-02-26 16:27:28 +02:00
Thiago Macieira
d09c6c1046 Short live QCoreApplication::instanceExists()
This is a thread-safe version of

    QCoreApplication::instance() != nullptr

for Qt 6.x, because QCoreApplication::self is not atomic and thus
reading it from outside the main thread could be a data race.

That's not to say it always is: if by construction the code can only run
in the main thread or while QCoreApplication definitely exists, that's
safe. Therefore, this commit focuses on places that are meant to be used
in multi-threaded environment (ruling out most of QtGui and QtWidgets)
or where the code was going to dereference the returned pointer anyway.

Change-Id: I6fc556c5fe5cbe0b5902fffdfb6b3bb345b0ee50
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-26 06:45:07 +00:00
Eirik Aavitsland
8b75f4735b Update bundled libpng to version 1.6.47
[ChangeLog][Third-Party Code] libpng was updated to version 1.6.47

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I11a0f266dddaad480a7700c3cdc4ec6da8de2fae
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-02-26 03:32:45 +01:00
Giuseppe D'Angelo
a7ff4679fa QColorTransferGeneric: fix the BT.2100 PQ EOTF
The PQ EOTF formula for BT.2100 [1][2] was incorrect. Fix it; while at
it, rename the variables to match the symbols used in the original
formula.

The inverse EOTF was correct, but also rename the variables there (for
the same reason).

[1] https://www.itu.int/rec/R-REC-BT.2100-2-201807-I/en
[2] https://en.wikipedia.org/wiki/Perceptual_quantizer#Technical_details

Change-Id: I6ce3a609824bee82053a16b3ff3cfc7cb396ce8f
Pick-to: 6.9 6.8
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-02-25 21:09:42 +00:00
Cristian Le
39e7946cb6 Bundle Kitware's RunCMake test module
Introduce a new module `TestInternalPrivate`.

Kitware's RunCMake allows to create more granular unit tests using
`cmake -P` scripts instead of configuring, generating and building full
projects.

[ChangeLog][Third-Party Code]
Add upstream cmake's RunCMake test infrastructure module to
src/testinternal/3rdparty/cmake to aid in creation of cmake auto-tests.

Pick-to: 6.8 6.9
Change-Id: I08cb7c6dc6f61bde29f176d58295f4f660b34ca8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-25 22:09:42 +01:00
Cristian Le
2433d02856 Make AdditionalTargetInfo.cmake optional
Pick-to: 6.8 6.9
Change-Id: I8b8d6383b6c50e9403bc90e76d4da8eb6c314854
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-25 22:09:42 +01:00
Cristian Le
aef789ad97 Add interface to install EXTRA_CMAKE_FILES in other paths
If the source file sets `QT_INSTALL_PATH` property, it will install the
CMake files in the relative path starting from the config-dir in both
the build and install paths.

Pick-to: 6.8 6.9
Change-Id: I86197d62bfac96f9c142d8abfe85c9b6f6f1a527
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-25 22:09:42 +01:00
Thiago Macieira
f8d1b58427 QMessageLogger: merge the isFatal() call into qt_message_fatal()
Making it qt_maybe_message_fatal(). Thus we're less likely to forget to
do the right thing.

Change-Id: Ie3c344d9f64527fc755ffffdd3c97cf8fa3fcc90
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-25 11:05:38 -08:00
Jaime Resano
cc517dd30d Fix resource system documentation
The referred file "titlebarLeft.png" does not exist. In addition, some
resource path prefix explainations are wrong

Change-Id: I3d88e5baf6a6d1fe45b6174fc18a080d87a0779c
Reviewed-by: Jaime Resano <Jaime.RESANO-AISA@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-02-25 18:31:01 +00:00
Alexandru Croitor
2dd0c4520f CMake: Add quotes around QT_DEBUG_OPTIMIZATION_FLAGS compiler flags
To more easily spot white space differences.

Pick-to: 6.8 6.9
Change-Id: I1e07960f78c95ca536243ce5c4fc6c302c47a7db
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-25 19:31:01 +01:00
Alexandru Croitor
fdb9a51414 CMake: Fix full rebuilds when using MSVC and reconfiguring the build
When reconfiguring an MSVC -release build with 'cmake .' after a full
build, instead of being a no-op, it rebuilt everything.

This happened because of CMAKE_CXX_FLAGS_RELEASE being accidentally
modified on each reconfiguration, resulting in extra whitespace being
added to the compiler command line rules.

Specifically, this was because we always added '-O2 -Ob3 ' as a string
to the compiler flags, but due to stripping, always tried to remove
only '-O2 -Ob3' (no trailing white space) when removing the
optimizations flags, resulting in an extra white space for each run.

Remove the trailing white space after '-Ob3 '.

Amends 2fb134f3fe8fdeb1f36c346cff3b09a2b7a095a7

Pick-to: 6.8 6.9
Change-Id: I46eb4c3b769ae6b063fe62df05c0cb92f13bda30
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-25 19:31:00 +01:00
David Redondo
3c8bc2721c Add logging category for platform services
Rather than being hidden behind a compile time flag or uncategorized

Change-Id: I3bc1781351220441134fb9815644e905273a1e40
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-02-25 19:31:00 +01:00
Harald Sitter
0d11ab87ca client: search for libvulkan.so.1 as first choice
this aligns the libvulkan lookup with qxcb, which too looks for .so.1
first and .so second. linux distributions often put the .so in separate
development packages that aren't installed by default.

See also 888b75aa12e2cf35ee760bcf5cb1ed60fe0c0770 in qtbase.

Pick-to: 6.9 6.8
Change-Id: I0639896b09df89a96696554f16b3ca4d06035ac0
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-02-25 14:34:48 +00:00
Giuseppe D'Angelo
0770171dcd Docs: uppercase spelling of utf-8
It should be spelled UTF-8 (official name by the Unicode Consortium).

Pick-to: 6.9 6.8
Change-Id: Ib358d0870e77f0cb4cdb920ed5ca829f100707a1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-25 09:53:23 +01:00
Fabian Kosmale
e84145d6c1 qt-cmake-create: Modernize QML template
- Do not use a version for the executable module target
- Rely on QTP0001 for the RESOURCE_PREFIX (via
  qt_standard_project_setup)
- Do not use OUTPUT_DIRECTORY to avoid a URI mismatch, potentially
  causing issues with the implicit import. Instead, use
  RUNTIME_OUTPUT_NAME to avoid a conflict between folder and executable
  name.

Pick-to: 6.9
Change-Id: Ic6188d96042e7b34eb3f423daf2b57290ca18a11
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-25 01:42:28 +01:00
Alexey Edelev
f9a05c7cae Make PlatformGraphics lookup QUIET
Let's do not litter user's logs with our internals.

Pick-to: 6.9 6.8
Change-Id: I79e9210960f1298a6e8e2b6f10e1bfefdbfede7f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-24 23:38:27 +01:00
Tomi Korpipaa
cf1f2361e7 Remove references to the deprecated QtCharts module
Task-number: QTBUG-133659
Change-Id: I3220c4f63c5ae00dbd1786daf8d09c07d8139a4c
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-02-24 16:06:17 +02:00
Kai Köhne
92b5980a7e Use ICU from Windows SDK for codec support (QStringConverter)
Windows has shipped a (limited) subset of ICU for quite a while:

  https://learn.microsoft.com/en-us/windows/win32/intl/international-components-for-unicode--icu-

The C API for this subset uses non-standard names for headers and lib
though, and is therefore not picked up by the ICU configure logic in
CMake.

This patch adds a separate configure test that enables the use of this
ICU API, specifically for text codec support in QStringConverter.
If a 'proper' ICU is enabled by the user, this still takes precedence.
Also, note that MinGW-w64 misses the respective Windows API, and will
therefore still use the old fallback.

[ChangeLog][QtCore][Text] Qt on Windows now uses the ICU API of the
Windows SDK for text codec support (if available and no 'full' ICU is
configured). This greatly enhances the list of supported text codecs
available.

Fixes: QTBUG-132056
Change-Id: Id02ae9f8cf56dee8c34795c0e60d2113f319bfd9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-24 15:05:01 +01:00
Michael Weghorn
71246cbdc6 QWizard: Drop obsolete sentence in QWizard::currentId doc
Commit 2140edaaab0bf61f354db521efca773568becc56 introduced
QWizard::setCurrentId that allows setting the property
directly, so drop the obsolete sentence in the QWizard::currentId
doc stating that this isn't possible.

Pick-to: 6.9 6.8 6.5
Change-Id: I5e7da2323e66a6e8bfd653dfebcba4363023b744
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-02-24 13:10:14 +00:00
Joerg Bornemann
6f1553774a CMake: Remove deprecated deployment API argument
[ChangeLog][CMake] The FILENAME_VARIABLE option of
qt6_generate_deploy_[app_]script, which was deprecated in 6.6.0, has
been removed.

Change-Id: I15bd4c121772d28014776398fa00769e8efeada0
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-24 07:37:21 +01:00
Thiago Macieira
fb2ef7e231 qEnvironmentVariableIntegerValue: remove arbitrary length limit
This commit removes all uses of getenv_s() (but not _wgetenv_s in
qEnvironmentVariable()), which is what was imposing the length
limit with qEnvironmentVariableIntValue(). We don't need to use
getenv_s() -- it's not more secure than getenv(). Microsoft could have
made them thread-safe, but the documentation for them[1] indicates they
are not.

[ChangeLog][QtCore][QtEnvironment] qEnvironmentVariableIntValue() is no
longer limited in the length of the number.

[1] https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/getenv-s-wgetenv-s

Change-Id: I95d97966c6da43b59a17fffdab2f904d78a62e9a
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-02-24 02:11:52 +00:00
Thiago Macieira
3fc00c4d5e qEnvironmentVariableIntegerValue: switch to 64-bit returns
[ChangeLog][QtCore][Editorial] Update previous statement on
qEnvironmentVariableIntegerValue to indicate it returns 64-bit.

Change-Id: I93fc5ca3455b2435bf95fffded69e086e038d14d
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-02-23 23:11:51 -03:00
David Faure
408959c8c8 Document the default value for QAbstractItemView::editTriggers
Pick-to: 6.9
Change-Id: I4456dcfcecf739299533167867208e1943bc4a26
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
2025-02-23 10:22:51 +01:00
Thiago Macieira
750be8ec51 QCborStreamReader: micro optimization: use constBegin() not constData()
Both QString and QByteArray's constData() have a check for null and
return the address of the corresponding _empty. constBegin() has no such
check and is therefore marginally faster because it could return null.

It will never in any of these conditions. Our internal buffer is never
empty at the places we're trying to get to its data; the params->string
and params->array have just been resized, so they are detached from null
even if newSize == 0. That leaves one case of a nullptr coming from the
user, in addData(), but QByteArray::append(nullptr, 0) works just fine
too.

Change-Id: I799e5c06638d393df793fffd502c25028c0f9c2e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2025-02-22 20:40:03 -08:00
Thiago Macieira
00f3ca950a CBOR: remove QT_X11_DEFINES_FOUND dead code
Amends commit be0f1af3f1829da0d321c12dbd40d5743d3b2eb5 ("CBOR: remove
the X11 True and False for good"), which removed the #define from the
top of the files, but didn't remove the checking of the macro from the
bottom of them.

Pick-to: 6.9
Change-Id: I92e76842a4117f6feed3fffdac2fcec01367101e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2025-02-22 20:39:57 -08:00
Thiago Macieira
4a4c425291 QT_TEST_EQUALITY_OPS: insert QCOMPARE before the current code
The macro, as it was, makes debugging REALLY hard:

FAIL!  : tst_QStorageInfo::operatorEqual()
 The computed value is expected to be equal to the baseline, but is not
  Computed (lhs == rhs)   : 0
  Baseline (expectedEqual): 1
  Loc: [qcomparisontesthelper_p.h(178)]

It prints the location of the macro helper, not the line that called it,
so one has to guess which of the many uses in a function has failed. And
it prints the boolean of whether the comparison result is the expected
value, not the values of left and right.

QT_TEST_ALL_COMPARISON_OPS also needs a similar fix, but I don't have
time for it. Ideally we'd replace the qScopeGuard with a proper QTest
failure report, which would extract the printers for Left and Right.

Pick-to: 6.9
Change-Id: I7a643066137c5fcdb9e7fffd83d9bf7cf4cccd6c
Reviewed-by: Rym Bouabid <rym.bouabid@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-02-22 17:33:54 -08:00
Ahmad Samir
9a83c2b88c QFileInfo: add isOther()
"Special" is interpreted similar to the logic used in
QDirListing::IteratorFlag::ExcludeOther. This also matches how
std::filesystem::is_other() is supposed to work except that in Qt .lnk
files on Windows are treated as "other".

[ChangeLog][QtCore][QFileInfo] Added isOther() method.

Fixes: QTBUG-133331
Change-Id: I2550fd37cd495b4593cacf704ce63da7d1c2addd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-23 02:46:48 +02:00
Ahmad Samir
c553f39e3d QDirListing: add ExcludeOther
Which is the same as ExcludeSpecial (the latter is new in 6.9). This is
to match std::filesystem::is_other() which has a similar functionality.
This makes it easier to remember/understand both APIs.

Amends e583c3d5163a5512abac85e32359652e28a053f7.

[ChangeLog][QtCore][QDirListing] Add IteratorFlag::ExcludeOther
enumerator. IteratorFlag::ExcludeSpecial now becomes an, obsolete, alias
for ExcludeOther (the name was changed to "other" to match the wording
used in std::filesystem::is_other()).

Change-Id: I986a2d822615f69ccf5ec283756ae063f5e18101
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-23 02:46:48 +02:00
Joerg Bornemann
3caf64adda Revert "CMake: Stop-gap fix for Qml user projects"
The issue was fixed by commit
3b0dab39d047cfc676a75915ce606cbd4d43a83d in qtdeclarative.

This reverts commit 4d95b6dccdd7772594bdb5f0c404585f16a4dc9c.

Change-Id: Ic7d78e740d1789a4ebd1d4c8c91d18846e005dfe
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-23 00:33:32 +00:00
Joerg Bornemann
bf272ce4ad configure: Support lists for the CMAKE_VARIABLE argument
One can now add configure options of type 'addString' to qt_cmdline.cmake
files like so:
    qt_commandline_option(device-option
        TYPE addString
        CMAKE_VARIABLE QT_QMAKE_DEVICE_OPTIONS
    )

Additionally, the type 'stringList', a semicolon-separated list, was
added:
    qt_commandline_option(qpa
        TYPE stringList
        CMAKE_VARIABLE QT_QPA_PLATFORMS
    )

This removes the need to call translate_list_input for such arguments in
QtProcessConfigureArgs.cmake.

Task-number: QTBUG-123064
Change-Id: I8216c84afaf9a15db09e41e731701bb567ea3828
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-23 01:33:32 +01:00
Joerg Bornemann
bf05a67db3 configure: Add type 'path' to qt_commandline_option
One can now add configure options of type 'path' to qt_cmdline.cmake
files like so:
    qt_commandline_option(prefix
        TYPE path
        CMAKE_VARIABLE CMAKE_INSTALL_PREFIX
    )

This removes the need to call translate_path_input for such arguments in
QtProcessConfigureArgs.cmake.

Task-number: QTBUG-123064
Change-Id: Ie2111d72f7fd637f2bbb9d7b049bf80ea9646b4f
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-23 01:33:32 +01:00
Joerg Bornemann
d9e9db65a3 configure: Make it easier to translate arguments to CMake variables
To add a configure argument that is translated to a CMake variable, one
can now use in qt_cmdline.cmake files:
    qt_commandline_option(foo
        TYPE boolean
        CMAKE_VARIABLE QT_FOO
    )

It's not necessary anymore to add a translate_boolean_input call to
QtProcessConfigureArgs.cmake. This is especially useful if a non-qtbase
module wants to add such configure arguments.

This patch adds the CMAKE_VARIABLE argument for configure options of
TYPE boolean and string. An attempt to use CMAKE_VARIABLE with other
types will result in an error.

Task-number: QTBUG-123064
Change-Id: I4c341e57993b729d08327cea57cf7c8a05c96c0e
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-23 01:33:31 +01:00
Christian Ehrlicher
bc06c7c61a SQLite: Update SQLite to v3.49.1
[ChangeLog][Third-Party Code] Updated SQLite to v3.49.1

Pick-to: 5.15 6.5 6.8 6.9
Task-number: QTBUG-132862
Change-Id: I544a7e2435315469fc174e2b2bf8c9ddbcf78c06
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-02-22 20:40:33 +01:00
Thiago Macieira
3b73bc463d QString: de-inline toStdString() so we can avoid a QByteArray temporary
We can simply write the UTF-8 string into the std::string buffer,
bypassing our temporary. And when Qt is compiled with C++23, we even get
resize_and_overwrite() support, removing the unnecessary memset() -
though the compiler might have been smart enough to suppress it (GCC and
Clang currently aren't that smart; in fact, GCC even generates code to
deal with a default-constructed std::string not being empty).

Change-Id: I3883268b30a9065757dcfffd6da4705a4aa44d7a
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2025-02-22 05:17:36 -08:00
Eskil Abrahamsen Blomfeldt
f846754663 Escape calculating vertical windows-metrics if they're too big
This amends 073fae097ce40bee1532c252a8c696840b5dfc16 which added
an escape before calculating the vertical metrics if they were too
big and would overflow. It missed one spot, which was when using
the winAscent/winDescent instead of the typo-metrics.

Pick-to: 6.9
Change-Id: Ib6a7705f6676c66bfd04b37efa30fe2d1b99581c
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
2025-02-22 00:23:17 +01:00
Kai Uwe Broulik
75ecb176df QScrollBar: Add createStandardContextMenu
Modeled after QLineEdit::createStandardContextMenu, allows customizing
the scroll bar context menu without re-implementing the entire menu.

[ChangeLog][QtWidgets][QScrollBar] Added createStandardContextMenu()
method to allow extending the built-in context menu.

Change-Id: I4f9feaba81a44a8c366b7341e0eb6934e9403a41
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-02-21 19:52:34 +01:00
Alexandru Croitor
a28a9e194c CMake: Rework SBOM PURL handling
Previously, only 3 purl entries could be added to a target, which
tightly coupled to Qt's needs: a QT one pointing to code.qt.io,
a MIRROR one pointing to github, and an upstream one pointing to some
upstream third party location.

Rework the implementation to allow for an unlimited number of PURL
entries and to allow more flexibility when adding PURLs in a user
project.

The new syntax for adding PURLs to a target, which is also the basis
for a future public API is as follows:

qt_internal_add_sbom(<target>
    PURLS
        [[PURL_ENTRY
            PURL_ID <id>
            PURL_TYPE <type>
            PURL_NAMESPACE <namespace>
            PURL_NAME <name>
            PURL_VERSION <version>]...]
    PURL_VALUES
        [purl-string...]
)

The PURLS keyword is used to specify multiple PURL entries, each
starting with the PURL_ENTRY keyword. The PURL_VALUES keyword is used
to specify a list of pre-built purl strings.

PURL_ID is an optional argument used to identify a specific purl
entry, which is mostly needed for Qt's needs, to post-process them
further.

The rest of the options are pre-existing from the previous
implementation.

Implementation-wise, there's a new custom parser to be able to parse
and validate PURL_ENTRY arguments.

The VERSION option was renamed to PACKAGE_VERSION, to avoid some
issues in cmake_parse_arguments parsing with nested VERSION options.

The NO_PURL option was removed because it makes no sense in the new
implementation, because if you specify some PURL arguments, there is
already an intention to generate a PURL entry.

Qt entities no longer have a restriction on which specific purl ids
they can have.

The new Qt specific purl IDs have been renamed:
- QT -> GENERIC
- MIRROR -> GITHUB

Amends f7e1123620b623be0c321b54eaba7a1d618a7ce1

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I050decece1c6d9e6e0e06547043f864d6f497ea7
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-02-21 15:57:17 +01:00
Alexandru Croitor
fd622bc3ae CMake: Move generic PURL function from qt-specific file to main one
Move generic PURL function from qt-specific file to main one. It was
mistakenly added to the wrong file during the initial split.

Amends f1ac316191c010b1389f6f3549c9f0b4424b9936

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I1884f53ee7d30a25b873d85ee04b8c8d1e0532f5
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-02-21 15:57:16 +01:00
Alexandru Croitor
e7cdf9d438 CMake: Move more Qt-specific SBOM PURL functions to the right file
The Qt specific functions belong in the
QtPublicSbomQtEntityHelpers.cmake file, not
QtPublicSbomPurlHelpers.cmake.

Amends f1ac316191c010b1389f6f3549c9f0b4424b9936

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: If5dd77672306c520404b294a6b5bde4f0e6ab8bc
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-02-21 15:57:14 +01:00
Wladimir Leuschner
a55db2cbee QWindowsTheme: Set highlight color to accent color in light mode
GetSysColor(COLOR_HIGHLIGHT) did not report the right highlight color in
light mode palette, Leading to a wrong accent color on
Windows. This patch uses the accent color analog to the dark mode
palette for QPalette::Highlight.

Fixes: QTBUG-130458
Pick-to: 6.9 6.8
Change-Id: If21f392e31c3187c28e871919ff17f417c8d144b
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-02-21 14:54:31 +00:00
Toni Saario
5be7a9773e Coin: Extend VxWorks restart matching to RTPLib errors
Running many tests on the VxWorks in the emulator without
restarting it between can cause exhaustion of some
resources and cause an RTP spawn fail in some tests.

This change will restart the emulator in such cases, which
allows the test to try again on fresh boot.

Pick-to: 6.9
Change-Id: I5ad715f243867d43b055271d6bc61ca4ccb3089b
Reviewed-by: Simo Fält <simo.falt@qt.io>
Reviewed-by: Michał Łoś <michal.los@siili.com>
2025-02-21 16:52:43 +02:00
Kai Köhne
6305ff33a9 Doc: Remove mentioning of qstringbuilder.cpp
The file is actually in src/corelib/text, and the majority
of the implementation is in the header file.

In any case, I don't think mentioning the name here is good
practice. Those who are a bit into Qt probably can find the
implementation quite easily themselves.

Change-Id: I7c7f0d655b55b509a830e92a02940f7b91df2dea
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: hjk <hjk@qt.io>
2025-02-21 15:10:21 +01:00
Marc Mutz
5cd046f154 tst_QCryptographicHash: remove remnants of BigData split
The ensureLargeData() and 'large' members were only used in BigData
tests that have since moved to a different executable.

Amends fff217824b532da7306af1ac755581e76e098a27.

Pick-to: 6.9 6.8 6.5 6.2 5.15
Change-Id: Idc99a868e082098dda4e1bee62470370c7e20f62
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-02-21 14:28:21 +01:00
Marc Mutz
2831ce613f QByteArray::remove(n,n): minor code cleanup
The result of d.begin() is only used in one of the branches, so
defining it outside both branches is a bit unmotivated; instead, drag
toRemove_start out of the else branch and reuse it in the then branch,
too.

Amends 358b7a9e747549f85c1d1631dfb21210b52b36f5.

Pick-to: 6.9 6.8 6.5
Change-Id: I162d72de7097a1257c8a0a01b69c36fc87466114
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-02-21 13:28:21 +00:00
Marc Mutz
60af93847e QByteArray: delegate to replace(char,char) from replace(QBAV,QBAV)
Don't go and build (among other things) a Boyer-Moore table for the
trivially optimizable replacement of single characters with single
characters. Just call the existing replace(char, char) overload.

Pick-to: 6.9 6.8
Change-Id: Ic69527bdaa5ce95bf937295366b94366e2ace933
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-02-21 14:28:21 +01:00
Marc Mutz
4308ab70ca QByteArray: don't recurse when needle or replacement alias *this
While the idea to delay the construction of the QVLAs until we know we
need them is elegant, we're doing a lot of checks twice or thrice this
way, so merely re-set the a, b pointers and otherwise continue
executing.

This requires us to default-construct the QVLAs before potentially
assign()ing to them, but that ought to be cheap, given the compiler
can see everything that's going on in QVLA.

Pick-to: 6.9 6.8 6.5
Change-Id: I4e42d5ab48711af91cc1785171524be5fb45ae2f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-02-21 13:28:21 +00:00
Marc Mutz
b93575de01 QLocale: fix UB (signed overflow) in formattedDataSize()
Coverity complains that qCountLeadingZeroBits() may return 64 and then
the RHS will be out-of-range for int. Of course, 64 leading zero bits
means that the argument is 0, which we excluded in the first `if` of
the if-else chain.

I can only guess (because it doesn't tell me which value of `bytes` it
is using for the analysis) that Coverity assumes bytes ==
numeric_limits<qint64>::min() and considers the overflow in qAbs() to
yield a 0, because, it being UB, it may yield anything.

Be that as it may, the fact remains that formattedDataSize() invokes
UB when passed numeric_limits<qint64>::min(), as confirmed by ubsan:

   global/qnumeric.h:479:26: runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself
   text/qlocale.cpp:5062:82: runtime error: signed integer overflow: -2147483648 * 3 cannot be represented in type 'int'
   text/qlocale.cpp:5062:26: runtime error: division by zero
   FAIL!  : tst_QLocale::formattedDataSize(English-Decimal-min) Compared values are not the same
      Actual   (QLocale(language).formattedDataSize(bytes, decimalPlaces, units)): "-inf bytes"
      Expected ("output")                                                        : "-9.22 EB"

So fix the overflow by using the new QtPrivate::qUnsignedAbs(). Then
sit back and await Coverity's verdict on the next run.

[ChangeLog][QtCore][QLocale] Fix issue when calling
formattedDataSize() with numeric_limits<qint64>::min().

Amends 9d23aebb271ea534a66cb3aceb2e63d9a1c870d6.

Pick-to: 6.9 6.8 6.5 6.2 5.15
Coverity-Id: 474294
Change-Id: I9a5a5acbdcf881a624bb827ca1dd970771f1bb6e
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-02-21 14:28:20 +01:00
Ulf Hermann
44118fcfef moc: Do not accept empty input files on --collect-json
... and also don't generate them on --output-json. That was an
invitation for build time race conditions.

Change-Id: I206ee47f08aa657f9b1cbec4e9e9b3ea97605cae
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-21 12:46:03 +01:00
Ulf Hermann
06b7a9b19e moc: Prefix messages from --collect-json with file names
Unless we're reading from stdin or writing to stdout, in which case
there are no file names.

Change-Id: I583fe2a77f54c5d62d965384a2c316f37a9b2fd2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-21 12:46:03 +01:00
Christian Ehrlicher
a47dc99079 QSqlTableModelTest: misc cleanup
Cleanup QSqlTableModelTest:
 - use pmf QSignalSpy ctor
 - use QCOMPARE/QCOMPARE_GE instead QVERIFY where possible
 - properly close additional databases so temporary folders created for
   sqlite can be deleted on exit

Pick-to: 6.9 6.8
Change-Id: I84e8960b81128c141a0e2cd6d03837c9b5ac6652
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-02-21 12:46:03 +01:00
Patrick Stewart
c9c8abb52d Close the Qt namespace even when QT_NO_TRANSLATION is defined
Pick-to: 6.9 6.8 6.5
Change-Id: I5e463b81f7e73b2946a0e3b3036a09de2105307b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-21 20:46:02 +09:00
Joerg Bornemann
ca407da21e configure: Fix implementation glitch
In the code block that transforms the global INPUT_* properties into
variables, there's a check that's supposed to guard already set
'commandline_input_foo_type' variables. However, the input name was
missing from the check, and we always called get_property.

Change-Id: I87b74726492c00a86e7c034c10e8dcf137f67082
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-21 08:28:26 +01:00
Joerg Bornemann
5971e94baf configure: Fix the -sbomdir argument
The argument must be added in qt_cmdline.cmake to work.

Pick-to: 6.8 6.9
Change-Id: Ic256c0fda0caf3794b37ad8c5e8b6515fb45b0e6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-21 08:28:24 +01:00
Thiago Macieira
9dc8bc80de QDirListing: std::exchange is <utility> not <memory>
The Clang analyser in Qt Creator was letting us know that <memory> was
unused in this header. Also, this is Include What You Need.

Pick-to: 6.9 6.8
Change-Id: Id7c260818f9e84847971fffda11da096169a0047
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-02-21 00:12:36 +00:00
Even Oscar Andersen
442e2f4aeb wasm: call focus on window if not editable
We used to call focus on the input element even for things
like pushbuttons.

This will display a keyboard on android, instead call
focus on the focus window.

Fixes: QTBUG-133781
Pick-to: 6.9 6.8
Change-Id: Ide4d6ec21a14f17b40d3d3de077c0ab073682f19
Reviewed-by: Lorn Potter <lorn.potter@qt.io>
2025-02-20 20:53:42 +01:00
Tor Arne Vestbø
8055a5c2db Build colormanagement manual test app as application bundle on macOS
Change-Id: Idf98eeacad5275b006615daaf53ea38a203307a1
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-02-20 20:11:36 +01:00
Tor Arne Vestbø
430ba7c0f8 iOS: Set LD_ENTRY_POINT for generated Xcode project
We normally override the entrypoint to _qt_main_wrapper via the -e flag
to the linker, but if a Swift file is added to the Xcode project, Xcode
does some magic, building the app as a shared library, and wrapping it
with the Swift code into a custom executable. The -e flag will then be
a noop when linking our shared library.

To work around this we set the custom LD_ENTRY_POINT Xcode build setting,
which triggers Xcode to pass -e when linking the wrapper-executable.

This works in practice, but produces a warning on the console that the
entrypoint is not found, which has been reported as FB16519113.

Fixes: QTBUG-133577
Pick-to: 6.9 6.8
Change-Id: I9d8310b39ac5a4900693df55c2e5bfa346c0300a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-20 20:11:35 +01:00
Wladimir Leuschner
564633f9d4 QWindows11Style: Add horizontal offset for Qt::AlignVCenter Labels
The progressbar label overlaps with the progressbar grove, when
vertically centered aligned. This patch adds a y offset to the
label, in case it is vertically centered to avoid the overlap.

Fixes: QTBUG-128458
Pick-to: 6.9 6.8
Change-Id: Iac977f83f09c2e4d12d1e0ed5f0eab3120c07b96
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2025-02-20 17:36:04 +00:00
Marc Mutz
3070efb64a QCbor/JsonValue: add toStringView()
This is like toString(), but returns a view on the underlying string
data (which may be US-ASCII (= L1), UTF-8, or UTF-16, so the return
value is QASV).

Use it around the code a bit.

Benchmark results on my machine (with -perf -iterations 1000):

  PASS   : BenchmarkQtJson::iteratorKey()
  RESULT : BenchmarkQtJson::iteratorKey():
     78,268.426 nsecs per iteration (total: 78,268,427, iterations: 1000)
     349,458.080 CPU cycles per iteration, 4,46 GHz (total: 349,458,080, iterations: 1000)
     780,327.957 instructions per iteration, 2,233 instr/cycle (total: 780,327,957, iterations: 1000)
     173,511.019 branch instructions per iteration, 2,22 G/sec (total: 173,511,020, iterations: 1000)
  PASS   : BenchmarkQtJson::iteratorKeyValueView()
  RESULT : BenchmarkQtJson::iteratorKeyValueView():
     58,424.756 nsecs per iteration (total: 58,424,756, iterations: 1000)
     267,176.603 CPU cycles per iteration, 4,57 GHz (total: 267,176,604, iterations: 1000)
     614,805.388 instructions per iteration, 2,301 instr/cycle (total: 614,805,389, iterations: 1000)
     140,681.105 branch instructions per iteration, 2,41 G/sec (total: 140,681,106, iterations: 1000)
  PASS   : BenchmarkQtJson::iteratorKeyView()
  RESULT : BenchmarkQtJson::iteratorKeyView():
     44,060.925 nsecs per iteration (total: 44,060,925, iterations: 1000)
     196,344.233 CPU cycles per iteration, 4,46 GHz (total: 196,344,233, iterations: 1000)
     426,631.322 instructions per iteration, 2,173 instr/cycle (total: 426,631,323, iterations: 1000)
     93,703.100 branch instructions per iteration, 2,13 G/sec (total: 93,703,101, iterations: 1000)
  PASS   : BenchmarkQtJson::iteratorKeyViewValueView()
  RESULT : BenchmarkQtJson::iteratorKeyViewValueView():
     29,205.569 nsecs per iteration (total: 29,205,570, iterations: 1000)
     131,089.040 CPU cycles per iteration, 4,49 GHz (total: 131,089,041, iterations: 1000)
     258,529.469 instructions per iteration, 1,972 instr/cycle (total: 258,529,469, iterations: 1000)
     60,875.631 branch instructions per iteration, 2,08 G/sec (total: 60,875,631, iterations: 1000)

[ChangeLog][QtCore][QCborValue/QJsonValue] Add toStringView() method.

Fixes: QTBUG-133688
Change-Id: I4200035e995426f1cce46a73a429921a0cd56c85
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-20 18:02:45 +01:00
Thiago Macieira
3e1dffd5dd QObjectPrivate: extend the QObjectPrivateVersion to a few more classes
To QtNetwork and QtGui too.

This isn't about their loading of QtCore, but about other libraries
loading of them.

Change-Id: I94ef6a59c321271f939efffdde360657417ae35e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2025-02-20 09:00:58 -08:00
Eirik Aavitsland
3d389ee2ac Windows: Fix rounding error in BitmapInfoHeader calculation
A potential rounding error in calculating the padded scanline length
could lead to the biSizeImage field being assigned a too small value.

Fixes: QTBUG-133782
Pick-to: 6.9 6.8 6.5
Change-Id: I251212cf2859f7268fc8ad6ca1cbc57f2bb1f1c0
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2025-02-20 18:00:58 +01:00
Alexandru Croitor
4174f388e6 CMake: Avoid warnings _qt_internal_sbom_replace_qa_placeholders
We should only pass the VERSION option if we have a value to pass.

Fixes warnings like the one below when using CMake 3.31:

CMake Warning (dev) at cmake/QtPublicSbomAttributionHelpers.cmake:511
(cmake_parse_arguments):
  The VERSION keyword was followed by an empty string or no value at
  all.
  Policy CMP0174 is not set, so cmake_parse_arguments() will unset the
  arg_VERSION variable rather than setting it to an empty string.
Call Stack (most recent call first):
  cmake/QtPublicSbomHelpers.cmake:954
  (_qt_internal_sbom_replace_qa_placeholders)

Amends bc3bbb51b7b48d3c4a44a432441938863582242c

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I671a9153d72b21b6aed2112bea45f577a5cee4eb
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-02-20 18:00:57 +01:00
Mate Barany
f6a5c7e011 Do not keep the headers and message body in case of temporary redirect
The implementation of GET requests with body (QTBUG-112871) keeps the
body after it has been redirected. However, in case of temporary
redirect (status code 307) this seems to be an incorrect behavior.

Reset the headers and the body in case of temporary redirect.

Pick-to: 6.9 6.8
Change-Id: I10be702b017a42cca27a37dfe2249da2f59c0328
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-02-20 16:12:19 +01:00
Eskil Abrahamsen Blomfeldt
1d6f71779f Accept multiple fonts with the same family and style name
When the style name is included in the request to
QtFontFoundry::style(), then it will ignore the other properties
and just return the hit that matches it. This is because we want
the style name to take precedence over all other properties when
the user specifies it in a request.

However, we were using the same function to check if a specific
font already exists. If we are registering a font and it is
already in the database, we want it to replace the existing one.
But for fonts such as the variable "Noto Sans Display" there would
actually be multiple styles in the family that were called the
same ("Regular") but had very different properties.

Due to how fonts are populated on GDI, this issue did not occur
there, so the issue is perceived as a regression in Qt 6.8 when
we switched to DirectWrite as the default backend.

We fix this by ignoring the style name when checking if the font
already exists and instead prioritizing the specific properties
it has. If multiple different styles with the same name exists,
they will all be registered.

Note that it will not be possible to differentiate between the fonts
using the style name, same as before, but you will now at least
be able to select the different styles by specifying properties
such as weight.

[ChangeLog][QtGui][Fonts] Fixed an issue with font families where
only the last of multiple sub-families sharing the same name would
be registered.

Pick-to: 6.8 6.9
Fixes: QTBUG-131574
Change-Id: I86a04547065c2d9ef88d9a761af95af33eb9b3d6
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
2025-02-20 08:26:37 +00:00
Thiago Macieira
eb87b0444a QVariant: don't use the static CanUseInternalSpace with existing objects
It's possible for the QVariant to have been created by an older or newer
build of the library in question in which the type in question was
relocatable but has ceased to be, or wasn't relocatable but now is.

[ChangeLog][QtCore][QVariant] Fixed a bug where QVariant could misbehave
regarding types that changed from non-relocatable to relocatable (or
vice-versa) and not all uses of it were recompiled. To benefit from this
fix, applications must be recompiled, but they will be safe going
forward.

Pick-to: 6.9 6.8
Change-Id: I222806b3804df6272abdfffd45f96312d23be1af
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-02-19 17:43:59 -03:00
Frédéric Lefebvre
6ea2657ad5 Skip tst_QDialog::keepPositionOnClose on Linux as meant for Windows bug
The auto-test tst_QDialog::keepPositionOnClose() was meant to verify a
bug relating to Windows. It is flaky on Linux Opensuse and flakes when
it should be passsing.

QSkip this test, as it was written to cover the QTBUG-79147 on Windows
and is flaky on Opensuse 15.

Fixes: QTBUG-133825
Change-Id: If06bef395248071779bcee234dbb0476ab1ef711
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-02-19 18:43:43 +00:00
Eric Beuque
50d1a22e5c Fix bad signal restoration which can cause infinite loop
This fix the FatalSignalHandler destructor to restore properly the
signal handler which cause an infinite loop when a signal is emitted
like SIGABRT or SIGINT and when we are using two QTest object in same
program.

Fixes: QTBUG-132121
Pick-to: 6.9 6.8 6.5
Change-Id: Ie9476e1ff9c0f29c3e35ae6dff565fab4a77ba86
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-19 19:13:58 +01:00
Wladimir Leuschner
c3d2a4972c QWindows11Style: Use Highlight color for ItemView with alternating rows
When using alternating rows in ItemViews, the currently selected item is
hard to distinguish from the background colors. This patch uses for
ItemViews with alternating row colors the highlight color for the
selected and hovered item.

Fixes: QTBUG-133118
Pick-to: 6.9 6.8
Change-Id: Ib5dbe0f58d5970c41cc9d14cf2188a7e5b1abd1a
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-02-19 18:14:05 +01:00
David Boddie
c08ca6ff02 doc: Remove link to missing showShaded() function
Pick-to: 6.8 6.9
Change-Id: I8a70558521a6829e0bd99f03a7aa695681061945
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-02-19 18:14:04 +01:00
Assam Boudjelthia
bcbb1701ab Revert "Android: update to Gradle 8.12 and AGP 8.8.0"
This reverts commit 0e4f9ffa55c2b77fbe79e96362bc68a968982b48.

Reason for revert: temporarily revert it to pass submodule
update round.

Change-Id: I2df4b76c0c3445d340bb0b11686e624f13d7fd3b
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2025-02-19 17:03:45 +00:00
Edward Welbourne
44ddb34da0 Fix UB in QTextStreamPrivate::putNumber()
Negating a negative value may attempt to negate the minimal value for
the signed type, whose only set bit is its sign; this is UB. So don't
do that. Since the non-decimal branch of the code just prepends
locale.negativeSign(), and we're passing -1 as width parameter to the
QLocalePrivate formatters (so there's no zero-padding, whose size
would be reduced to make space for a sign), we can treat decimal the
same as all other bases. This, furthermore, simplifies the code.

In the process, I noticed (because a test only done for decimal
failed) that if QTextStream::ForceSign is set, this code-path for
negatives would prepend the minus sign before a plus sign supplied by
QLocaleData. Skip the flag to include sign, for negative input, since
we'll be including a negative sign anyway. Remove the QEXPECT_FAIL()
from the test I've added for this in a preparatory commit.

Purge one now-redundant comment and revise some others. Expand on why
we need to hack octal zero to display two zeros. Add a second test row
to keep the lonely zero-row company in the test for that.

Fixes: QTBUG-133269
Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I35c9bdf34b812cff578de9b0a2570a60e6145c80
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-19 17:03:45 +00:00
Edward Welbourne
82ae262de2 Avoid returning null from find{Next,Prev}InOrder(non-null)
The checkNode(p) call relies on p being non-null, so CodeChecker
grumbled. In any case, we should be returning node_impl if we fall off
the end of the structure (which shouldn't be possible, since we
descended into the three and can't come back out on the way up without
passing through node_impl, for which we check). Include a null-check
in checkNode(), save the nsURI.isNull() check when !p->isElement()
makes it redundant and fix some coding style nits while I'm about it.

Amends commit 8609982791928a30a6d836b25810143a064f8c6f

Pick-to: 6.9
Coverity-Id: 474724
Coverity-Id: 474725
Coverity-Id: 474726
Change-Id: Id622a91d2e443276756e50729cf155b10f7164a1
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
2025-02-19 18:03:45 +01:00
Cristian Le
97517b20aa Fix: Use _qt_internal_set_source_file_generated
`SKIP_AUTOGEN` was a bit too zealous.
Hotfix for 6865c21e41be5d86b5a04889bfe28fac55c89f29

Fixes: QTBUG-133850
Pick-to: 6.9
Change-Id: I6ec984a7a5d8eefb56e53a0f56c4f4384a56e0ae
Reviewed-by: Nicolas Fella <nicolas.fella@kdab.com>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-19 17:44:41 +01:00
Marc Mutz
562cb8e4d9 tst_QLocale: actually check formattedDataSize() with qint64
... not just int, and not just non-negative values.

Reveals a problem with bytes == numeric_limit<qint64>::min(), says
ubsan (example; all min64 fail):

    global/qnumeric.h:479:26: runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself
    text/qlocale.cpp:5062:82: runtime error: signed integer overflow: -2147483648 * 3 cannot be represented in type 'int'
    text/qlocale.cpp:5062:26: runtime error: division by zero
    FAIL!  : tst_QLocale::formattedDataSize(English-Decimal-min) Compared values are not the same
       Actual   (QLocale(language).formattedDataSize(bytes, decimalPlaces, units)): "-inf bytes"
       Expected ("output")                                                        : "-9.22 EB"

So exclude that from testing, for now.

Pick-to: 6.9 6.8 6.5 6.2 5.15
Coverity-Id: 474294
Change-Id: Ia1f8e87c58a9fdc2668b6745956e913384cff4c7
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-02-19 17:44:41 +01:00
Marc Mutz
24a26ed3a3 QBenchmarkPerfEvents: help Coverity understand the code
Coverity thinks that r may be negative and not -1 and warns that the
cast to quint64 may overflow.

Change the check for `== -1` to `< 0` to help Coverity (and other
readers of the code) understand that this cannot happen.

Amends c63420a117fe67107466d806890e901d091cb1d5.

Pick-to: 6.9 6.8 6.5 6.2 5.15
Coverity-Id: 474172
Change-Id: I7615e0ef152e1e6e9cbc6dec1b8ecd4f8879521c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-19 16:44:41 +00:00
Rym Bouabid
01fc6aeaff Add a generic container-joining algorithm qJoin()
Introduce a generic container-joining algorithm, qJoin(), to
qalgorithms.h. qJoin() combines the elements of a container
into a single result such as a string separated by a specified
'Separator'. Optionally, elements can be transformed using a
projection function.

Add tests and documentation.

[ChangeLog][QtCore][QtAlgorithms] Added qJoin().

Task-number: QTBUG-64318
Change-Id: Ia9abd45645fbbbcc87ff3e5474878609398d9eb6
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-19 15:50:26 +01:00
Marc Mutz
929466ba64 tst_QCryptographicHashBigData: skip Sha1 tests on ASAN CI builds
The SHA-1 test has started to time out in CI ASAN builds recently, so
skip it there. Keep it on non-CI or non-ASAN builds, though.

Amends c6e092a5f84b7fc72556897b50c7697152967925.

Pick-to: 6.9 6.8 6.5 6.2
Change-Id: I8d653c2a8304cfae290befafda570d5c49dd4536
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-02-19 15:50:26 +01:00
Eirik Aavitsland
90247966a7 QPainterPath: Add option to cache calculations
Speeds up repeated calls to length and percentage functions.

Change-Id: I357732e35de648e7da07ad492e58d5b94c2c0870
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-02-19 15:50:26 +01:00
Eirik Aavitsland
76b1424048 QPainterPath: Make the private class a bit more compact
Rearrange the data members and avoid spending a whole int to store the
1 bit of fillrule information, when it instead can be part of an
already existing bitfield member. Saves 8 bytes.

Change-Id: I2013ff076e38b2bcd414665a2d5aa528f3632670
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-02-19 15:50:26 +01:00
Eirik Aavitsland
ff7221c677 QPainterPath: Extend autotests for length and percentage functions
Also add a benchmark test for them.

Change-Id: Icc44f54786048550d0a96fd0d1acd3801eaca132
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-02-19 15:50:26 +01:00
Eskil Abrahamsen Blomfeldt
c136de2deb Fix divide by zero when opening font on invalid image
If you open a QFont on an invalid image, its dpi will be 0. In
other places we check for this before calculating the point
size, but this was missing in one spot, causing divide by
zero.

This would happen e.g. in the tst_QFontMetrics::same() test.
While it would pass normally, running this with an undefined sanitizer build would warn about the division by zero.

There's nothing useful we can do with the fonts on the invalid
image, so like in the other places, we just leave the point size
as is when this happens.

Pick-to: 5.15 6.5 6.8 6.9
Change-Id: I4769e23e2b4dbb92f675cb8a77f8554c90bc2afd
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
2025-02-19 11:16:48 +00:00
Konsta Alajärvi
83a4128ecb Unblacklist tst_qrhi renderToTextureSampleWithSeparateTextureAndSampler
Unblacklist test function by skipping it with Android with Vulkan.

Fixes: QTQAINFRA-6335
Pick-to: 6.9 6.8
Change-Id: I2ee093542f09f68044baa044b697a09af066fcd8
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Lauri Pohjanheimo <lauri.pohjanheimo@qt.io>
2025-02-19 07:40:32 +00:00
Vladislav Tarakanov
a77173486a QCupsPrintEnginePrivate: Use "true" for "landscape" option
CUPS treats the "landscape" option as a boolean value
(IPP_TAG_BOOLEAN). In this case, all values ​​other than "true", "on" and
"yes" are considered as false. As a result, using an empty string as the
value for the "landscape" option results in the print area still being
portrait.

Currently, the problem with printing landscape images (png, jpeg, etc.)
in Qt programs (e.g. Okular, Gwenview) occurs on Fedora 41 and other
distributions using cups-filters v2.0+.

The patch adds passing the value "true" instead of an empty string for
the "landscape" option, as CUPS expects for changing the orientation.

Pick-to: 6.9 6.8
Change-Id: Ib7ad1e2debcfff10e673757c97ef5614fb59a6ca
Reviewed-by: Albert Astals Cid <aacid@kde.org>
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
2025-02-19 02:15:55 +04:00
Axel Spoerl
d0cb3c0acd Correct childNumber() reference in editable tree model example
childNumber() has been renamed to row() in the code, but not in
the documentation.
Correct it.

Pick-to: 6.9 6.8 6.5
Change-Id: Ibe6f1f27c0dd1982ff663dc680738babf2db87d7
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2025-02-18 21:43:55 +00:00
Topi Reinio
3336422289 Doc: Ignore 'Unknown base <type> for QML type' warnings for now
These warnings are false positives when testing in the CI
when a documentation module containing the  base type is meant
to be loaded as a dependency; In the CI, the .index files for
doc dependencies are not available so we see this warning.

Ignore these warnings for now in the global documentation config.

Pick-to: 6.9 6.8
Change-Id: Ic1711bf7389e9f9d4a04e3b72b2c9f8b25539357
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2025-02-18 20:05:13 +00:00
Thiago Macieira
fd857d400a QThreadStorage: don't print the destruction ordering warning on app exit
This warning here was very confusing (so I'm also updating the language
to be clearer what it means). It is here to advise users of
QThreadStorage that they may have destroyed the object before all
threads using the object have finished. That means there will be memory
leaks, hence the user should fix the issue.

But the one time we don't care (too much) about memory leaks is when the
application is about to exit -- all memory is being released back to the
OS anyway. This may happen because of Static De-Initialization Order
Fiasco: the Q_GLOBAL_STATIC or equivalents holding QThreadStorage were
destroyed before the QThreadData for the exit()ing thread did. That
problem became more prevalent after the series of changes ending in
commit 2f69a05bd0cd7ce63890f709ff3ed7a4f78acd70, because that made the
QThreadData clean up happen very late in the execution.

Unfortunately, there's no way for us to know when we're being called
during application exit, so this is the next best thing:
QCoreApplication::instance() does not exist. We're using a private
function in QCoreApplication because in Qt 6.x, QCoreApplication::self
is not atomic and reading it would be a data race.

The QThread::currentThread() call was superfluous, because it was always
true. It was a relic from Qt 3, from before we had QAdoptedThread.

Pick-to: 6.8 6.9
Fixes: QTBUG-133500
Change-Id: I48d84d76f2b72483ed92fffdd54c6ad17e3d67d3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-18 12:04:21 -08:00
Alexey Edelev
7a6b3e1a9c Ensure <target>_copy_apk_dependencies is called for QtC build
QtC doesn't use the make_[apk|aab|aar] targets, it runs the deployment
manually. The top-level android build target for QtC is the
<target>_prepare_apk_dir target. Make it depending on
<target>_copy_apk_dependencies target, to ensure that all abi-specific
artifacts are copied before running the deployment procedure, from
either QtC or command line.

Amends 44149f9d8b62b5343a5d06628b0c9588f035ccc2

Fixes: QTBUG-133810
Fixes: QTBUG-131862
Pick-to: 6.8 6.9
Change-Id: I4f3630798658a793b0c96a99fc4644ec1dd0504b
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-18 21:04:21 +01:00
Alexey Edelev
4d6a2850ad Mention QT_ANDROID_MULTI_ABI_FORWARD_VARS in QT_ANDROID_BUILD_ALL_ABIS docs
Help users to navigate in docs.

Pick-to: 6.5 6.8 6.9
Task-number: QTBUG-107893
Change-Id: I95774e03ba4027dad82ba652b3f119f19b9d6760
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-18 21:04:21 +01:00
Thomas Moerschell
c093b57c86 QScroller: Remove workaround for timer start
The CI is flakey, likely due to missing timer events. Instead of
skipping the first event, start the timer only when the new state has
been set.

Task-number: QTBUG-30133
Pick-to: 6.9 6.8
Change-Id: Ia58e4b091d8791d1b77642ded67312bc3927d0b7
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-02-18 20:14:42 +01:00
Alexandru Croitor
52a64aca20 CMake: Add project supplier to generated source SBOM
Make sure to specify the creator organization when calling reuse to
generate the source SBOM.

This replaces
  'Creator: Organization: Anonymous'
with
  'Creator: Organization: TheQtCompany (https://qt.io)'

Pick-to: 6.8 6.9
Fixes: QTBUG-133796
Change-Id: I3532d9f35ca3eacd9c20bee7db88f35c76db9672
Reviewed-by: Lucie Gerard <lucie.gerard@qt.io>
2025-02-18 19:54:45 +01:00
Michael Cho
7a31e402f2 CMake: Add support for pkg-config files on macOS
This enables generation of pkg-config files that work with Qt's
libdir-installed macOS frameworks. QtFinishPkgConfigFile.cmake
wasn't modified as POSTFIX has no impact on framework name.

Pick-to: 6.9
Change-Id: I2da8f43608e778aa286ad625b70c5be20b447193
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-18 13:54:45 -05:00
Ulf Hermann
8f5c6434e8 Doc: Clarify need to qt_add_standard_project_setup early
Pick-to: 6.9 6.8
Fixes: QTBUG-115050
Change-Id: If8b3aabd0072bfb2bef6dea106af06524f144990
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-02-18 19:54:44 +01:00
Assam Boudjelthia
f18f50a8be Android: fix Quick for Android density
Amends 060a65f6c8c6b2e5528cb3cc91e7bba969d52a4f, which seems to make
Quick for Android apps show content with big sizes, the quickest fix
is to partially revert to the previous behavior while still have the
calls to update density, orientation and refresh rate under one
common method under QtDisplayManager.

Fixes: QTBUG-133754
Change-Id: I9a3791354cc6d425f858a6d1d7075ec8ddae8eb3
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-02-18 20:54:44 +02:00
David Boddie
3c4ec4de14 doc: Fix a couple of typos that cause broken links
Pick-to: 6.8 6.9
Change-Id: I7f9aafa12d98475fc28230fcb25ba6a4570889aa
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
2025-02-18 19:27:24 +01:00
Vlad Zahorodnii
71fc85f594 Client: Fix potential file descriptor leak
Qt doesn't use the ICC file information, but the file descriptor should
be still closed.

Change-Id: Ib793e7cc12dbd7dd338c4ab4528c17f30e48abcd
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-02-18 17:50:00 +02:00
Lucie Gérard
e5fab54e54 Correct doc/images licensing
Pick-to: 6.9 6.8
Change-Id: I202366f8294920fa4ac15f95a4352d5c56c1a6cd
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-02-18 13:58:26 +01:00
Matthias Rauter
2c15086b7e Silence warning in tst_qwidget.cpp
Amends: 1a0f056f318417ba5e54c8110257b75cf5537acb

Pick-to: 6.9 6.8
Change-Id: Ib67016bbb7d5abe48224d23d49e36e2e01e416fc
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-02-18 11:41:13 +00:00
Matthias Rauter
9ea1417e83 Untangle a confusing sentence in the doc
Change-Id: Ia360a0cf7944f7f1101ab38da229b0ca2d7d2f26
Reviewed-by: Mate Barany <mate.barany@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-02-18 12:41:13 +01:00
Wladimir Leuschner
369be48510 Windows: Check for bitmask instead for equality for initial window flags
fixTopLevelWindowFlags uses a equality comparison for the initial window
flags fixup. In case window flags are set before creation, this equality
will fail and no initial window flag fixup will happen. This patch
changes the equality comparison with a test for bitmasks.

Change-Id: I5a18f37376af5cc72f5ee7a3365970ca7fd51b66
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-02-18 12:41:13 +01:00
Morteza Jamshidi
ee942d7ab4 Windows: Fix title bar artifact for frameless windows after restoring
If windows is frameless we don't let windows os handle WM_NCACTIVATE event.

Fixes: QTBUG-127116
Change-Id: I90f6a394018d0b275c77d319f0dc6fe93707694e
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-02-18 12:41:13 +01:00
Giuseppe D'Angelo
72cde6f7dd qcompare_impl.h: include what you use
Both enable_if and is_null_pointer belong to type_traits, include it.

Amends 631a0cc45cbe70940746cd944d325d7d3bab8c15.

Pick-to: 6.9 6.8
Fixes: QTBUG-133808
Change-Id: I9626ba80b2d9799d1bfed8ca9c9090691b8d8715
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-18 08:54:28 +01:00
Thiago Macieira
1040728e39 GUI: no need to unregister input device if list is destroyed
Fixes: QTBUG-133776
Pick-to: 6.9 6.8
Change-Id: If4a148e3ebf753ccd661a5ed1b321dbd7751576e
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-02-18 02:03:13 +00:00
Marc Mutz
2753924fcb QByteArray: optimize replace(char, char)
Write every byte only once.

Amends 83c2c5055405f09043c35b93cd5ba9b9969f3174 (as well as the start
of the public history).

Pick-to: 6.9 6.8
Task-number: QTBUG-106185
Change-Id: I883b2f00c754806882131a09dc3cbc5613420151
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-02-18 00:24:00 +01:00
Kai Uwe Broulik
4396c96f1e Add Qt::Key_Keyboard
Adds a "media key" for the "Keyboard settings" key
found on some laptops.

Change-Id: Id041a551844f095f1d7d2fd25d37346da30407a3
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-02-17 22:17:08 +01:00
Lauri Pohjanheimo
2f23b0cd9c SwiftShader sw check added to enable tests on hardware
On CI an Android emulator with SwiftShader software graphics
implementation is used. SwiftShader implementation is unable
to emulate this OpenGL functionality.

QSKIP the test if it is run in Android platform,
OpenGL and SwiftShader sw graphics implementation is found.

Task-number: QTQAINFRA-6333
Task-number: QTQAINFRA-6334
Change-Id: I560aa796e7f364e645ebb41f89120673a0f59a5b
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-02-17 23:00:52 +02:00
Christian Ehrlicher
6a46395614 Windows11Style: don't modify palette for buttons in polish()
There is no need to screw up the palette of buttons in polish() - the
colors are not honored at all.

Pick-to: 6.9 6.8
Task-number: QTBUG-132433
Change-Id: I4df1f046690d1aa9b07fc538441d6ea50d0216ce
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2025-02-17 20:21:02 +01:00
Frédéric Lefebvre
21ef8bed6d Harden tst_QWindow::framePositioningStableAfterDestroy()
StablePosition was in some cases recording a wrong position, as it was
taking the framePosition and considering it to be the widget's
position. That erroneous position was then used to place the window,
resulting in a correct position but a wrong framePosition.

Wait and check for the window.geometry() and the
window.frameGeometry() to be different. If not the frame
has not been updated, or there is no frame when there
should be one. The test will most likely fail because
of this.

Fix flakiness on Opensuse 15

Pick-to: 6.9 6.8 6.5
Change-Id: I8e05ee7769de4efc2ac55ec7afbe366f76e325db
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-02-17 18:20:14 +01:00
Shawn Rutledge
280025fc7e doc: Add QTextDocument::MarkdownFeature docs
Detailed docs were omitted before (and QTextMarkdownImporter::Feature is
not public) because
- "GitHub dialect" is a moving target (although we may have supported
  all known features when it was introduced). We should reserve the
  right to add to the feature set accordingly: so the numeric flags
  can be expected to change.
- the writer mostly ignores the feature flags and writes back to
  GitHub dialect; only the front matter can be omitted that way
- recognizing non-URL links seems fuzzy; md4c does it, so we allow that
  feature, but if it goes wrong it would be an md4c bug
- hex flags look strange: in fact they come from
  https://github.com/mity/md4c/blob/master/src/md4c.h#L306
  If we assume that they might change, it would be better not to
  document the numeric values in detail. But so far, md4c has never
  removed any, only added a few (and we don't yet support all the
  new ones).

Change-Id: I6552da1226bf7ad6242432c1d5d3df9ec8f61d6f
Pick-to: 6.9
Reviewed-by: David Boddie <david.boddie@qt.io>
Reviewed-by: Tommi M. Tauriainen <tommi.m.tauriainen@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2025-02-17 16:44:31 +01:00
Cristian Le
95f712c6cc Change the GENERATED property of module export header
Use a more specific property

Change-Id: I68702fd66902273b108f7f207f583f73693087ed
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-17 16:44:30 +01:00
Cristian Le
3f31f210d5 Use _qt_internal_path_is_prefix
Change-Id: I3eeb514c33340956328eff33409dfa2899023eb5
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-17 16:44:30 +01:00
Cristian Le
0630f055b8 Add _qt_internal_path_is_prefix compatibility
Direct equivalent to `cmake_path(IS_PREFIX)` except for `NORMALIZE`
support.

Change-Id: Ic17990b93d458073ddc1b860a7f5d5b81bd63ea8
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-17 16:44:30 +01:00
Cristian Le
6865c21e41 Use _qt_internal_set_source_file_generated
Migrate implementations that set `GENERATED` source property

Task-number: QTBUG-125077
Pick-to: 6.9
Change-Id: Ia77ecf8422bf3983f7746c26e5a9994d1f6415f2
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-17 16:44:30 +01:00
Cristian Le
f654519c7b Add _qt_internal_set_source_file_generated function
Create a function `_qt_internal_set_source_file_generated` that sets the
source file property `GENERATED` along with Qt relevant properties:
- `SKIP_LINTING` if CMake>=3.27 and `QT_FEATURE_lint_generated_code`

Task-number: QTBUG-125077
Pick-to: 6.9
Change-Id: I0ef5f7901f502366aaf2d020554c72e4845101b6
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-17 16:44:30 +01:00
Alexandru Croitor
414b73075c CMake: Add internal API to check if json SBOM generation deps are met
Will be used by WebEngine configure checks to check if the
dependencies are met and show an according error message if not.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I56d46fe5cf12051903d1aec893336be5ae8983a2
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-02-17 10:56:34 +01:00
Alexandru Croitor
8b6b17ae87 CMake: Make sure to look up deps when converting json to tag SPDX doc
When converting a json SPDX document to a tag/value SPDX document, we
need to make sure that the python dependencies are looked up.
After they are looked up, either error out or silently return
depending on whether the operation is required or not.

By default when _qt_internal_sbom_generate_tag_value_spdx_document is
called it is required to succeed and thus requires the python
dependencies to be present. A caller can opt out using the OPTIONAL
argument.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: Iccb68f900f4892a816360843dd87f9e469104bf7
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-17 10:56:33 +01:00
Alexandru Croitor
ad82afb054 CMake: Improve error reporting about missing SBOM dependencies
Improve wording when python or some dependency is missing, deduplicate
the strings and make sure to mention what is actually missing.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I26af38f0330a5462c6001cae03c46284e742fbda
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-17 10:56:32 +01:00
Alexandru Croitor
46ee11a426 CMake: Always save SBOM python interpreter path
To ensure that when we find the interpreter, but not some python
dependency, we actually show the error about the dependency.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: Ib4f42e04f071f800d0f5bbe3700a1208e1017a19
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-17 10:56:30 +01:00
Alexandru Croitor
37e85c0ff3 CMake: Fix getting target property from Tools-only packages
A call to find_package(Qt6 COMPONENTS LinguistTools) would fail with
CMake Error at Qt6Config.cmake:212 (get_target_property):
  get_target_property() called with non-existent target
  "Qt6::LinguistTools".

Tools packages don't have a module, guard the get_target_property
call.

Amends a9c18e5df240ce4a8bdc4dd3e7b8d5289227d2d9

Change-Id: Idb70b427d0762ed64c2ef77133a2ae56f310483d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-02-17 10:53:55 +01:00
Alexandru Croitor
fcb2058631 CMake: Work around upstream AUTOGEN issue with discarded dependencies
Upstream CMake has a nasty bug where AUTOGEN dependencies are
discarded if a library is added as a dependency more than once (or
rather the number of times it is added is not equal to the number of
configured build configs).

This can result in racy build failures, where a <module>_autogen
target is supposed to depend on some <other_module>_sync_headers
target, but doesn't, and thus moc generates empty metatypes files
because it can't find a synced header.

To avoid the AUTOGEN dependencies from being discarded, manually
add all dependencies passed to qt_internal_extend_target to the
AUTOGEN_TARGET_DEPENDS property.

The issue is fixed in CMake 4.0, so the workaround is gated on the
cmake version used. Add a flag called
QT_NO_AUTOGEN_DISCARDED_DEPENDENCIES_WORKAROUND to disable the
workaround, in case the fix gets reverted upstream.

Pick-to: 6.5 6.8 6.9
Fixes: QTBUG-133725
Change-Id: I857d7e774fc9f9f5203a58311daea5e7177e0d67
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-02-17 10:53:26 +01:00
Giuseppe D'Angelo
3cb58b053c Update PCRE2 to 10.45
New upstream version.

Importing note: 10.45 is missing a licence file for the sljit
dependency. This is tracked upstream at

https://github.com/PCRE2Project/pcre2/issues/686

so it may get fixed in 10.46 (in which case the import script /
qt_attribution.json may need to be amended).

[ChangeLog][Third-Party Code] PCRE2 was updated to version 10.45.

Pick-to: 6.9 6.8 6.5
Change-Id: Ifa0430782bed8ffb1c26f44ca6eb06cd26aaa1f9
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-02-17 10:45:06 +01:00
Thomas Moerschell
84e09e060b QScroller: Fix no overshoot behavior
Correct previously mixed up parameters to pushSegment(). stopProgress
can be set to 1 so stopPos is the only terminating condition.

Pick-to: 6.9 6.8
Change-Id: If590555ed08170800b67063aa10e853411180aa3
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2025-02-17 01:30:22 +01:00
Giuseppe D'Angelo
a66f51fe82 QPicture: (almost) work around overflow in bounding box calculations
QPicture keeps a bounding box of its drawing, and updates it as it
processes paint commands, extending it if necessary. The problem is that
these calculations are prone to overflows:

* drawing (and thus the bounding box) is floating point based, but
  QPicture only stores a QRect. If the drawing's BB overflows the
  integer range, QPicture overflows.
* Since the stored QRect is `int` based (signed), if the drawing spans
  "too far" (e.g.  from INT_MIN/2 to INT_MAX/2), it'll again overflow
  the range. This impacts serialization, as the protocol serializes the
  bounding box's topleft+size.

For the former, clamp the qreal-based into the integer range before
the conversion.

For the latter, as a dirty work around, when calculating a new bounding
box, directly set the bounding box corners instead of topleft+size. This
is NOT A FIX by any means. I'm trading one source of UB for another; the
only objective is hiding an assertion from a test.

Some design change is needed to properly fix this (keeping in mind the
stability of the serialized format).

Task-number: QTBUG-133293
Change-Id: Ia741e1e73bdf7eee21f66b4ea5c1fae3430b468d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-02-16 16:24:25 +01:00
Giuseppe D'Angelo
7736823500 QMenu: make mousePopupPos a QPointF
QMenuPrivate::mousePopupPos is a QPoint which gets set to
QGuiApplicationPrivate::lastCursorPosition, and only read from
QMenuPrivate::hasMouseMoved to determine if the mouse has moved enough.

When the last mouse position is not known, lastCursorPosition.toPoint()
returns {INT_MAX,INT_MAX} (see c5792dcfd631abb4f9e2b92cd6e88d7e5c373406
for the reasoning). This is extremely prone to overflows. In fact, one
was happening into QMenuPrivate::hasMouseMoved:

  (mousePopupPos - globalPos).manhattanLength()

On the first mouse move the subtraction yields an enormous result which
overflows manhattanLength.

The solution is simple, make mousePopupPos so that these calculations
happen in fp coordinates. The length itself is only used as a threshold
against QApplication::startDragDistance, so its representation doesn't
actually matter.

Pick-to: 6.9 6.8
Change-Id: I9c8e30a637de120d086d6f7171725702c205da78
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
2025-02-16 16:24:21 +01:00
Thiago Macieira
cf2f102684 Make QString::fromRawData() inline
And make it and the QByteArray equivalent use the QArrayDataPointer
function of the same name, which hides the const_cast.

Change-Id: I15d7b43afb6269eba411fffd496bca3f13e86a8e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-14 22:59:44 +00:00
Thiago Macieira
4b278fd998 QString: add fromRawData with a char16_t pointer
And I've updated the documentation to use char16_t too, making this the
primary (recommended) overload over the QChar one.

[ChangeLog][QtCore][QString] Added fromRawData() overload taking
char16_t* (was: only QChar*).

Change-Id: Iad8dd905a494706d72c4fffd40ded1cbf7122597
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-14 22:59:43 +00:00
Thiago Macieira
ba18ae3869 QResource: try to survive being created during application shut down
Similar to commit 12d4bf1ab52748cb84894f50d437064b439e0b7d, which was
for QLocale. Like it, QResource can be used very late in the execution,
like for example the logging system. For example (simplified):

 #9  0x00007ffff759d497 in resourceMutex () at /io/qresource.cpp:188
 #10 0x00007ffff759d615 in QResourcePrivate::load (this=0x41c940, file=...) at /io/qresource.cpp:333
 #11 0x00007ffff759dc19 in QResourcePrivate::ensureInitialized (this=0x41c940) at /io/qresource.cpp:386
 #14 0x00007ffff75011a9 in QLibrarySettings::load() at /global/qlibraryinfo.cpp:80
 #22 0x00007ffff7501756 in havePaths () at /global/qlibraryinfo.cpp:149
 #23 0x00007ffff75028e3 in QLibraryInfoPrivate::paths (p=QLibraryInfo::DataPath, usageMode=QLibraryInfoPrivate::RegularUsage) at /global/qlibraryinfo.cpp:613
 #26 0x00007ffff758e4f0 in QLoggingRegistry::initializeRules () at /io/qloggingregistry.cpp:309
 #34 0x00007ffff758f007 in QLoggingRegistry::instance () at io/qloggingregistry.cpp:424
 #35 0x00007ffff758c50b in QLoggingCategory::init () at io/qloggingcategory.cpp:188
 #43 0x00007ffff758c6bb in QLoggingCategory::defaultCategory () at io/qloggingcategory.cpp:317
 #44 0x00007ffff750ff8e in qt_message_print (msgType=QtWarningMsg, context=..., message=...) at global/qlogging.cpp:2036
 #45 0x00007ffff7509515 in qt_message(msgType=QtWarningMsg, context=..., msg=...) at global/qlogging.cpp:360
 #46 0x00007ffff750a712 in QMessageLogger::warning (this=0x7fffffffd8b0, msg=...) at global/qlogging.cpp:600
 #47 0x00007ffff790e083 in QThreadStorageData::finish (p=0x41b588) at thread/qthreadstorage.cpp:160
 #50 0x00007ffff78ed423 in QThreadPrivate::finish (this=0x41b5e0) at thread/qthread_unix.cpp:404
 #51 0x00007ffff78ec8ed in destroy_current_thread_data (p=0x41b520) at thread/qthread_unix.cpp:154
 #52 0x00007ffff78ec9ec in Cleanup::~Cleanup () at thread/qthread_unix.cpp:204

Task-number: QTBUG-133206
Task-number: QTBUG-133500
Pick-to: 6.9 6.8
Change-Id: I7b653afb1b41ef3c1c9afffdaa93e6558740016b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-02-14 14:02:02 -08:00
Thiago Macieira
8ff4d0bc18 qEnvironmentVariableIntegerValue: bypass middle-men functions
We don't need most of the extra checks that either
QByteArrayView::toInt() or QtPrivate::toSignedInteger() perform. Plus,
QtPrivate::ParsedNumber won't fit a two-register return ABI, while
QSimpleParsedNumber will.

We do need to reintroduce the int check.

Task-number: QTBUG-133654
Change-Id: I693c3e0eb072dab27000fffdd1279750dc83258c
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-14 14:02:02 -08:00
Thiago Macieira
fd3c05cd07 Long live qEnvironmentVariableIntegerValue() returning std::optional
That way, we won't need to pass a bool pointer to distinguish an
environment variable containing zero from one that failed to parse.

[ChangeLog][QtCore][QtEnvironment] Added qEnvironmentVariableIntegerValue(),
which returns std::optional<int>.

Fixes: QTBUG-133654
Change-Id: If0d6c3a6f7a080588fa5fffd87b9365f0f8e1089
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-02-14 14:02:02 -08:00
Thiago Macieira
b888bc09ce tst_QGetPutEnv: use a lambda instead of a macro
Neater and more debuggable. This code was added in Qt 5.4, before we
could use C++11.

Pick-to: 6.9 6.8 6.5 6.2 5.15
Change-Id: Icd8acccb4a9ae1f500e7fffdc4d4fc7c310cbb89
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-14 22:02:02 +00:00
Thiago Macieira
83f2d1130a qEnvironmentVariableIntValue: fix off-by-one with MSVC's getenv_s
This meant a string containing the octal form of INT_MIN (-020000000000)
would be just too long and getenv_s() would fail. This was never caught
because code that was meant to test different bases simply forgot to use
the base. Amends commit bb56586e32677ee9be23bffa4f3cc9a913ef192f.

I've renamed the rows to be the text being parsed, so it matches the
previous rows and it makes clear what was being parsed just by reading
the test's output. That also revealed a duplicate row to be removed.

[ChangeLog][QtCore][QtEnvironment] Fixed a bug that caused
qEnvironmentVariableIntValue() to fail to parse octal values from
-020000000000 to -010000000000 with MSVC. Other compilers were not
affected.

Pick-to: 6.9 6.8 6.5
Change-Id: I9095d86cccd9e8001e85fffd6fbbcd6a9a1678c3
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-14 14:02:02 -08:00
Thiago Macieira
297df8317c QTest::toString: remove massageExponent()
We don't need it after tst_selftests got code to normalize floating
point string representations.

Change-Id: Id9cd1293ade99e77b900fffd0bd292418a6ea475
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-02-14 14:02:01 -08:00
Thiago Macieira
395d23fbb3 QTest::toString(): print FP with full precision and in hexfloat
It's very annoying to try and debug why the values are different when
QCOMPARE(_xx) says they are the same:

FAIL!  : tst_QCborStreamReader::floatingPoint(QByteArray:2.^64-epsilon) The computed value is expected to be equal to the baseline, but is not
   Computed (reader.toDouble()): 1.84467440737e+19
   Baseline (expectedValue)    : 1.84467440737e+19

Now:
   Computed (reader.toDouble()): 1.844674407370955e+19 (0x1.fffffffffffffp+63)
   Baseline (expectedValue)    : 1.844674407370952e+19 (0x1.ffffffffffffp+63)

%a formatting is required by C11, which is required for C++17, which we
require. I've modified tst_selftests to normalize the representation of
floating point numbers on-the-fly, so we don't have to deal with
differences in how the different libc print floating point values[1].
This allows us to remove qtestcase.cpp's massageExponent() function,
if we want to in the future.

I've chosen to use std::regex instead of QRegularExpression so we don't
break tst_selftests in case we break QRE or our PCRE dependency. I've
also moved the floating point comparison that was in tst_cmptest to
tst_float, where all other floating point were.

Ideally we'd also print the NaN payload when not zeroes, but that's a
job for another day.

[ChangeLog][QtTest] QtTest now prints floating point values in
hexadecimal notation and has increased the precision for the decimal
format, so different values can be observed in the output when QCOMPARE
or QCOMPARE_xx fail.

[1] For example, whether 1 is 0x1p+0 or 0x8p-3. For me, the 0x1 prefix
is objectively more useful because the part after the dot matches the
mantissa bits in the variable and the exponent matches the stored
exponent (minus the bias).

Task-number: QTBUG-85779
Task-number: QTBUG-127280
Change-Id: Idc6cb070c750d2acbd26fffdc8defad7d7ae8733
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-02-14 14:02:01 -08:00
Cristian Le
b8b6382b02 Check the PROJECT_NAME more thoroughly
This was missed in 3e1a223318dbda50a010ba851841a9e51c80c42b

Task-number: QTBUG-127953
Pick-to: 6.8 6.9
Change-Id: I2ff6cafe852ec2696aea37e2e79e3c8b95c0e8ca
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-14 18:42:11 +01:00
Thiago Macieira
8e1c333661 QCborStreamReader: use std::bit_cast in _toFloatingPoint
Change-Id: Ic5b53111dbdb9073bb45fffd7c1bcb0c80b5df62
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-14 17:42:11 +00:00
Thiago Macieira
e62407b429 QCborStreamWriter: remove stale doc about 2 GB size limits
Those applied to Qt 5's int-based size types.

Pick-to: 6.9 6.8 6.5
Change-Id: Id8436bae9c641e33770bfffdd55bb1b883863a7c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-14 17:42:10 +00:00
Thiago Macieira
54daec43a0 CBOR/JSON: fix crash when comparing strings with different length
Amends 8e5ce9cd369230256045864d6fad38dbd8bee413, which introduced the
QtPrivate::equalStrings() call. At that time, equalStrings() had already
required equal lengths (see 1560e0161af70b5cf88a70e55c0b502612d433cd),
so no excuse.

[ChangeLog][QtCore][QCborMap and QJsonObject] Fixed bug that could
result in a crash or failing to find a entry in the map/object with non-
ASCII keys.

Pick-to: 6.9 6.8
Fixes: QTBUG-133744
Change-Id: I6b0f8b0a2e47d3ef905afffda6c4c079814a0914
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-14 09:42:10 -08:00
David Boddie
768ae82a03 doc: Fix invalid auto-link
qdoc tries to auto-link text written like a function call. Since there
isn't a terminated() function to link to, we ended up with unlinked
text, so we just remove the parentheses.

Amends 3b95bfe7c7b918bfececd9734780aa9e2f91ec02.

Pick-to: 6.9
Change-Id: I83bd19973aea939b51a512ca65ba7ae4ad8c34ed
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-02-14 17:42:06 +00:00
Mårten Nordheim
6ad2918de4 QNetworkInfo: Document threading restriction
Specifically on Windows we use COM, which requires being
de-initialized in the same thread as it was initialized.
Given that QNetworkInfo is a GLOBAL_STATIC with a qAddPostCondition
(iirc APPLICATION_STATIC was not yet implemented at the time) to
delete the backend when qApp is destructed, we need to cope with
destruction happening on the main thread.
If the backend is loaded on a secondary thread, the thread may
have shut down, or we may not otherwise be able to rely on
emitting Queued emissions to perform the destruction.
Conversely we also can't trivially move the construction to the
application thread (eg. using BlockingQueued emission during first load)
because we may cause a deadlock.

This leaves us with just documenting where the first load should happen.

Fixes: QTBUG-133644
Pick-to: 6.9 6.8 6.5
Change-Id: I7f52e884151c6c24acc34f1112faabc897d9b0f9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-14 17:27:16 +01:00
Mårten Nordheim
d25e5e2cb7 QByteArray(View)::lastIndexOf: Guard against needle > haystack
Otherwise we would traverse beyond bounds.

We calculate the delta in sizes between the haystack and the needle and
if this delta is smaller than the starting position
(the `from` argument) then we start from there.

The default value for `from` is size(). With the needle being longer
than the haystack, the delta is negative and we set our starting
position to be the delta, i.e. we start before the start of the
haystack.

[ChangeLog][QtCore][QByteArray/QByteArrayView] Fixed a bug in
lastIndexOf() that could lead to out-of-bounds access when the needle
is longer than the haystack.

Pick-to: 6.9 6.8 6.5 6.2 5.15
Change-Id: Id5cd772f00b0c3c50fbf61b4e888bba5587391ee
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-14 17:27:16 +01:00
Mårten Nordheim
9afd4f6814 QHash: reduce how many times we calculate hash by passing it around
Result in some smaller speedups, because we now compute the hash once
per insertion operation, and pass it around, instead of computing it
once in every function where we need it. Though it's minimal, on my
machine it executes around 1% less instructions per iteration.

Change-Id: Ib84696cac56c379c37853dd4f0bc6ab4f5e440ad
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-14 17:27:16 +01:00
David Boddie
c8e59d682c doc: Change links from begin() and end() to constBegin() and constEnd()
It appears that there are no longer relevant begin() and end() functions
to link to. constBegin() and constEnd() are the relevant alternatives.

Pick-to: 6.8 6.9
Change-Id: If6fc421ee08364de9a879fb704a7989046b9b43a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2025-02-14 17:20:10 +01:00
David Boddie
f9334be98e doc: Add missing fromArray() documentation
QAnyStringView::fromArray() was not documented, leading to a broken
auto-link that referred to it.

Pick-to: 6.8 6.9
Change-Id: Ibf3704da8b3f16e56589bd649ce1e63a7cbd3739
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-14 17:20:10 +01:00
David Boddie
915e1b71af doc: Change \since from 6.9 to 6.10 to reflect API status
Functions in 6.10 were incorrectly marked as \since 6.9. This was
noticed when automatic cherry-picking of a documentation change failed.

Change-Id: Idc6fe958cd1f4dfed6252e2b1fce6c8fea4d77fb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-14 17:20:10 +01:00
Laszlo Agocs
b6d4c1368d rhi: vulkan: Don't assert in VMA when vk header is older than runtime
Building Qt with e.g. a version 1.2.x Vulkan SDK and then running
on an implementation providing 1.3 or 1.4, one will likely get an
assert in debug builds upon initializing the memory allocator.

Work it around by restricting the apiVersion passed in based on the
preprocessor macros.

Pick-to: 6.9 6.8
Change-Id: Ia689ffc29d5675b84b6683e289d0725d7e47220b
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-02-14 16:11:53 +01:00
Alexei Cazacov
1e7e0b0cac Docs: Move qmake-specific documentation out of Qt's documentation
This commit moves the third-party-libraries.html topic to the qmake
documentation. The topic is renamed and links to it are corrected.

See also: 623150

Task-number: QTBUG-132504
Pick-to: 6.9
Change-Id: I711400d887b7e4894021b0433eb1cd61dfdd5349
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-02-14 12:27:48 +00:00
Andreas Eliasson
bdf453afd7 Doc: Improve deprecation description for QApplication::fontMetrics()
Add a link to QFontMetrics, which provides more information about the
differences between QFontMetrics and QFontMetricsF and why the latter
is the preferred choice.

Fixes: QTBUG-127528
Pick-to: 6.9 6.8 6.5 6.2
Change-Id: Ib5713a9d39bf312a6eae6b8b1a6d1dc1d47e25be
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-02-14 13:01:57 +01:00
Rami Potinkara
9b475eadfc Android: update Android 15 SDK 35 to docs
This patch updates the macros for Android
maxApiVer, AndroidMaxVer, AndroidPlatformVer,
AndroidBuildToolsVer variables to reflect
Android 15

Task-number: QTBUG-129462
Pick-to: 6.9 6.8 6.5
Change-Id: Ia6edfa7811dd8c98a0a99c10d8781aa09384bdfa
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2025-02-14 12:09:22 +02:00
Marc Mutz
8669bc97ff qhighdpiscaling: de-pessimize qEnvironmentVariableOptional*() functions
Don't call qEnvironmentVariableIsSet(), since it locks the environment
mutex. Since qgetenv() and qEnvironmentVariable() both report whether
the value was set (returning non-isNull()), we can avoid the extra
mutex lock (and envvar lookup) by just calling those and then checking
for isNull().

In qEnvironmentVariableOptionalReal(), in addition, use qgetenv()
instead of qEnvironmentVariable(). While on Windows, that may convert
encoding, QString::toDouble() first converts to Latin-1, and only then
converts to double, so we avoid one encoding conversion, even on
Windows; on Unix we avoid two.

Amends 4d1f13f3549a73f5ca4e64dac9137e83138080fa.

Pick-to: 6.9 6.8 6.5
Change-Id: I6803e2277b324c2568726765245681bcbf517362
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-02-14 05:45:02 +00:00
Volker Hilsheimer
6c61d7b0f8 JNI: generate QtJniTypes forwarding header for the namespace
The documentation claims that this is where the namespace and the macro
definitions live, and it's convention to have a Qt<Namespace> header for
Qt namespaces.

Pick-to: 6.9 6.8
Change-Id: Ia49001d61f0967df84344779909860cf65c3623c
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-02-14 03:37:48 +01:00
Thiago Macieira
97a6512724 QByteArray/QList/QString: mark isEmpty() and isNull() constexpr
Since QByteArray::isNull() wasn't inline until Qt 6.4, we needed a new
macro in the module C++ exports header, which may come in handy for
future uses.

Change-Id: I059fc46ce7b340a68b39fffdd65f6d2255c9c5cc
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-13 18:06:28 -08:00
Thiago Macieira
434222f635 tst_QFontEngine: fix argc going out of scope
Q{Core,Gui,}Application constructors take a reference to argc.

Amends 4db368d4741eff4d2b2942c25d5e633648e23a64.

Pick-to: 6.9
Change-Id: I0a0c9a0ba574133ac7b8fffdb80e4656267d2ed2
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-02-13 18:06:28 -08:00
Pierre-Yves Siret
d8b4eb1a17 Add a QMetaObject::connect function
This adds a QMetaObject::connect function allowing to connect a
QMetaMethod to a PMF or a functor. This is most useful when connecting
a signal retrieved by QMetaObject introspection to a lambda with
a capture. This aims to replace the remaining usecases of QSignalMapper
with a lighter alternative not relying on sender()/senderSignalIndex().
Note that this function doesn't support implicit conversion between
argument or return types.
It does support lambda with captures and signals returning values.

[ChangeLog][QtCore][QMetaObject] Added a QMetaObject::connect function
for connecting a signal's QMetaMethod to a member function or a functor
(lambdas, etc.)

Fixes: QTBUG-120631
Change-Id: Ifca73cd047478f6a262728493b16a942bff36e40
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-02-14 01:51:47 +01:00
Thiago Macieira
aad0ab897f QDesktopServices: don't use openDocument if the URL has a query
[ChangeLog][QtGui][QDesktopServices] Fixed a bug that caused
QDesktopServices::openUrl() to discard a query when opening a local file
URL that contained a query but no fragment.

Pick-to: 6.9 6.8
Fixes: QTBUG-133663
Change-Id: Ie8fa190036417f590540fffdcf03e53f3c99b38f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-02-13 16:09:35 -08:00
Thiago Macieira
0cc41083c3 tst_QByteArrayView: stop using std::basic_string<signed char>
That's not a valid type for the Standard's string, because the Standard
doesn't allow for std::char_traits<signed char> either.

Pick-to: 6.8 6.9
Fixes: QTBUG-133689
Change-Id: Icd0d4928fa4cdc9d806bfffd4053f0eb1073e6b4
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-13 16:09:35 -08:00
Thiago Macieira
c7ec043e46 QLoggingCategory: remove init() and merge with the constructor
Nothing else calls it.

Drive-by initialize the two pointers via NSDMI.

Pick-to: 6.9 6.8
Change-Id: I8c51cf5126aeb8bd6254fffdd21a37526329bbf3
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-14 00:09:35 +00:00
Assam Boudjelthia
16ef3aaa74 Android: directly set available geometry from handleLayoutSizeChanged()
Don't check for current primary screen available geometry as that value
might not have been set (invokeMethod() is used for that) from a
previous call. Also, in any case, handleLayoutSizeChanged() is only ever
called when the root layout size has really changed.

Amends 0f2c6450201bfa1e612175cddf7481ab72eb4620.

Fixes: QTBUG-133456
Change-Id: I3219529d0f18d4cfc8a9d0eca7573de57ae9e43d
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-02-14 02:09:34 +02:00
Marc Mutz
20d058acfc QFutureInterfaceBase::setContinuation(): add a missing std::move()
Found by Coverity: We can move the shared_ptr into the last lambda
instead of copying it.

Amends b0e82f598193f7d2c331a7ff3da7e2d3114db714.

Coverity-Id: 474727
Change-Id: If0eb759c97c1e3d1e00aa0ff541ce257a2a2ff69
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-02-14 00:49:13 +01:00
Thiago Macieira
c2fa41a081 QStringConverter: mark QStringConverterBase as removed in Qt 7
It's an internal class containing the common content between
QStringConverter and QTextCodec (Qt5CoreCompat) so the latter didn't get
the new API from the former.

This allows us to remove the QStringConverter::Flags qdoc hack too.

Pick-to: 6.9
Change-Id: Iacf32fb88e3c3d0ea369fffd153356cec308e3dd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-02-13 11:38:49 -08:00
Thiago Macieira
8379d1e90a QFile: refactor {to,from}FilesystemPath to avoid temporary allocations
Avoiding #ifdef and reinterpret_cast too, to boot.

It was already the case on Windows and for fromFilesystemPath
everywhere, but now we can also benefit from the QString::toStdString()
that also avoids a temporary.

Change-Id: Ie4f0a129d0f2f3653046fffd2ec22713a5516ada
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-02-13 11:34:06 -08:00
HIDAKA Takahiro
2429c73cc9 iOS: Add support for hover feature for Apple Pencil 2nd gen or later
Add UIHoverGestureRecognizer to support Hover feature.

Task-number: QTBUG-128473
Change-Id: I73bbd1b8cca1ffcb8fcc27f6c26cb4ab8830c690
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-02-13 19:29:53 +00:00
Eskil Abrahamsen Blomfeldt
cf674f3845 Treat variation selectors as ignorable chars
The variation selectors only make sense in the context of the
previous glyph and should never be shaped by themselves, therefore
we should not pick a different font engine for these even if
the cmap does not support it. They are sometimes needed to
properly resolve the emojis, but the OpenType rules in the font
may not be written with them in mind.

If the cmap lookup fails for these, then Harfbuzz will map them
to a zero-width space, thus ignoring them when resolving the
OpenType rules.

We treat these the same as other control characters and just
ignore them when doing font merging.

Note: This was handled through an ad hoc mechanism prior to
the introduction of the emoji segmenter in 6.9.When the emoji
segmenter is disabled, we still use this mechanism, which
depends on us not ignoring the character in that case.

Pick-to: 6.9
Fixes: QTBUG-133480
Change-Id: I8fa4e8d5e1aabad0946b8fd3fff044e2b2af5d0e
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
2025-02-13 20:15:49 +01:00
Ulf Hermann
dd2dc8c70d QLibraryInfo: Consider resource paths as absolute
This is what QDir::isRelativePath() does, for better or worse. We've
used QDir::isRelativePath() before and we shouldn't change the behavior.

Amends commit c74cba1117355a6312b1f0cc815efa4cdea4bbfa

Pick-to: 6.9 6.8
Change-Id: I03e3e921977af2b9c6ff2593535d846d6ce28fe2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-02-13 19:40:34 +01:00
Aurélien Brooke
6ec0fd6632 rhi: vulkan: avoid allocations/deallocations in every beginPass() call
It is not uncommon to have more than 4 total clear values because of all
the color, depth, resolve and shading rate attachments.

Set the stack prealloc of the temporary QVarLengthArray to its maximum
possible size to avoid any heap (de)allocation in this hot path.

For 10 render passes per frame, it saves 600 allocs/deallocs per second.

Change-Id: If44fd075d1c1f9c07809ddc9922c690e9dc3ac3d
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-02-13 19:40:34 +01:00
HIDAKA Takahiro
fa21fc298a iOS: cleanup debug log for touch event
Add xTilt, yTilt variables for simplify duplicate expressions.
And remove azimuthAngle as it is no longer used.

Change-Id: Ia4a058d61670c1251760835e92972406c5dfe4c0
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-02-14 03:40:34 +09:00
Cristian Le
51dc4cdd42 Simplify genex expressions
Simplifications:
- `COMPILE_LANGUAGE` accepts comma-separated list since 3.15

Pick-to: 6.8 6.9
Change-Id: I4af316a463b5771bf5b37a6b4d77e41adba60977
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-02-13 15:57:20 +01:00
Tor Arne Vestbø
c812190a92 iOS: Pause display link when app moves out of active state
The applicationWillResignActive documentation describes that the app
should "use this method to pause ongoing tasks, disable timers, and
throttle down OpenGL ES frame rates". Similarly, the more modern
sceneWillResignActive describes that the app should "use this method
to quiet your interface and prepare it to stop interacting with the
user. Specifically, pause ongoing tasks, disable timers, and decrease
frame rates or stop updating your interface altogether."

In practice the application enters the inactive (as opposed to the
backgrounded) state when the user brings up the app switcher, or
enters split-view mode, as described by the "Adopting Multitasking
Enhancements on iPad" documentation.

We do propagate the inactive state as Qt::ApplicationInactive, but
it was up to the application itself to react to the state.

To adhere to the documented behavior, we now skip update request
delivery if the app is not active. Once it becomes active again
we re-try the update request delivery.

Relying on the exposed state of window was not an option, as the
window is still technically exposed, even if the app itself is
inactive.

This hopefully fixes a GPU crash observed (only) on A10 iPads
(iPad 7) with iOS 18, when the user entered split-view mode,
possibly due to changes in the system Metal-based OpenGL driver:

  void IOGPUScheduler::signalHardwareError(eRestartRequest, int32_t)
  void IOGPUScheduler::hardware_error_interrupt(IOInterruptEventSource *, int)
  void IOGPUCommandQueue::retireCommandBuffer(IOGPUEventFence *)
      Deny submissions/ignore app[openglwindow] with 2 GPURestarts in 31 submissions.
  Execution of the command buffer was aborted due to an error during execution
      Caused GPU Timeout Error (00000002:kIOGPUCommandBufferCallbackErrorTimeout)
  GLDRendererMetal command buffer completion error
      Error Domain=MTLCommandBufferErrorDomain Code=2
  Execution of the command buffer was aborted due to an error during execution
      Ignored (for causing prior/excessive GPU errors)
  Terminating due to blacklisting by kernel driver

The back-trace always pointed to the display-link callback,
so the assumption is that the crash was triggered by the app
rendering when it shouldn't, during the split-view transition.

Fixes: QTBUG-132314
Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Idf1f692daa9d437ee69f9436706777b220fbfbf4
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2025-02-13 15:37:02 +01:00
Thiago Macieira
5da95322bd Fix use of #warning in compilers that don't support them
That becomes an error. So only allow them in GCC-compatible compilers.

Fixes: QTBUG-133376
Pick-to: 6.9
Change-Id: Idd04be795dd9fd2b43affffd08cd7b8a444bbc43
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-13 06:15:27 -08:00
Aurélien Brooke
9e5dae9b8c Qt Concurrent documentation: fix Forward Iterator example container
std::slist doesn't seem to even exist on Google, while std::forward_list
exists in the standard since C++11.

Pick-to: 6.8 6.9
Change-Id: I9869c716fb631bc743e656a3b8bbb8ca35c9a1ed
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-02-13 15:15:27 +01:00
Marc Mutz
d71379d447 QLayoutPolicy: use qCountTrailingZeroBits() in setControlType()
This is more efficient, because it maps to a single assembler
instruction on most ISAs, and also avoids a Coverity warning about the
loop not terminating and thus 1 << i overflowing, if type == {}.

The clone class, QSizePolicy, is not affected, since it already uses
qCountTrailingZeroBits().

Amends 6c322a917ad57d57f0ee76825eab3e2e008c5bd4.

Coverity-Id: 474336
Pick-to: 6.9 6.8 6.5
Change-Id: Idf62d045d8ac3f0cb15196dd8664ac37d92a9cc2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-13 15:15:27 +01:00
Shawn Rutledge
6e089a66a4 doc: Explain the use of QContextMenuEvent cross-platform
...and across Qt Quick and Widgets, and somewhat from a usability
perspective.

Pick-to: 6.9
Task-number: QTBUG-67331
Task-number: QTBUG-93486
Change-Id: I75085f3a7a8e76c3e67ff5864600324faf262a76
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2025-02-13 12:41:16 +01:00
Tomi Korpipaa
d14e57ecbf Remove references to the deprecated QtDataVisualization module
Task-number: QTBUG-133658
Change-Id: Ibf8123ffacf6fc4cc02817a5d2ac380ff317f815
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-02-13 12:21:47 +02:00
Christian Strømme
08146377db visionOS: Change how the initial immersion style is set
Set the initial style to be automatic, that's the default. With this
change we also get rid of the warnings shown on application startup
complaining about the application not defining an initial immersion
style:
"Since your app does not define an initial immersion style in its
Application Scene Manifest, the default immersion style will be
applied. This does not match the immersion style defined at runtime
'full'. To make sure your app's state matches its runtime behavior
define an initial immersion style."

Pick-to: 6.9
Change-Id: I1b8bba5f919b72d4f2507a19a30de49e8bfcd708
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-02-13 06:18:12 +01:00
Matthias Rauter
e5ea3e68cc Alphabetically order CMakeList entries
Change-Id: I8dfc3521aac8d71b0a8b5148e201fa1a98e53a03
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
2025-02-12 18:27:22 +00:00
Mårten Nordheim
06db3f3c5c QMultiHash: use move() on key when move-constructing nodes
Change-Id: Ibc2bd1c2b11d3fa29814db0cae1caf0e2c23bb54
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-12 19:02:34 +01:00
Alexey Edelev
3db7fd6a3f Remove dead code
Remove unused variables and property get call.

Pick-to: 6.8 6.9
Change-Id: I0da26fae813fd201f7fbb24d2b779e62a78250e2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-12 19:02:34 +01:00
Lauri Pohjanheimo
7140c5b688 QRhi test renderToTextureArrayOfTexturedQuad unblacklisted
On CI an Android emulator with SwiftShader software graphics
implementation is used. SwiftShader implementation is unable
to emulate this OpenGL functionality.

Blacklisting removed. QSKIP the test if it is run in Android platform,
OpenGL and SwiftShader sw graphics implementation is found.

Task-number: QTQAINFRA-6330
Change-Id: Ib0832f35b63540d57a273fc6dba1e310de917439
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2025-02-12 15:10:34 +00:00
Christian Ehrlicher
7d0017cda8 ItemWidgets: add supportedDragActions()/setSupportedDragActions()
In Qt6 the deprecated function QAIM::setSupportedDragActions() was
removed so the itemwidgets had no possibility to specify the drag
actions anymore. Fix this by adding it to the itemwidgets themselves.

Done-with: David Faure <david.faure@kdab.com>
Fixes: QTBUG-87465
Change-Id: Ib10fa30c5b2c9e8e5cd3f0e1c2664f7a12fb249b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-02-12 10:45:49 +01:00
Allan Sandfeld Jensen
da1fbf6053 Update defaults for QPaintDevice
A few values have meaningful defaults, for the rest only warn about
implemented metric.

Pick-to: 6.9 6.8
Change-Id: I80c6c8dba6c8d2715daac0463a411bc5117f0bc0
Reviewed-by: David Faure <david.faure@kdab.com>
2025-02-12 10:37:55 +01:00
Jerome Pasion
1a8ae82bb0 Qt D-Bus Viewer: Update documentation
-Added information about the location of qdbusviewer
-Fix name to "Qt D-Bus Viewer"

Fixes: QTBUG-118997
Pick-to: 6.8 6.9
Change-Id: I90f1e75a04a959d9c739e33779d978b607a8181c
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2025-02-12 10:30:16 +01:00
Joerg Bornemann
a9c18e5df2 CMake: Silence the private module warning for dependencies
If a private module package is pulled in by another Qt module we showed
the private module warning message. The user couldn't act on the warning
other than disabling it completely. This doesn't seem useful.

Now, we only show the warning if the user explicitly does
find_package(Qt6FooPrivate).

There's the situation where a private module is pulled in as dependency
and later pulled in by the user. For example, in a static Linux build
    find_package(Qt6 REQUIRED COMPONENTS Gui CorePrivate)
will pull in CorePrivate as transitive dependency of Gui's plugins.

To still see a warning for CorePrivate in this case we need to trigger
the warning in Qt6Config.cmake when handling the COMPONENTS.
To achieve that, the warning code has been moved to a function which is
called in Qt6Config.cmake and Qt6FooPrivateConfig.cmake

Task-number: QTBUG-87776
Change-Id: Ie9cc2d287d1fcb94db77045165f703cebcb6983d
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-12 10:26:05 +01:00
David Redondo
a0d203cf89 Use the same pointing device for releasing as all other events
When we specify no pointing device QWindowSystemInterface will use
QPointingDevice::primaryPointingDevice() which is slightly different
than what QWaylandWindow will do where the seat name is passed.
Task: QTBUG-127821

Pick-to: 6.9 6.8
Change-Id: I77bf7ce0c5b57c205d670923ba348bf6eeec2490
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-02-12 09:03:44 +01:00
Eskil Abrahamsen Blomfeldt
d7731dd110 Remove touch-extension protocol
This removes the special case touch-extension protocol for Qt.
Touch input should work with all compositors, not just Qt-based,
through the wl_touch interface, and the world has come a long
way since this was added.

Task-number: QTBUG-133223
Change-Id: I89d404ac87270d8b3c6a9015d3a72fac5919b0b9
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2025-02-12 08:22:31 +01:00
Thiago Macieira
e6f483c0e8 QCoreApplicationPrivate: make cachedApplicationFilePath non-static
I don't see why it needed to be static, given that the setter checks for
!self and prints a warning.

Pick-to: 6.9
Change-Id: I2d4b632db7d7c9fac21dfffd3f302b5a7aac2e89
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-02-11 18:20:20 -08:00
David Faure
c82ad28125 QListWidget/QTableWidget: extract method view()
Change-Id: Ie6505e2aea2c3a7a10f91be19dfc66197bf97556
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-02-12 04:20:20 +02:00
Thiago Macieira
c74cba1117 QLibraryInfo: use fewer QFileInfo in finding qt.conf
This is hot code, run early in the application's life, usually as a
result of the first qDebug() because QLoggingRegistry wants to find
qtlogging.ini. So let's not use QFileInfo, which allocates memory, just
to do string manipulation. These are always filesystem paths.

See commit d59e640c868f3db2d661970f3d34a22013d49053 for a similar change
in findConfiguration().

Pick-to: 6.9 6.8
Change-Id: I012daf4a3aa2ebc2c5abfffd2ef7ceac1df2626d
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-02-12 02:20:20 +00:00
Thiago Macieira
f314e991ca generate_expected_output.py: suppress annoying warning about non-UTF8
On my system, en_US.UTF-8 is apparently not properly detected, causing
the warning about running on a non-UTF8 locale to be printed. I don't
understand why because strace shows that the proper locale file was
opened:

openat(AT_FDCWD, "/usr/lib/locale/en_US.utf8/LC_CTYPE", O_RDONLY|O_CLOEXEC) = 3

And it doesn't get printed when running the tests manually, only when
running with the python script.

Detected locale "C" with character encoding "ANSI_X3.4-1968", which is not UTF-8.
Qt depends on a UTF-8 locale, and has switched to "C.UTF-8" instead.
If this causes problems, reconfigure your locale. See the locale(1) manual
for more information.

Change-Id: I0ea60c82852bc3039952fffdd9136ed4ada43158
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-02-11 18:20:20 -08:00
Marc Mutz
bbdbcb2eba QJsonObject::iterator: add keyView()
Unlike CBOR maps, JSON objects can only have string keys, but, like
CBOR, they are internally stored as either US-ASCII (ie. Latin-1),
UTF-8, or UTF-16, so in order to return a view on the internal
storage, QAnyStringView is the perfect fit.

Add (const_)iterator::keyView() and add a benchmark, prepared for
testing a similar change to the value side of things.

Results (fastest each of ten runs) on my machine suggest a 40%
speedup:

  PASS   : BenchmarkQtJson::iteratorKey()
  RESULT : BenchmarkQtJson::iteratorKey():
       0.071 msecs per iteration (total: 73, iterations: 1024)
  PASS   : BenchmarkQtJson::iteratorKeyView()
  RESULT : BenchmarkQtJson::iteratorKeyView():
       0.042 msecs per iteration (total: 87, iterations: 2048)

[ChangeLog][QtCore][QJsonObject] Added keyView() methods to iterator
and const_iterator, allowing zero-copy inspection of the key().

Task-number: QTBUG-133688
Change-Id: I0ccedaf8a4fa41125b12bdbab5bea3bd2468d9a5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-12 00:45:13 +01:00
Marc Mutz
6aaa874d79 QJsonValueConstRef: remove duplicate Q_ASSERT in objectKey()
Amends 14d1108d3562f6e409505ba49b7bce82d70bd64f.

Pick-to: 6.9 6.8
Change-Id: I9fcfb864254d040cd1de8aa0dc818ccd9104487b
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-02-12 00:45:13 +01:00
Lauri Pohjanheimo
51979cfa17 Unblacklist tst_QRhi::RenderToFloatTexture and skip on Android-Sim
On CI an Android emulator with SwiftShader software graphics
implementation is used. SwiftShader implementation is unable
to emulate this OpenGL functionality.

Blacklisting removed. QSKIP the test if it is run in Android platform,
OpenGL and SwiftShader sw graphics implementation is found.

Task-number: QTQAINFRA-6332
Change-Id: I241a2c6772291795d26b9c2a563f4f9412605cf6
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-02-11 23:28:32 +02:00
Bartlomiej Moskal
b4c82eba03 AndroidTestRunner: allow to call additional/extra adb call
This commit adds a new parameter (--pre-test-adb-command) to
AndroidTestRunner. The new parameter allows to pass an extra adb command
which will be called by AndroidTestRunner after installation and before
running the test.

To set the mentioned argument the new parameter for qt_internal_add_test
was proposed: ANDROID_TESTRUNNER_PRE_TEST_ADB_COMMANDS.

The new parameter is needed especially for multimedia screen capture
tests. ScreenCapture feature needs an acceptation of Security Popup. It
can be automatically accepted with additional adb command.

Fixes: QTBUG-132249
Pick-to: 6.9 6.8
Change-Id: Ib70cd05d60d4594961ca68b554c7aae11cf42240
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-02-11 22:03:57 +01:00
Alexandru Croitor
d7a739bde1 CMake: Remove pro2cmake and configurejson2cmake
Most qt repos and modules are now ported from qmake to CMake. The
CMake API for internal Qt modules has evolved, and these tools have
not been kept up-to-date. It's time to remove them. Developers can
still use qmake2cmake for their own user projects, which is hosted in
a different repo.

If we do end up needing the scripts again, they can be used from one
of the older branches like 6.9.

Fixes: QTBUG-133678
Change-Id: I8d9a765f2575a6c0fcfe9a0346a06a7eec302914
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-02-11 16:02:32 +01:00
Tor Arne Vestbø
a5d896d70a macOS: Trigger expose on screen param change for windows that opt into EDR
When the active EDR headroom of a display is updated, due to its brightness
setting changing e.g., the system sends us a screen parameter change.

We don't have a specific signal for these kinds of changes on a screen
or window level, so for now we do the next best thing, which is to trigger
an expose even for any relevant windows that might need to re-render to
reflect the updated EDR headroom.

Change-Id: I1edd8ff6b9714b558a9ae92d45aaee56a838af7c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-02-11 15:58:40 +01:00
Tor Arne Vestbø
5d58c9765c iOS: Trigger expose on screen brightness change for windows that opt into EDR
When the screen brightness of the display changes, the active EDR headroom of
the display might also be updated.

We don't have a specific signal for these kinds of changes on a screen
or window level, so for now we do the next best thing, which is to trigger
an expose even for any relevant windows that might need to re-render to
reflect the updated EDR headroom.

Change-Id: I72ed3b8335ad763f66043daf6fcbac616425845b
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-02-11 15:58:38 +01:00
David Faure
f0508b7ff3 QToolButton: allow opening a menu after it first failed because empty
Commit 353ce5344fbde5a6cecbdd2c131e1cf0f4b7f383 made QMenu::exec()
return immediately (without showing the menu), which meant it never
emitted aboutToHide() and QToolButton didn't reset mouseButtonDown.
Therefore, on the next click on the toolbutton (maybe by then the
menu has actions), it won't even try to show it (because mouseButtonDown
is still true).

Pick-to: 6.9 6.8
Task-number: QTBUG-129108
Change-Id: I3f84b9a35eb444fc33d8516c4be130293c04017d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-02-11 15:46:24 +01:00
Alexandru Croitor
66261ac0f1 CMake: Simplify and fix target dependency handling in SBOMs
Previously we had complicated logic trying to differentiate between Qt
targets, system libraries, vendored libraries, custom sbom targets,
whether they are in external documents or not, when generating SBOM
dependencies for a target.

We also lacked the ability to handle regular non-Qt non-system
libraries. This was discovered while creating the SBOM for Qt Creator,
where the code treated all Creator helper libraries as system
libraries rather than just regular dependencies.

Simplify the code by unifying most of the code branches, removing
nested ifs, and removing special handling of some targets when
checking whether they are in external documents.

Now system libraries are marked at qt_find_package time by setting the
_qt_internal_sbom_is_system_library property on the target, rather
than trying to infer it base on the target name and other markers.

Now the logic goes as follows:
- check if system library based on the presence of the
  _qt_internal_sbom_is_system_library property
- check if it's a vendored lib based on walking its libs and checking
  if the _qt_module_is_3rdparty_library property is set
- mark system libraries as consumed
- if not a system library, handle it as a regular dependency, taking
  into account if it's external or not

Also add some debug messages to help keep track of system libraries.
And remove some of the unnecessary code in
in _qt_internal_sbom_is_external_target_dependency and
_qt_internal_sbom_add_external_target_dependency.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: Ic43fe53446b74badee2cde6d18146e952587c292
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-02-11 12:23:29 +01:00
Alexandru Croitor
f1ac316191 CMake: Decouple Qt specific handling from SBOM implementation
The SBOM functions so far had a lot of Qt-specific logic inside them.

Decouple this logic into separate Qt-specific functions or explicitly
guard the code with Qt-specific handling options, to prepare for a
cleaner SBOM public API.

The generic functions then call the Qt-specific ones if various
internal options are set.
This approach is used, rather than directly passing values to the
generic functions because:
- we have cases where we need to recursively pass the values all the
  way down to all recursively created attribution targets
- some of the logic needs to know about values before and after qt
  processing, and this could be achieved with something like lambdas
  but it's not worth the complexity

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I4399c41f4d976f20b16a0bb0c674d4f07ee1ccd4
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-02-11 12:23:28 +01:00
Alexandru Croitor
3a5c62d4af CMake: Fix location of build time sboms in no-prefix builds
For build time sboms to be found in a no-prefix qt build of a repo,
specifically when finding external sbom documents, the build time
sboms have to be in the same location.

Previously they were in each repo's build dir.
Align the location to be in the qtbase build dir, just like for super
builds.
Also check for QT_BUILDING_QT because we don't want to apply the logic
for QT_WILL_INSTALL not being set in user projects.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I04a066fc0efc91a4f2ee938c190b8632c8c946aa
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-02-11 12:23:26 +01:00
Ivan Solovev
cdc71532ec Add QFuture::cancelChain()
This method should be used on a future returned from the long
continuation chain, if this chain needs to be canceled altogether.

To achieve it, this commit introduces a pointer to the parent data.
That pointer is set when setContinuation() is called, and cleaned
when the parent is completed and calls its runContinuation()
method. This allows the code in cancelChain() to simply move up
the chain as long as the parent pointer is valid, and cancel each
of the continuations.
The commit also moves the QFIB::cancel() implementation into
QFIBP::cancelImpl(), so that it can be reused in the new method,
and introduces an enum for cancellation options, to address the
differences in the behavior between these two methods.

Note that the approach consistently works only on the last QFuture
of the chain, because the already-executed continuations might
clear their continuation data, which makes navigating down the
chain inconsistent.

[ChangeLog][QtCore][QFuture] Added QFuture::cancelChain().

Fixes: QTBUG-130662
Change-Id: Ic0949ed30a2f54f99597e95b3951fda6bfb9a0be
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-02-11 12:19:50 +01:00
Ivan Solovev
3164746eb0 QFutureInterface: mark the unused setContinuation() overloads as removed
This is a cleanup after the previous patch that introduced the new
setContinuation() overloads. The old API cannot be used correctly with
the new approach that requires to always set a continuation type, so
let's mark it as removed.

Technically, this change is SiC. However, QFutureInterfaceBase was
never documented as a public class, so users are not supposed to derive
from it and should not use setContinuation() methods directly.

Task-number: QTBUG-130662
Change-Id: Idf3d9f5de00a7c4ac34ee3dde1d58902e3a27904
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-02-11 12:19:48 +01:00
Ivan Solovev
b0e82f5981 QFutureInterfaceBase: rework setContinuation() overload set
Add new overloads to make sure that we can pass continuation data
even for the continuations with context. The new overloads
intentionally do not expose QFutureInterfaceBasePrivate pointer,
because they would be used in the inline code (see QTBUG-117514).
The overload with a context provides a continuation future as a
QVariant, because that is the easiest way to keep the
QFutureInterface<T> object alive without exposing the template
type T to a non-templated exported base class. We cannot pass the
QFutureInterfaceBase because of the reference count logic, which
contains two different counters: for base class (void case), and
for the interface that holds an actual type T.

This patch is a pre-requisite for a follow-up patch that would
introduce the ability to cancel the entire continuation
chain from the first QFuture object of the chain, even if
that QFuture is already finished.

Note that the pre-existing QFutureInterface::cancel() code
relies on the fact that only then-continuations provide
continuation data. The onFailed() and onCanceled() handlers
never provide it, even when they were supposed to be executed
in the same thread.
To keep the old behavior on the cancel() method, introduce
a new ContinuationType enum and make sure that the type is
properly set when providing a continuation data.

The new overloads also allow to get rid of the template
QtPrivate::watchContinuation() helper method. The exported
Impl should stay for BC reasons. This patch implements it
in terms of the new setContinuation() overload.

During the development of this patch it was important to
verify that the behavior of all public and/or exported
methods stays unchanged. It was done by running the tst_qfuture
binary that was originally compiled with the old QtCore version
against the updated QtCore library.

Task-number: QTBUG-130662
Change-Id: I2bd5821846561d18c198205f3c57d3f0dacbb94b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-02-11 12:19:45 +01:00
Ivan Solovev
a30289ee0b tst_qfuture: silence all continuation overwrite warnings
Introduce a helper function to silence this lengthy warning, and use
it consistently in all places where the warning was triggered.

Amends 502a7706b94380d4957a7e594fc7c4c4db8ae81b which introduced the
warning.

Pick-to: 6.9 6.8 6.5
Change-Id: Ifa5c7e0182a12885af4db42ef5d68b1f27a0c6bc
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-02-11 12:19:43 +01:00
Ivan Solovev
04b5d2b94f QFuture: prevent the continuations from being executed twice
On some very rare cases the continuation could be executed twice in a
multithreaded scenario. Consider the following example:

  auto f = QtConcurrent::run(someFunction);
  f.then(someOtherFunction);

Assuming that QtConcurrent::run() is executed on Thread B, and the
continuation is attached in Thread A, the following call stack is
possible:
1. Thread B: someFunction() is finished
2. Thread B: QFutureInterface::reportFinished() is called
3. Thread B: QFutureInterfaceBase::reportFinished() is called and
             finished.
4. Thread A: then() is called. It checks that the future is already
             finished, so the attached continuation is executed
             immediately.
5. Thread B: QFutureInterfaceBase::runContinuation() is executed.
             At this point it sees that a continuation exists, and
             executes it again.

Step 5 will lead to a crash, because we'll try to access a moved-from
QPromise.

To fix the issue, introduce a flag that is explicitly used to test if
the continuation was already executed or not.

The pre-existing code already uses a concept of a continuation state,
but it cannot be easily extended without convering it from an enum
to flags, because the canceled continuation should still be called
in order to actually execute the onCanceled() handler.

Wrapping QFIBP::ContinuationState into QFlags would increase its size
from 1 to 4 bytes, and manually treating the enum as flags will result
in a more complicated code. So, I simply picked the approach of adding
an explicit flag for this case.

Writing a unit-test is not really possible, but I verified that the
reproducer from the linked Jira ticket does not crash anymore.

Amends dfaca09e85a49d2983bb89893bfbe1ba4c19eab4 that introduced the
continuations, so picking to all active Qt 6 branches.

Fixes: QTBUG-118032
Pick-to: 6.9 6.8 6.5
Change-Id: I3e07722495e38367e8e4be2eded34140e22b0053
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-02-11 12:19:40 +01:00
Alexandru Croitor
a8f55f4729 CMake: doctools: Avoid blocking integrations due to version mismatch
It can happen that qt repo version bumps are direct pushed, and not
merged in DAG-dependency order. This can cause a mismatch between the
qttools package version and any of its dependencies, which would block
integrations. To avoid this, we disable the warning about incompatible
package versions when building the doc tools. The version check in
that case doesn't make sense, so it's safe to do.

Amends f7f02c791bcbee44597f1fe24570ebdf352ec648

Pick-to: 6.8 6.9
Task-number: QTBUG-128730
Change-Id: I6180ecb09c6a3dee415ae73c11549ee0f709f240
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Toni Saario <toni.saario@qt.io>
2025-02-11 12:17:44 +01:00
David Faure
9dfd8410b0 QMenu: improve test for "empty menu" to be style-independent
This amends commit 353ce5344fbde5a6cecbdd2c131e1cf0f4b7f383 so that
the behavior doesn't depend on the widget style.
If QStyle::PM_MenuPanelWidth returns 2, then size will be (2x2),
which is hardly a valid menu to show - don't show that either.

Pick-to: 6.9 6.8
Task-number: QTBUG-129108
Change-Id: I2daa05932ea00971880747daeffdfa20a8be3f22
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-02-11 12:11:57 +01:00
Marc Mutz
5b52814d64 BenchmarkQtJson: print errorString() on QFile::open() failure
Amends 1c3ee86f183d46709c070ccd44970e05dc70f83d.

Pick-to: 6.9 6.8 6.5
Change-Id: Iaffdbd43fc182a46e1280bc7e023083bbea4a285
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-11 08:07:33 +01:00
Marc Mutz
8113a50d71 qhighdpiscaling: pass QStringView by value
QStringViews should be passed by value, not cref, so sane ABIs pass it
in registers instead of forcing the variable to the stack.

As a drive-by, s/QVector/QList/ in the return type.

Amends 51e2a64ed9360c8e889726c3fbaf649a4d260e0d.

Pick-to: 6.9 6.8 6.5
Change-Id: I6b51dfda87643f6c7ec219ac4a8970537bb6b2ed
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-11 01:51:18 +01:00
Alexey Edelev
c65d6319f9 [vcpkg] Fix the chainloading of the platform specific toolchain files
QT_CHAINLOAD_TOOLCHAIN_FILE might not be set, but
__qt_chainload_toolchain_file falls back to the value initially set
when building qtbase in per-module build scenario. Use the correct
variable(__qt_chainload_toolchain_file) when specifying
VCPKG_CHAINLOAD_TOOLCHAIN_FILE.

Pick-to: 6.8 6.9
Change-Id: I331c305a17172a1cc67a6ed8b43b2baa380abc0b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-10 22:52:51 +00:00
Giuseppe D'Angelo
419ebb2770 Long live QCheckedInt
This is a private and minimal "safe int" API for internal uses.
It has configurable policies for

* how to carry out a given arithmetic operation (check for overflow,
  just do the native language operation, ...);
* how to report an error in case the operation fails (Q_ASSERT, ignore
  it, ...).

By default, operations are implemented via the q*Overflow family of
functions, and Q_ASSERT is used to report errors. This means an
arithmetic error will be fatal in debug mode, and implement wraparound
in release mode. However, UB will be prevented; the compiler will
generate the same assembly, but it won't be allowed to exploit overflows
as an UB source (that's because q*Overflow has well-defined behavior).
In C++26 jargon, the program will have EB at this point.

The class is also supposed to be binary compatibile with the type it
wraps, so that it can be used to replace an `int` data member, without
breaking ABI. (Of course the mangling will be different, but this is an
implementation detail and it's not supposed to be exposed.)

It's woefully incomplete (operator% is missing, for instance); I just
needed a MVP to support the upcoming changes to the geomery classes.

This is meant to stay completely private, users that need a real
implementation should use Howard Hinnart's bbi.

Change-Id: I69ea20e872e395a505c5748f24105469dfb60d84
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-10 23:17:18 +01:00
Thiago Macieira
696e11ec72 QLoggingCategory: remove #ifndef QT_BOOTSTRAPPED
Amends commit 670810787318df8a80b2197b49448c18a78bb7ed from 6.8, which
removed qloggingregistry.cpp from the bootstrap library build.

Pick-to: 6.8 6.9
Change-Id: I3bb5609707478df771b8fffd3e71eb889eaac53f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-02-10 13:19:36 -08:00
Friedemann Kleint
1832ac4d25 uic: Add #ifdef depending on Qt version for QPalette::Accent
Complements 17c589df94a2245ee92d45839c2cba73566d7310.

Pick-to: 6.9 6.8
Fixes: QTBUG-133651
Change-Id: Ieb57df30863f8493cd170d80220ae09177842ede
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2025-02-10 22:19:36 +01:00
David Faure
5ffb9d7ae6 QConcatenateTablesProxyModel: implement roleNames()
Pick-to: 6.9
Change-Id: Id74b45f58678df15285c8b9631db1c59a5d62a2a
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2025-02-10 20:49:37 +01:00
Marc Mutz
f31c37a131 tst_QAnyStringView: test which chars magically convert
QAnyStringView is designed to replace overload sets containing QString
and QChar, among others, so it needs to accept types that merely
implicitly convert to QString and QChar. It achieves this by
maintaining a hidden container to hold the converted QString or QChar
for the duration of the full-expression, much like the compiler would
do if the function took QString/QChar.

This patch adds a check for the single-char ctors to determine whether
they convert or not, by comparing QASV::data() to the address of the
QASV's argument. While it would be interesting to have the same test
for QString, that is outside the scope of this patch.

Task-number: QTBUG-126054
Pick-to: 6.9 6.8 6.5 6.2
Change-Id: I30ac2d1199da5a03fe6fee4c9d5ea2a209a003d6
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-02-10 20:16:50 +01:00
David Faure
eda83d41f6 Doc: document RemoveAuthority and RemoveFragment in QUrl
Pick-to: 6.9
Change-Id: I5ff4898853f1655a902523e7f22344deb5624cc1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-10 19:20:08 +01:00
David Boddie
bddfded80e doc: Fix broken links, including auto-links
Pick-to: 6.8 6.9
Change-Id: I967304c24e1a593b1b555998a718d0a015e12900
Reviewed-by: Jerome Pasion <jerome.pasion@qt.io>
2025-02-10 18:20:08 +00:00
David Boddie
4aff3488b8 doc: Remove invalid link and tone down language
QLatin1StringView::split() appears to be invalid.

Pick-to: 6.8 6.9
Change-Id: I11066b8224cce0a6091c758367f602a63c6136a0
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-02-10 19:20:07 +01:00
Mårten Nordheim
85899ff181 Update UCD to Unicode 16.0.0
They added some new scripts.

There were a few changes to the line break algorithm,
most notably there is more rules that require more context than before.
While not major, there was some shuffling and additions to our
implementation to match the new rules.

IDNA test data now disallows the trailing dot/empty root label,
technically to be toggled off by an option that controls a few things,
but we don't have options. For test-data they changed the format a
little - "" is used to mean empty string, while a blank segment is
null/no string, update the parser to read this.

[ChangeLog][Third-Party Code] Updated the Unicode Character Database to
UCD revision 34/Unicode 16.

Fixes: QTBUG-132902
Task-number: QTBUG-132851
Pick-to: 6.9 6.8 6.5
Change-Id: I4569703659f6fd0f20943110a03301c1cf8cc1ed
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-02-10 18:36:55 +01:00
Laszlo Agocs
037e4f9a5a rhi: Add autotest for continuous readback
Exercises both the fix for the Vulkan/D3D12 readback problems,
and the D3D12 finish() fix.

Task-number: QTBUG-133454
Task-number: QTBUG-133405
Change-Id: Ida34c42a9be0a7913d4e8de9f0676d126fea2523
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-02-10 17:33:23 +01:00
Matthias Rauter
b1c32afb91 Unifty logic in QDomNodeListPrivate::forEachNode
All iterations through QDomNodeListPrivate were going through the
forEachNode function with its own internal logic. The newly introduced
iterator works with the similar logic but is written a bit more compact.

Thus it makes sense to replace the forEachNode logic with internal
functions of the iterator.

Pick-to: 6.9
Change-Id: I22b7ae7a49e2bfaf84bede2fe0b45530a32f8d55
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-10 17:33:23 +01:00
Frédéric Lefebvre
fc0e788d02 Tst_QGestureRecognizer::panGesture set FramelessWindowHint
tst_QGestureRecognizer::panGesture() is flaky as sometimes the gesture
event is being sent before the frame and position has had time to
update. The event then starts in the frame and is not received by the
widget.

Set FramelessWindowHint flag to the widget, to remove the need of
updating its frame position and position.

Fix flakiness on Opensuse 15

Pick-to: 6.9 6.8 6.5
Change-Id: Id88510a91e3ed0d5ff92fdc31422503744448b3e
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-02-10 13:59:36 +00:00
Mårten Nordheim
dc8055c914 QMultiHash: fix/update class description documentation
It no longer inherits QHash, so drop the references to this.

And remove an extra 'and'.

Pick-to: 6.9 6.8
Change-Id: I5c19f7793571fe04f93e0ede37d280d215d95dfc
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-10 14:59:36 +01:00
Edward Welbourne
b37c580169 Add terminal rows to various QtTimeZoneLocale tables
This fixes some read-past-end issues in assertions that verify the
next row of a table after the last for a specific locale belong to a
later locale. Since those assertions happen without sight of the table
of which the locale's range is a part, they can't tell when the
range's end is in fact the table's end - so they shouldn't have been
reading from a row there. Fix by putting a row there, that belongs to
a nominal locale with index out of range.

Pick-to: 6.9
Change-Id: Ib9d227ca4f86c372c13f963a08a8d637eae63ed0
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-02-10 14:59:36 +01:00
David Boddie
4dcff4ed6d doc: Fix broken links and incorrect information
ReadOnly was used in places where ReadWrite was the correct value.

Pick-to: 6.8 6.9
Change-Id: I26a2f0de55665ac015fe269e8e5f0d23a2f00e5f
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-10 13:20:16 +00:00
Allan Sandfeld Jensen
a522a0595b Fix config summary CPU subarch line
Was likely broken by abc888c75bf145bb5da2680b7943f1ea3af83202

Pick-to: 6.9
Change-Id: Ic9ed27255f105272ef60c3a91f3d934c70b91b8b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-02-10 12:41:00 +01:00
Bartlomiej Moskal
5bd26fda7a Android: Fix cursorHandle and EditPopup positions
After the commit 28df9a49776a88cb1a8e69348ae19a59b16a5b7e, a regression
occurred in the positioning of cursorHandle and EditPopup.

Previously, these positions were calculated using QtEditText
coordinates, which worked correctly because the QtEditText size matched
the QtWindow size. However, after the mentioned commit, the QtEditText
size no longer reflects the window size. In this case, we need to use
the parent View for calculations.

This adjustment was already made for the single cursorHandle.

This commit also updates the positioning of selection handles and the EditPopup.

Fixes: QTBUG-132589
Pick-to: 6.9 6.8
Change-Id: I861292e363452d487284e3f603fe03a21a334aa4
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-02-10 12:41:00 +01:00
Matthias Rauter
8609982791 Make QDomNodeList::It bidirectional only
The new (6.9) iterator for QDomNodeList was implemented as random access
iterator. The underlying structure of QDomNodeList is similar to a
linked list and therefore it is better suited for bidirectional
iterator.

This patch changes the iterator to a bidirectional iterator. Further the
tests are expanded because the new implementation uses more custom code.

Fixes: QTBUG-132527
Pick-to: 6.9
Change-Id: I796f445e0b883abc2aea613f1fed6f17c4d93dcd
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-02-10 07:13:50 +00:00
Eskil Abrahamsen Blomfeldt
8de2aae8c1 Remove qt-key extension
This was an extension to make sure we send the full key
event the client was running against a Qt Wayland
Compositor.

But the world has moved on and this is now handled through
official extensions. And we have to support multiple
third-party compositors, so any issues that occur with
key event handling should be handled on a more "official"
level.

Task-number: QTBUG-133223
Change-Id: I96cf394fa0e79eeaeba6dfec0c0fc81f5320fdd4
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2025-02-10 07:32:21 +01:00
Ahmad Samir
f1f610bc67 Qt Timers: disallow setting negative intervals
As disccussed in the code review. Replace negative values with 1ms (not
0ms as that would spin up the event-loop too many times).

Move QTimer::start(std::chrono::milliseconds msec) API docs next to the
method definition so as to not forget changing it when the
implementation changes.

Drive-by, qWarning() and co. are marked cold so there is no need to use
Q_UNLIKELY in an if-condition leading to calling these methods.

[ChangeLog][QtCore][Important Behvaior Change] Timers with negative
intervals aren't allowed anymore, that is, if you try to start a timer
(or set the interval) with a negative value, that interval will be set
to 1ms. Previously Qt timers would let you set the interval to a
negative value, but behave in surprising ways (for example stop the
timer if it was running or not start it at all). This change affects
QTimer, QChronoTimer, QBasicTimer and QObject::startTimer().

Fixes: QTBUG-132359
Change-Id: I09309063665db051337f91160971993d9ce7911e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-10 01:13:29 +02:00
Jukka Jokiniva
d4c312f68a Revert "Blacklist IMAP tests"
This reverts commit 69c992b02c544f7091113111a6fa0ad5c9c80d2c.

Reason for revert: DNS fix was applied to the CI network

Change-Id: Ib6ae4d6e56c35408f64eec33357347e606ba2495
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-02-09 10:24:06 +00:00
Frédéric Lefebvre
6dc0e59393 tst_QGestureRecognizer::swipeGesture set FramelessWindowHint
tst_QGestureRecognizer::swipeGesture() is flaky as sometimes the
gesture event is being sent before the widget's position has
been updated.

The gesture starts in the window frame.

Set flag Qt::FramelessWindowFrame to prevent this from
happening.

Fix flakiness on Opensuse 15

Pick-to: 6.9 6.8
Change-Id: I794b022b5a51146ddfa7d6029509c6fa43b9aad6
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-02-09 00:30:01 +00:00
Tor Arne Vestbø
bddc019829 macOS: Update window flags when updating content border thickness
The titlebarAppearsTransparent property of NSWindow depends on whether
the window has a NSWindowStyleMaskTexturedBackground, so we need to
re-apply the window flags after updating the style mask to ensure we
pick up the updated value for titlebarAppearsTransparent.

Amends a1e6fed44964a3eb14045bf819d232d6cbad9f59.

Fixes: QTBUG-133525
Pick-to: 6.9
Change-Id: Ifff594f54569ac43ad27917e5f4b2f8a3bae5901
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-02-09 00:01:22 +01:00
Even Oscar Andersen
7dd94d74e4 wasm: Truncate input field length to 1px, fix object selection
Having the input field length too wide causes the view to scroll
to contain it. Since it is not visible, setting it to 1px width and
height should work.

Further, input field contents where set on the showInputPanel
call. At this point in time we do not necessarily have an updated
focus object. Hence the input contents is now set on the
setFocusObject call.

Ignore input on showInputPanel/hideInputPanel. This reflects
the current design where showInputPanel do not act unless
inputMethodAccepted(), and hideInputPanel do not act if
m_focusObject.

Still hideInputPanel used to set m_usingTextInput to false,
this behavior is not kept.

Fixes: QTBUG-132057
Pick-to: 6.8 6.9
Change-Id: I2d7088def8060df267c5da9e045824decd913faa
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-02-08 22:18:07 +01:00
Wladimir Leuschner
3d45d22b53 QWindows11Style: Add left margins to Radio/Checkbox indicator
On 150% DPI scaling, the Radio/Checkbox indicators were clipped. This
patch adds an extra margin to the left to avoid this clipping.

Fixes: QTBUG-133117
Pick-to: 6.9 6.8
Change-Id: I2e0186cbdad12481922de5ddf00f50daeb94bb37
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-02-08 20:39:08 +01:00
Edward Welbourne
75d32b923f Remove a spurious static_cast<NumberOptions>
The value being so cast is already of that type, so just return it.

Change-Id: I694826a0fabcde25de69cc7ebbf66c05c8937bcd
Reviewed-by: Magdalena Stojek <magdalena.stojek@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-08 19:33:54 +01:00
Christian Strømme
3c81c89076 rhi: Always check and mark the extra buffers for reuse on metal
It's not just with tesselation we're using these buffers, but also for
multiview, which meant we'd continuously grow the pool until we run
out resources when multiview was enabled. Interesting observation
from this is that newBufferWithLength would 'hang' instead of
returning erroneously unable to acquire a new buffer.

Pick-to: 6.9
Change-Id: Ie30ca44bc7b4b8f29c517fe6c88fafbe46be3d17
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-02-08 18:28:50 +01:00
Edward Welbourne
5a230596c8 Modernise tst_QTextStream::manipulators() and add two new data rows
It was using int for two flag columns; we can pass the relevant flag
types now, and we get better type-checking by doing so. Expand the
integral numeric column from int to qlonglong, since that's the type
we actually end up with by the time we're asking QLocale to do our
formatting for us. Add test-cases for things we've lately noticed
aren't right, notably including the min-qlonglong test (which passes
because compilers handle the UB straightforwardly), that needed the
integral numeric column's expansion. Sign-handling for negative values
in hex fails; a later commit shall fix and remove the QEXPECT_FAIL().

Pick-to: 6.9 6.8 6.5 5.15
Task-number: QTBUG-133269
Change-Id: I39c5339b144b40a30886d8253fa464828ed87629
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-02-08 15:00:00 +01:00
Frédéric Lefebvre
3766b9cb3c tst_QGestureRecognizer::touchReplay give fix position
tst_QGestureRecognizer::panGesture() is flaky as sometimes
the gesture event is being sent outside of the parent. It
is being sent in the window frame instead of in the widget.

Fix position of the parent and verify that it is correct.

Fix flakiness on Opensuse 15

Pick-to: 6.9 6.8
Change-Id: I00eacb80a7e2e658345d3bc56cdef0c0024d1a1d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-02-08 13:49:15 +00:00
David Boddie
787d1db347 Fix or remove broken and outdated external links in qtbase documentation
Change-Id: Ia78b3b16b89ab3f80d990b6e338b4a0f294ab1ed
Pick-to: 6.8 6.9
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2025-02-08 10:10:47 +01:00
Topi Reinio
88e4e952d7 Doc: Clean up output for tabbed content macro
Insert line breaks in the content the \tab macro expands to. This
produces nicer-looking html and also fixes an issue related to
the post-processing done to the generated files.

Fixes: QTWEBSITE-1202
Pick-to: 6.9 6.8
Change-Id: If4e7f7242f8687ef84ad715744653c4167cf907f
Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
2025-02-08 04:30:01 +00:00
Giuseppe D'Angelo
329a2349ae qmath.h: clean up inclusions
We can remove some preprocessor provisions around #include <cmath>:
they're ineffective because <cmath> is actually already included
indirectly (qmath.h -> qglobal.h -> qnumeric.h -> cmath).

Leave the inclusion to honor IWYU, but remove the defines around
it as they're apparently not necessary at all.

While at it, explicitly include qnumeric.h because it's used (for
instance, the qIs* fp classification functions called by qmath.h are
declared in qnumeric.h).

Change-Id: I7d5bf67f518ffd73c81dd78b2bf108df6bbb8186
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-08 04:14:25 +01:00
Liang Qi
5c9fd486ae ibus: use logging category for im debug
Pick-to: 6.9 6.8 6.5
Change-Id: I5397f1fb14273b77833979d3e66056a7110fd2b0
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Inho Lee <inho.lee@qt.io>
2025-02-08 04:14:25 +01:00
Thiago Macieira
cf93005bb1 QSqlDatabase: provide QString defaultConnectionName()
This avoids doing a conversion from 8-bit to UTF-16 and thus allocating
memory on the call to these functions.

Change-Id: Ibed5fc9ef19a21ea475efffdb978f45c1b9b3cc0
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-02-07 18:46:38 -08:00
Thiago Macieira
16aae5a4b8 QSqlDatabase: fix historical mistake of defaultConnection being non-const
This was likely never intended, and was a mistake in the API design,
missing the second const after the pointer. It should have been:
    static const char *const defaultConnection;

This commit fixes that mistake by replacing the variable with a
constexpr one that can't be modified.

We can actually do better by moving the name to the header, so it will
get emitted in each library, application, or plugin instead of trying to
load from QtSql.

[ChangeLog][Potentially Source-Incompatible Changes] The static
QSqlDatabase::connectionName member variable has changed from a
non-const pointer to a constexpr array. Modifying the pointer was most
likely a mistake in code and would produce a misbehaving application.

Change-Id: Icf2eddc865c2d6dde0c7fffda06e55e215e5f26d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-02-07 18:46:38 -08:00
Thiago Macieira
03f6f176b1 QSet: Fix Qt Creator build
Amends commit 68cac07d500851209eab93dec771c45ac4864c8a. One QSet()
wrapping was missing.

Task-number: QTBUG-132500
Change-Id: Iee61f1d6613b0220846afffda3a8212053e2183c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-02-07 18:46:38 -08:00
Thiago Macieira
6069933b57 Q_ASSERT_X: fix build where (where) or (what) were not castable to bool
Amends commit 868645fd3be039e37c96315059ab0b851d022bf4

Code like (qtmultmedia):

    Q_ASSERT_X(QFile::exists(shaderFile), Q_FUNC_INFO,
               QStringLiteral("Shader file %1 does not exist").arg(shaderFile).toLatin1());

Change-Id: Iab02812335384115a689fffd871cd478c7c20046
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-07 17:33:03 -08:00
Matthias Rauter
e4bcd9f1cb Extend testing of QDomListIterator
In preparation of changing the random access iterator to a
bidirectional iterator, the tests are extended to ensure complete
test coverage.

Task-number: QTBUG-132527
Pick-to: 6.9
Change-Id: I8caf93417282631f7982cb12a82b39c00d67c913
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-08 01:52:54 +01:00
Pavel Dubsky
84b7cef139 Move UUID definitions out of Qt namespace
When UUID definitions are placed within Qt namespace MinGW build fails because specializations of struct __mingw_uuidof_s are now defined in a different namespace.

Fixes: QTBUG-133516
Pick-to: 6.9 6.8 6.5
Change-Id: I49270aa2a892d407675dab7b90d3929d120c5224
Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
2025-02-08 01:52:54 +01:00
Laszlo Agocs
01308ff18e rhi: d3d12: Fix finish() when called outside a frame
Pick-to: 6.9 6.8
Fixes: QTBUG-133454
Change-Id: I447610917966a9dcd4b80dc8b84156ce985f9ca9
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-02-07 21:42:17 +01:00
Laszlo Agocs
68e48ac60a rhi: d3d12: Fix crash in readbacks
Amends 73405890b8911dd1a58120665ce63a38281c6ce4. The patch here
does the same for D3D12 as that previous one did for the Vulkan
backend.

Others, like D3D11, are not effected because the loop logic there
does not branch.

Pick-to: 6.9 6.8
Fixes: QTBUG-133405
Change-Id: I88ac7c841dc0c28fc3f6b37c3402315b52de0a66
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-02-07 21:42:13 +01:00
Jan Arve Sæther
f06dd09169 doc: QKeySequence cannot be cast to a QString any longer
bf805455d40b4445f61321439d529cd85cb6bc65 deprecated the QString()
operator in Qt5. Later dccf28b7c344822b7459635099ebe3abdf5fd107 and
2eee9e6fcf9b70681c5d9202d1509d176e48fc31 attempted to remove it
entirely, but a reference to it still remained.

This change also removes the detailed documentation for toString() in
the same paragraph, which previously stated that it generates strings
for use in menus. However, this is not always the case due to
toString(QKeySequence::PortableText). The differences between the two
serialization methods are already well-documented in the toString()
documentation.

Pick-to: 6.9
Change-Id: I42dbb353bc56354f37b8fc22170f8e588eb97176
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-02-07 18:53:32 +01:00
Eskil Abrahamsen Blomfeldt
407a98d94f Improve hinted rendering quality on Windows
When rendering hinted text on Windows with DirectWrite, the goal was
to keep the rendering and metrics as close to GDI as possible,
minimizing the impact of changing the default font backend.

Therefore, the DWRITE_RENDERING_MODE_GDI_CLASSIC was always preferred
when hinting was on.

However, DWRITE_RENDERING_MODE_GDI_CLASSIC only applies antialiasing
in the horizontal direction, but GDI applies vertical antialiasing
as well. The result is that text will look more aliased with
DirectWrite than it did with GDI, which arguably looks ugly
especially at large sizes and can be perceived as a regression.

Microsoft documentation recommends using symmetric antialiasing
when the pixel size exceeds 16, so this patch enables
DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC for fonts larger than
16px regardless of whether hinting is on.

It's worth noting that for fonts with heavy hinting, such as
Times New Roman, the rendering using
DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC is different from
GDI, although more similar to Freetype. However, the impact
of not having vertical antialiasing is worse and as native apps
are moving towards using DirectWrite, the GDI rendering is not
going to be the definition of a "native" look anymore.

A second thing to note in this patch is that we always pass in false
for the useGdiNatural argument in GetGdiCompatibleGlyphMetrics().
According to the documentation, we should be passing in true for text
rendered with CLEARTYPE_NATURAL_QUALITY. However, doing this causes
wider kerning in certain cases. Since the tighter kerning matches
the layouts we get in native apps, as well as when using Freetype,
I've chosen to pass false for now, to be consistent.

This change also adds a manual test which can be used to switch
between DirectWrite, GDI and Freetype rendering on Windows, so
that it's easy to compare.

[ChangeLog][Windows] Improved hinted text rendering at font sizes
larger than 16px.

Pick-to: 6.8 6.9
Fixes: QTBUG-131946
Change-Id: Iebbe5c7affe7df6266ade6b161c31bde3d2caa84
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2025-02-07 18:29:27 +01:00
Christian Ehrlicher
eb03784510 SQLite: Update SQLite to v3.49.0
[ChangeLog][Third-Party Code] Updated SQLite to v3.49.0

Pick-to: 5.15 6.5 6.8 6.9
Task-number: QTBUG-132862
Change-Id: I0978f2d3bd6aab71cded77668912dec4cb569a68
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2025-02-07 17:29:26 +00:00
Marc Mutz
7206f6a39d QStringBuilder: remove an unneeded cast
memcpy() takes void*, not char*, so the cast from QChar* to char* is
not necessary (and potentially harmful).

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5
Change-Id: I7b7178290bd30d93ed9e64b6b84294d0f7576c80
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-02-07 14:38:37 +01:00
David Boddie
3acd5a1951 doc: Fix null-termination function signatures and link
Pick-to: 6.9
Change-Id: I89498714daae5415fa595f0216dd888f4c6b9d33
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-07 13:31:40 +00:00
Mårten Nordheim
69c992b02c Blacklist IMAP tests
For some reason the IMAP server is responding very slowly to the tests,
causing the default 5s timeout to fail. For now let's blacklist them
while the issue is investigated.

Task-number: QTBUG-133548
Pick-to: 6.9
Change-Id: I133a48b14f76566712af72012677bf048740b235
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-07 14:21:21 +01:00
Marc Mutz
40e65f0293 tst_QTextStream::stillOpenWhenAtEnd(): use QTRY_VERIFY()
The test is flaky every now and then on the CI, so increase the timeout from
5s to 20s (a previous TRY_VERIFY precheck reported just shy of 10s waiting
time, doubling should be™ sufficient).

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 6.2 5.15
Change-Id: I8e64bf8ac1576c0ac71790a03936635016b3b2b7
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-02-07 13:21:15 +00:00
Inho Lee
c57da9bb0a textinputv3: implement enableSurface() and disableSurface()
When enter() happens, it got enabled unconditionally. Then in
QWaylandInputContext::setFocusObject(), we need to enable() or
disable() it based on real situation.(If previous enter is
not valid on the QObject, it will be disabled by
disableSurface().)

It fixes the issue for wayfire and kwin/plasma 6. Sway still
has issues with input method events with popup menu, with and
without this patch.(Sway doesn't make keyboard_leave/enter
after surface_enter of popups.) See also
https://github.com/swaywm/sway/issues/4406

Fixes: QTBUG-132196
Pick-to: 6.9 6.8
Done-with: Liang Qi <liang.qi@qt.io>
Change-Id: I5b29a86e0256868c8bcbe48f936c09ee013728a6
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-02-07 09:43:47 +01:00
Xaver Hugl
005927d089 client: fix inverted logic in color management code
It was meant to return nullptr if the entry was *not* found

Change-Id: I69ea904f4a3f61052858b04d018dc2195bc38a8c
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2025-02-06 21:03:23 +01:00
Giuseppe D'Angelo
828cfd5d23 Fix typo in QT_DECLARE_RO5_SMF_AS_DEFAULTED docs
Change-Id: I1f2acc02939171464e05671afcaf3df7ca2b3b8a
Pick-to: 6.9 6.8 6.5
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-06 02:15:19 +01:00
Ivan Solovev
584ac81852 Move qtformat_impl.h into corelib/text
... because it is not really related to IO.
We were choosing between serialization and text, and ended up with
text, because that's where the standard itself puts format [0].

[0]: https://eel.is/c++draft/format.functions

Amends ffac33964d51971a1c1f61308b6f0a60a4133296.

Found in Qt 6.9 API review.

Pick-to: 6.9
Change-Id: I827322175da81bc027a9e136098b7e84677f43f7
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-06 01:52:38 +01:00
Marc Mutz
f080f16123 QFlags: make base class SMFs protected
This is from one of the 90s books on C++ Coding Style:

  Destructors of (public) base classes should be either public and
  virtual or else protected and non-virtual.

The dtors of the various QFlags helper classes were public and
non-virtual, allowing slicing and use outside of QFlags.

Fix both following the rule and making the dtors protected.

Previously, this would have been enough, but Clang started to warn
about undeclared copy- and move-SMFs in the presence of a user-declared
dtor, so need to declare all five.

Found in API-review.

Pick-to: 6.9
Change-Id: I70d1163f7bb42d981bf550418d2775a784bd416e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-02-06 00:52:38 +00:00
Marc Mutz
1a74f77f57 Port qcompare.h to qstdlibdetection.h's Q_STL_ macros
... and add more specific #errors.

There are two distinct error cases here:

- First, someone could add more Q_STL_ macros to qstdlibdetection.h,
  so like a switch with -Wswitch, list them all here and #error out if
  there's a Q_STL_ we haven't yet seen. The audience here is Qt
  developers, via the CI.

- Second, one of the "non-major" libraries (ie. not libc++, libstdc++
  or MS-STL) add support for C++20, specifically the std::ordering
  types as announced by __cpp_lib_three_way_comparison, in which case
  we need to retroactively add the correct unordered value here. The
  audience here is both Qt developers, via CI, but also Qt users.

So separate the two error conditions.

Also, for platforms where we don't know the numeric value of
std::partial_ordering::unordered, use Qt's legacy value, for
potentially faster conversions to/from QPartialOrdering. There's no
point in guessing which value _might_ be used by a future STL, and
swapping STLs is _always_ BiC, so we don't need to guess which STL
will follow the Dinkumware ones on QNX and VxWorks.

Amends 0231f33ad121a85368bb3f43273973b9632735dc.

Pick-to: 6.9
Change-Id: I1d06a18ca5bb26aceb7c76a0f035ecd8d4673547
Reviewed-by: Michał Łoś <michal.los@siili.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-02-06 00:47:04 +01:00
Giuseppe D'Angelo
da71fb9343 QRectF: remove some unnecessary casts
qFloor and qCeil already return int, so the casts aren't necessary.

Change-Id: Ie9df17718d2f32b924c243ae03ef71060e781ec4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-05 20:35:32 +01:00
Andrew Forrest
d908e04398 Android: Fix mouse button processing
Fixes clicking UI elements with a mouse on Android.

8d8cbe87e21f05b7d611ed4be47299977288b267 introduced changes to support
mouse buttons other than Qt::LeftButton, but the release always looked
like no buttons changed, nor were they tracked (m_buttons is always
Qt::NoButton). Qt was not notified of mouse up, so nothing was clickable.

Now all mouse events go through sendMouseButtonEvents, and the last seen
button state is tracked for every event. If a mouse up with no buttons
occurs, the last seen set of buttons is used instead, so Qt correctly
handles the event. Also adds the mouse button state information to
mouse move events from Android, so the workaround for delivering
Qt::LeftButton when a window is tracking a move while a button is
pressed has been removed.

Tested on a Samsung A1 with a Bluetooth mouse.

Fixes: QTBUG-132700
Fixes: QTBUG-130297
Pick-to: 6.8 6.9
Change-Id: I241282c2915d7e6cf99db7f0bc1ad2d541349077
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-02-05 18:29:14 +00:00
David Redondo
9704927844 QScreen: Add a note to use QWindow::devicePixelRatio if possible
Like QGuiApplication does as well. Also add a note that screen and
window DPR can be different.

Pick-to: 6.9 6.8
Change-Id: I1a24cf7f11e945187da9dce4421039350e811997
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-02-05 14:21:19 +00:00
Giuseppe D'Angelo
c10072895d QVLA*: honor the RO5
The various base classes that abstract away template-independent parts
of QVLA have protected destructors to prevent slicing. Re-add the
special 5 (using the macro) and a defaulted default constructor.

Pick-to: 6.9 6.8 6.5
Change-Id: I60f036eafc808862a1abee72fd53023dd99b4cc3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-05 15:00:20 +01:00
Giuseppe D'Angelo
fcb57391f7 QtGlobal: introduce a helper macro for declaring the RO5 SMFs as defaulted
If a class honors the RO0 we usually just leave a comment in the class'
body, and don't explicitly redeclare any of the RO5 special member
functions.

In some cases we may need to redeclare (some of) them. The main use-case
so far is to declare a protected destructor for a base class that is
not polymorphic, in order to prevent slicing; the compiler-provided
destructor is always public.

We can easily declare and default such a protected destructor, but that
comes with the problem that now we're violating the RO5 (as far as C++
is concerned, declaring a SMF counts towards the RO5, even if it's
immediately defaulted).

Specifically: by declaring the destructor, the class loses the
compiler-generated move operations, and the copy operations are
generated but deprecated. Clang >= 18 warns about this.

In such a scenario we *must* redeclare all five SMFs... and default them
all. This is boilerplate, therefore I'm adding a macro to streamline it.

Apply the new macro to a couple of cases were manual refactoring has
already been done.

Pick-to: 6.9 6.8 6.5
Change-Id: I5dc0ff9770621fbec0b1057c164d0623f901e3e9
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-05 15:00:20 +01:00
David Faure
a176f87a64 Linux: autodetect gdb (to add -nograb) even in release mode
Application developers using Qt from their distribution, or from the
official installer, get a release-mode Qt build, where QT_DEBUG wasn't
defined. That's no reason to hit the issue that a breakpoint in
code that gets hit when opening a popup menu should lead to a complete
desktop freeze due to the mouse/keyboard grab.

Pick-to: 6.9
Change-Id: Idf0df03ce5afb792261b62cabb06fab17b5e2952
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2025-02-05 15:00:20 +01:00
Ivan Solovev
737c87b2b2 [docs] Add three-way comparison overview
Task-number: QTBUG-128837
Pick-to: 6.9 6.8
Change-Id: I64ae12994f8a48ee5f4e48ca6ed7f5980476f2aa
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-05 15:00:20 +01:00
Kai Köhne
a0703b6b87 Doc: Fix broken link to QTextStream::OK
Change-Id: I10f7f17410be731b50c0d06ad05d387eaaec07d2
Reviewed-by: Alexei Cazacov <alexei.cazacov@qt.io>
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2025-02-05 12:17:24 +01:00
Kai Uwe Broulik
46809abbb7 doc: Fix typo in Qt Style Sheets Reference
It's QAbs*t*ractScrollArea.

Pick-to: 6.9 6.8 6.5
Change-Id: I94a8d35c40445883a232a8671e56780afffb2e01
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2025-02-05 10:55:53 +01:00
Thiago Macieira
84467d70a8 QByteArray/QList/QString: mark size() constexpr and always in-range
Using the C++20 [[assume]] attribute, which GCC and Clang support in
C++17 mode too. This may help the compiler generate slightly better
code, avoiding the need to check if the size is negative or overflows.

I've also marked count() and length() as constexpr.

Change-Id: Ida6c9a7ba67574a952f3fffd44dea52a0e0e61c2
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-04 22:40:20 -08:00
Marc Mutz
68cac07d50 QSet: add an rvalue overload of unite()
The old QSet::unite() overload cannot really be optimized, because the
RHS set was passed by cref, so cannot be modified, even if it were
already detached.

If we could, we could insert-or-overwrite from the LHS into the RHS
and then swap the two, if the RHS was larger than the LHS. This was
the original idea of 92acc94fa98d19929d28feb5d543acf8c50c2290, which,
however, ignored the implicit detach of the larger set if it was
shared.

So add a unite(QSet&&) overload that, when called, does have the
ability to change the RHS, incl. using it as the base for the
result. We just need a way to insert_or_assign into a QSet, which is
only possible using private API, because QHash never overwrites a
once-inserted key, and that's exactly what we need to perform this
operation while staying consistent with the QSet insertion behavior.

[ChangeLog][QtCore][QSet] Added unite(QSet&&) overload of unite(const
QSet&). Ditto for the `+` and `|` operators.

Task-number: QTBUG-132500
Change-Id: I31592d7bec3b0702e746b69e4f024708ad6a3cc4
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-02-05 07:39:25 +01:00
Mitch Curtis
e426737d73 iOS: send context menu event rather than instantly showing edit menu
This allows Qt Quick items to react to the QContextMenuEvent, rather
than immediately showing a native edit menu.

Task-number: QTBUG-35598
Pick-to: 6.9
Change-Id: Id8f492b549431a42aa26f2d72b418301d2cab3dd
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-02-05 11:08:13 +08:00
Vlad Zahorodnii
a99d09f0b3 Client: Prune stale buffers in QWaylandShmBackingStore
A backing store may sometimes allocate an extra buffer and keep it even
though the buffer is never touched again.

This change makes the QWaylandShmBackingStore clean up the old buffers
more aggressively.

Specifically,

* if a buffer is referenced by the compositor and has a different size,
  there is no need to wait for the buffer to be released, it can be
  destroyed immediately
* if a buffer has not been used for the past 50 frames, it probably
  won't be used any time soon so it can be disposed

Depending on the compositor implementation details, the
QWaylandShmBackingStore is likely to hold either one or two buffers
now. Note that the backing store can still sometimes have more buffers
because Qt widgets not always use QWindow::requestUpdate().

Change-Id: I57428d457d889dd07c4beb641cf380b1aceb88c2
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-02-05 02:34:06 +02:00
Allan Sandfeld Jensen
982fe396e5 Make -platform linux-clang-libc++ work with icecc
It usage of libc++ was never detected if the compiler was explicitly set
to a specific clang binary and clang wrapper.

Change-Id: I5fd3c84223cafedf06b34afe91d975e71c199e24
Pick-to: 6.9
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-05 01:31:34 +01:00
Christian Ehrlicher
82a5e8bdb7 Windows11Style: don't create a QPen when not needed
Use QPainter::setPen(QColor) and QPainter::setBrush(QColor) overload
instead creating a temporary QPen/QBrush to gain advantaged of the newly
introduced QPen and QBrush assignment functions from
ab53500cfa11b988e7e4234583fa6eb5027b4c08

Pick-to: 6.9
Change-Id: I3b8c4f7d669a08558cf6abcc77c23a4fdda99c02
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-02-05 01:04:51 +01:00
Thiago Macieira
23e67332a0 QProcess/Win: Properly report the reason of a fail-to-start
We were losing the GetLastError() by calling CloseHandle(),
QProcess::tr() or just not adding it.

Change-Id: Ic16faa6d68a32d42d620fffd1a8e72be718bf19d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2025-02-04 16:03:51 -08:00
Thiago Macieira
3d007ff2e9 QProcess/Unix: don't close the childStartedPipe too soon
We were accidentally closing it along with all the other file
descriptors if the CloseFileDescriptors flag was active. That meant we
were unable to report start problems back to the parent process.

So instead of closing everything immediately, we simply mark everything
as FD_CLOEXEC so they'll be closed by execve()'s success. Because we're
using CLOSE_RANGE_CLOEXEC now to detect the system call, we don't need
the configure-time test.

[ChangeLog][QtCore][QProcess] Fixed a bug that caused QProcess not to
report start failures if the UnixProcessFlag::CloseFileDescriptors flag
was active.

Pick-to: 6.9 6.8
Change-Id: I4d81d763281354e886d9fffd56ef6ab8b6115715
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2025-02-04 16:03:51 -08:00
Thiago Macieira
030c93add8 QProcess/Unix: update the start error messages to be all similar
The user doesn't care if it happened in the parent process or in the
child.

Windows says "Process failed to start: %1" which is a bit nicer, but I'm
not going to update to that.

Change-Id: If974ba44f84ffc236e48fffd4e48457fac21b248
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2025-02-04 16:03:51 -08:00
Thiago Macieira
675d6fd558 QFile::rename: merge the block copy code with copy()
This greatly simplifies the code and removes the duplication of the
block copy content. For example, it was missing both the file engine-
level copy() and cloneTo() optimizations.

Now a rename across filesystems on Linux will use the OS copy system
calls:
ioctl(5, BTRFS_IOC_CLONE or FICLONE, 4) = -1 EXDEV (Invalid cross-device link)
copy_file_range(4, [0], 5, [0], 9223372036854775807, 0) = -1 EXDEV (Invalid cross-device link)
sendfile(5, 4, NULL, 2147479552)        = 1111
sendfile(5, 4, NULL, 2147479552)        = 0
statx(4, "", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=1111, ...}) = 0
access("x", R_OK)                       = 0
access("x", W_OK)                       = 0
access("x", X_OK)                       = -1 EACCES (Permission denied)
fchmod(5, 0644)                         = 0
close(4)                                = 0
lseek(5, 0, SEEK_SET)                   = 0
fdatasync(5)                            = 0
linkat(AT_FDCWD, "/proc/self/fd/5", AT_FDCWD, "/tmp/x", AT_SYMLINK_FOLLOW) = 0
close(5)                                = 0
unlink("x")                             = 0

As a side-effect, we won't be able to rename files across volumes
without QSaveFile.

Change-Id: Ic864f4833cb21de1e9f7fffd811c5d59a10c9eb7
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-02-04 16:03:51 -08:00
Thiago Macieira
1de95f36c4 QFile::copy: refactor to use QSaveFile
This code mostly existed from before QTemporaryFile, let alone
QSaveFile, and yet duplicated a lot of its functionality. So I'm
choosing to simplify our lives by depending on QSaveFile. As a minor
improvement, the setPermissions() call on Unix will perform an fchmod(2)
system call on the file descriptor instead of chmod(2) on the name.

I've extracted it to a separate function so I can use that in rename()
too. I had to disable the longFileName test on VxWorks because this
fails. With no system to debug why, I can only guess that it's now just
too long.

No ChangeLog because the feature system isn't supported.

Change-Id: I033d677fe090ca3c29d4fffd4024f149402df51d
Reviewed-by: David Faure <david.faure@kdab.com>
2025-02-04 16:03:50 -08:00
Thiago Macieira
fb5b9fd6f3 QFile::copy: remove the fallback to copying through QDir::tempPath()
This would never work: if we failed to create the temporary file in the
target directory, then a later QTemporaryFile::rename() to that name is
even less likely to work. If we didn't have write permissions, we're not
likely to get them; if the disk was so full that we couldn't create a
file, the copying of the data is going to fail too; if the FS is out of
inodes, it wouldn't be able to create the file anywhere either. The only
case where the creation elsewhere would work is if it were a different
FS, but then QTemporaryFile::rename() won't succeed.

Change-Id: I1ba6b9f7050f81163d14fffd79ff4e7460201e86
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-02-04 16:03:50 -08:00
Assam Boudjelthia
d169447627 Android: fix Q_JNI_NATIVE_METHOD() with namespace builds
Prepend the Qt namespace to the JNI method under Q_JNI_NATIVE_METHOD.

Pick-to: 6.9 6.8
Fixes: QTBUG-132490
Change-Id: I73bb8119a0d760e8f7ce82e70ced2684bec76eb0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-02-05 02:03:50 +02:00
Thiago Macieira
0a5b37b706 QTypeInfo: work around MSVC 2022 bug "isRelocatable: undeclared identifier"
Definitely a compiler bug because it passes for everything we threw at
the compiler in the CI but fails for a user. At least the workaround is
simple.

Fixes: QTBUG-133032
Pick-to: 6.9 6.8
Change-Id: Ie84590c466cf1d6f01bbfffd3ca1d6c262d77200
Reviewed-by: Irfan Omair <irfan.omair@gmail.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-04 11:37:46 -08:00
Thiago Macieira
340c9d88ab QUrl: avoid going up from the drive path on Windows file URLs
On Windows, using a URL of "file:///c:/" as a base to be resolved with
"../" should not result in the Windows drive being removed.

[ChangeLog][QtCore][QUrl] Fixed a bug (regression from 6.7) where
resolving a base URL of an absolute file path containing a Windows drive
could result in said drive being removed (e.g., resolving "file:///c:/"
with "../" would result in "file:///").

Fixes: QTBUG-133402
Pick-to: 6.9 6.8
Change-Id: I58286b9c5e5d02363f0efffdb06f983b560340df
Reviewed-by: David Faure <david.faure@kdab.com>
2025-02-04 11:37:31 -08:00
Thiago Macieira
7d05f5ed7d QUrl: set the host to empty but present for "file" URLs
We set it when manipulating full URLs. If you're creating them from
parts, you may end up with one without a host. We will still fix that up
in QUrl::toString() ("manipulates full URL").

This allows the path normalization code to avoid accidentally creating a
URL with no host/authority and with a path that starts with double
slash.

[ChangeLog][QtCore][QUrl] Fixed a bug (regression from 6.7) where
QUrl::resolved() could create invalid URLs when the relative URI being
resolved contained a path with double slashes (e.g., combining
"scheme:a" with "..//b.txt")

Pick-to: 6.9 6.8
Fixes: QTBUG-133403
Change-Id: I3fe9d5fbd2efcaa66d66fffdc010e5a84066b641
Reviewed-by: David Faure <david.faure@kdab.com>
2025-02-04 11:37:30 -08:00
Tor Arne Vestbø
ca250a6372 Document QSurfaceFormat::ColorSpace deprecation
Pick-to: 6.9 6.8 6.5
Change-Id: I894316d0b3df703e5fd07a1c18f579992215e621
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-02-04 20:08:09 +01:00
Tor Arne Vestbø
380a9fdc87 qmake: Find Apple ID via IDEProvisioningTeamByIdentifier for Xcode 16.2
The format of the Xcode preferences has changed, so we need to account
for the new format when looking up the default development team.

The account identifier (previously an email address) was not used by
any consumers of the provisioningTeams() function, so it was left out.

Pick-to: 6.9 6.8 6.5
Change-Id: I81a400000615594336e14c95db86ffa71a5c5ff9
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-04 20:08:09 +01:00
Tor Arne Vestbø
469e4237cf cmake: Find Apple ID via IDEProvisioningTeamByIdentifier for Xcode 16.2
The format of the Xcode preferences has changed, so we need to account
for the new format when looking up the default development team.

Pick-to: 6.9 6.8 6.5
Change-Id: Ib34c2e5245c13db4d81218a5a2460417e4fc6347
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-04 20:08:09 +01:00
Tor Arne Vestbø
ab4aac7bf1 cmake: Add option to pass additional arguments to _qt_internal_plist_buddy
Pick-to: 6.9 6.8 6.5
Change-Id: Icbbfcb7fffa97370c3cdf7440e801eea60de84f0
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-04 20:08:09 +01:00
Tor Arne Vestbø
d688c73e08 cmake: Rename _qt_internal_find_ios_development_team_id
As well as the _qt_internal_apple_development_team_id_computed
property.

It's used for macOS as well, so use `apple` infix instead of `ios`.

Pick-to: 6.9 6.8 6.5
Change-Id: I7932166d094a14ac32cce95e6c9fcbfa44bb97b4
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-04 19:08:09 +00:00
Thiago Macieira
014e77801f Fix detection of -fPIE code for QT_CONFIG(reduce_relocations)
Amends commit 19b7f854a274812d9c95fc7aaf134a12530c105f, which removed
the __PIE__ check because of the GCC version check that was alongside.
GCC and Clang define both __PIE__ and __PIC__ for -fPIE, so checking for
__PIC__'s presence isn't enough.

Drive-by amend the no-PIC #error message to also suggest
-DFEATURE_no_direct_extern_access=ON, which is more modern and produces
better code for executables too. Because of that, I've also changed the
reduce_relocations option to the CMake one, as there is no configure-
style equivalent for the modern option.

Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-133101
Change-Id: I957b264eaee360fd964afffd60617964b26fe934
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-04 11:08:09 -08:00
Liang Qi
facf2c1770 xcb: call qGuiApp->exit() on xcb connection error
Fixes: QTBUG-130741
Pick-to: 6.9 6.8 6.5
Change-Id: I67eff8e58d4a4a8d18fb49699111f72ed9100480
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-02-04 19:08:08 +00:00
David Boddie
9854482835 Fix broken auto-links in QAtomic docs
- There is no load() in Q*Atomic (unlike std::atomic), so link to
  loadAcquire()/loadRelaxed(), depending on context.

- Also remove the template argument, <T>, which prevents qdoc linking.

Amends b62c3a85452aecf4f6c863645db34857b05d5ebf and
329e09a3c303fad1ab001de74924288aae1e7a9d.

Pick-to: 6.9 6.8 6.5 6.2 5.15
Change-Id: I8c58674ffc7e779fee982555edcd45ed40d4c17d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-04 18:07:53 +00:00
Marc Mutz
162015e9c6 Unbreak QSet::intersect()
The selection of which set to iterate over and which one to remove
from based on their relative size violates the function's
documentation, which clearly states that items are removed from *this,
and not from `other`, so the result must never contain any elements
from `other`.

Amends 4f2c96eaa8bfa4d8a6dfb92096e4e4030d0cdea7. Instead of reverting
to the gruesome old code with the forced detach-just-to-remove copies,
distinguish four cases:

- if the two sets are shallow copies of each other, then their
  intersection is *this

- otherwise, if either set is empty, clear() *this. This is required
  for one of the tests that 29017f1395b1bc52e60760fa58c92f6fa4ee4f60
  added to succeed.

- otherwise, if *this is detached, perform the operation in-place,
  using removeIf()

- otherwise, create a new set and move-assign to *this to avoid
  detaching just to remove something again. In this case, we can
  continue to iterate over the smaller set, but we need to keep
  picking elements from LHS into the result.

[ChangeLog][QtCore][QSet] Fixed a regression (introduced for Qt 5.2)
in intersect() that caused equivalent elements of `*this` to be
overwritten by elements of `other` if `other.size()` was larger than
`this->size()`.

Not picking to 5.15, as users will have likely adjusted their code to
the buggy behavior, and because removeIf() isn't available there.

Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-132536
Task-number: QTBUG-106179
Change-Id: Idfa17c3b3589c4eacec27259fc01df6aeaa6c45f
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-02-04 18:07:52 +00:00
Marc Mutz
2d1b302867 Revert "Optimize QSet::unite"
This reverts commit 92acc94fa98d19929d28feb5d543acf8c50c2290.

The change broke QSet ordering guarantees: The documentation clearly
states that each item from `other` that isn't already in `*this` is
inserted ("STL insertion behavior"). Swapping *this and other breaks
this.

Independent of STL vs. Qt insertion behavior, making the picking of
elements from containers "random" in the sense that the size of the
container is now important, and not merely LHS vs. RHS, is a bad idea.

[ChangeLog][QtCore][QSet] Fixed a regression in unite() that caused
equivalent elements of `*this` to be overwritten by elements of
`other` if `other.size()` was larger than `this->size()`.

Pick-to: 6.9 6.8
Fixes: QTBUG-132500
Change-Id: Ia636b62325139d618b5467a643ff710716324296
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-02-04 19:07:52 +01:00
Kristoffer Skau
0b7b02cdb4 Add additional shader variant for HDR support
Both qsb and the batch renderer will generate and use the rewritten
shader for this new variant respectively.

Task-number: QTBUG-126035
Change-Id: I5c4078afcfb22de1e82485459c58d2211958ab7b
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-02-04 17:34:21 +00:00
Kai Uwe Broulik
acb8252d0a QStyleHints: Add menuSelectionWraps
This lifts QStyle::SH_Menu_SelectionWrap to Qt GUI so it
can also be honored from Qt Quick Controls.

Change-Id: I78eb2dd9fe6ad9329d40f7962bf7ad5f07dd4685
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-02-04 17:05:35 +01:00
Tor Arne Vestbø
9afc899a30 Add option to enable/disable tracking in nativetext manual test
Only applies to Qt for now, as I didn't find a way to toggle this for
CoreText.

Change-Id: I79d3da1cf968bd9e5ae756f7633a0c58a227ffd2
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-02-04 15:19:40 +01:00
Alexei Cazacov
32890793ca Docs: fix minor issues with topic naming
Pick-to: 6.9
Change-Id: Iaf8d12743a5f43c355f6960f1da0c6764e622bf8
Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
2025-02-04 16:08:10 +02:00
Ivan Solovev
9860f65229 QProcess/Unix: add an actual check of DisableCoreDumps flag
The original patch that added this feature was disabling the core dumps
unconditionally. I guess the check was simply forgotten.

Amends 9df6e8ad3b3a7a57af87e6a3fef2ef793610cb3d.

Found in Qt 6.9 API review.

Pick-to: 6.9
Change-Id: If3f9cb35d11a0262241a465626a25f6d7d2bbdb4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-04 15:08:10 +01:00
Ivan Solovev
b0364bc263 Bump the deprecation version for WindowType::MaximizeUsingFullscreenGeometryHint
The replacement is new in 6.9, so the deprecation should be done in a
later Qt release.

Amends 90fe9874d22f0c4b809a3e493766ef852c72cc39.

Found in Qt 6.9 API review.

Pick-to: 6.9
Change-Id: If68685f98928015163cd4aa0e65fed2c6578e429
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-02-04 15:08:10 +01:00
David Boddie
575f3b5002 doc: Fix link syntax
Change-Id: Ibb732922f4f31b9fb59dc90d3675e6fd69c47c8c
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2025-02-04 14:08:10 +00:00
Vladimir Belyavsky
7cc0ea0b5a CoreText: prevent colored glyphs (like emoji) to be clipped
To prevent colored glyphs (like emoji) from being cut off at the edges,
we can simply apply the solution from bbba71748438dc05d344bb9727f10b7f55a5d229
to colored glyphs as well (i.e. to glyphs with QFontEngine::Format_ARGB format).

Fixes: QTBUG-133297
Pick-to: 6.9 6.8
Change-Id: I5578e2d12f956d0635b662b3ecf714aa63474945
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-02-04 14:08:10 +00:00
Allan Sandfeld Jensen
d076420bb0 Fix AVX512-FP16 build
Was missing explicit conversion from float to FastType when
FastType isn't float.

Pick-to: 6.9 6.8
Fixes: QTBUG-133430
Change-Id: I227558f6ecc1018158c88514dbb23bfe095ef77f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-02-04 14:08:10 +00:00
Mårten Nordheim
62685375a2 Unicode tool: use unsigned values for the bitfields
On MSVC the values stored end up as negative.

Task-number: QTBUG-132902
Pick-to: 6.9 6.8 6.5
Change-Id: I963c57c34479041911c1364a1100d04998bdfaed
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-04 15:08:09 +01:00
Mårten Nordheim
f7d0366207 Unicode tool: print values using portable types
ssize_t is not universal; fails to compile in Windows.

Task-number: QTBUG-132902
Pick-to: 6.9
Change-Id: I4b8f45cba32202329ac085c7caa0a8c19a11c621
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-04 15:08:09 +01:00
Mårten Nordheim
e99d5c6268 Unicode tool: handle required QFile::open return
Fixing warnings/errors about QFile::open() return value not being
checked, and print the name of the file and the error message that
occurred.

Task-number: QTBUG-132902
Pick-to: 6.9
Change-Id: I099b300b5fd4563334fa547ffa365ec3f68e08cf
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-02-04 15:08:09 +01:00
Mårten Nordheim
c5910d97de Move tldRestrictions from (tst_QUrl) to \1 Internal
It is testing internal behavior - the punycode decoding/encoding

Change-Id: I5b5bab7f47a84cc331cd62a50993be8920e9948a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-04 15:08:09 +01:00
Mårten Nordheim
382a7d006b QUrl: sort idn whitelist
We look it up with a binary search, so it needs to be sorted.

Pick-to: 6.9 6.8 6.5
Change-Id: I0aa25e6ff9722372c0a09f2dce9f9c839fedf00e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-04 15:08:09 +01:00
Giuseppe D'Angelo
868645fd3b Q_ASSERT_X: always consume where and what
Just like `cond` is always consumed to prevent -Wunused warnings,
do the same with `where` and `what`. They're not required to be
literals, but could be function locals that go unused otherwise.

Change-Id: I6b44108c2c040368319a85ec5f34d98930e0794c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-04 14:52:02 +01:00
Jaishree Vyas
43cb7f93a4 Doc: Make C++20 overview visible to the new sidebar
Added the link to the qtcore-toc.

Task-number: QTBUG-130085
Pick-to: 6.9
Change-Id: I765e01aeda0bce694157bf15ff5a036f239168f5
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-04 13:52:02 +00:00
Marc Mutz
0d4fd5c545 QSet: check that unite() and intersect() prefer elements from *this
In Qt versions 5.0..6.7, at least, this used to be the implemented
behavior for unite(). For intersect(), it was implemented up to and
excl. 5.2. Even the documentation states as much:

intersect(): Removes all items from _this set_ that are not
             contained in the other set.

unite(): Each item in the other set that isn't already in this set
         is inserted into this set.

Add checks that the functions behave as documented (hint: they no
longer do, since 6.8 (unite()) and 5.2 (intersect()), resp.), this
being the only correct way to implement these functions (items in
sets may be equivalent, but not identical; it is important that the
set operations work in a manner consistent with insert(), to meet
user's expectation of how these functions work (unite() just
inserts() the rhs, intersect() removes if !rhs.contains). Note that
QSet, unlike other Qt associative containers, actually has STL-style
insertion behavior (insert() doesn't overwrite).

subtract() is the only one that's still true to its docs. A test for
this function will be added in a follow-up commit - eventually.

In anticipation of adding rvalue-other overloads of at least
unite(), add a test with that, too.

Pick-to: 6.9 6.8 6.5 6.2 5.15
Task-number: QTBUG-132500
Task-number: QTBUG-132536
Change-Id: Id309ab5192e6d1c9bbeef496cbd7116d306eaae8
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-02-04 13:52:02 +00:00
Marc Mutz
b6f825a857 Long live qstdlibdetection.h!
I've been meaning to add this since at least 2012 (cf. commit message
of 9180d9aa8bfb9e9f66fad13f194398a98698eb77), this is as good a time
as any.

Detection taken from qcompare.h, except for
- libstdc++: using version macro instead of date one
- Dinkumware, which is taken from the above-mentioned commit (adjusted
  for the LIBCPP->CPPLIB typo),
- STLport/SGI, which are taken from stlport's _stlport_version.h,
- RogueWave, which is taken from Apache stdcxx's rw/_config.h, a fork
  of RogueWave, contributed to Apache by RogueWave themselves.

It looks like not all STLs provide a version macro, and those that do
vary a lot in granularity, so for the time being, just define these
macros to nothing and not to some form of version.

[ChangeLog][QtCore] Added Q_STL_ macros for stdlib detection (libc++,
libstdc++, MSSTL, Dinkumware, STLport, SGI, RogueWave). If your STL is
lacking, please file a bug report. Note that these macros are not
considered public API just yet.

Picking to all active branches, since not picking is more risky (code
that assumed these macros existed in older branches could silently
change behavior if they don't).

Fixes: QTBUG-132908
Fixes: QTBUG-132909
Pick-to: 6.9 6.8 6.5 6.2 5.15
Change-Id: I8f956d131292483b7727f11f69b460b12a06b583
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-04 13:52:01 +00:00
Rym Bouabid
07eeb45d88 ibus: Make address a QByteArray instead of a view in createConnection()
When "address" is a QBAV, it points to line(QBAV) which points to
lineArray(QBA), so its data will be overwitten after every read:
      while(file.readLineInto(&lineArray))

This amends f0aa391ef89a393221d77d5ad3c1616a4727f11a .

Fixes: QTBUG-133445
Pick-to: 6.9
Change-Id: Id23e726327529c44e205c4c0720af0dad42c175b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-02-04 07:51:29 +00:00
Thiago Macieira
4074cc9424 QCoreApplication: make libraryPathsLocked() file-static
Amends 08ad96404b4c915eece1a547bf12e91664e7cdff.

There's no need to have it in QCoreApplication, if it isn't called from
anywhere outside of qcoreapplication.cpp and (now) doesn't require
access to any QCoreApplication privates.

Pick-to: 6.9
Change-Id: I60a929aed02f71d25e00fffdcd42d092d5533cc4
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2025-02-04 00:01:46 -03:00
Thiago Macieira
39b47431fd QCoreApplication: move some content to libraryPathsLocked()
Amends ee0fd8700724848e73c228d973bf72e246077d07 ("Selectively update
library paths when creating QCoreApplication") which introduced
QCoreApplicationData::manual_libpaths. There's no need to have the
separate function in QCoreApplicationPrivate.

Note: the comment near the change seems to be the opposite of what it
really is. I've left it unchanged.

Pick-to: 6.9
Change-Id: I7abd6d7cfcb6747a6ae4fffd32fbf3a6fdf720fa
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2025-02-03 21:01:46 -06:00
Thiago Macieira
d59e640c86 QLibraryInfo: speed up checking if ":/qt/etc/qt.conf" resource exists
Go straight for QResource, because this is run very early in Qt's
initialization, usually as a result of some debug message, via
QLoggingRegistry::initializeRules(). This bypasses the need to create
QResourceFileEnginePrivate, QResourceFileEngine, QFileInfoPrivate, and
QFileInfo, all of which would end up in this .isValid() call.

Additionally, I'm making it query in the C locale, which will also avoid
initializing the system & default QLocales. If a resource exists in any
language, the C locale query will find it.

Pick-to: 6.8 6.9
Task-number: QTBUG-133206
Change-Id: I434b498903d793c12d35fffd3e297bfdbdc1b6fe
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-03 19:01:46 -08:00
Ahmad Samir
e5fbe88708 QDirListing: clarify the ExcludeSpecial flag API docs
Amends e583c3d5163a5512abac85e32359652e28a053f7.

Pick-to: 6.9 6.8
Change-Id: I2ed231990778d03384045bc417efc58a6019fc14
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-04 01:51:23 +02:00
Giuseppe D'Angelo
f744cef06c QSqlQuery: complete the deprecation/removal of its copies
QSqlQuery has been made movable in Qt 6.2
(14f9f00fdb2dc428610c08e3d9d03e38e9602166). The pre-existing copy
operations have been deprecated, but not removed, in order to preserve
SC/BC.

This left us with two issues:

1) Whether or not to keep the deprecated copies in Qt 7. The answer is
no: the copy operations are impossible to implement in a way consistent
with value semantics (the state of the DB driver can't be copied in
general). Therefore, mark the related APIs as to-be-removed, and not
just deprecated.

2) While we no longer copy QSqlQuery from Qt code directly, QMetaType
still detects the presence of the copy constructor and extracts it,
triggering the deprecation warning.

Rather than unconditionally suppressing the warning (which will hide any
similar issue we might have in the future), add a local workaround that
raises a runtime warning if QSqlQuery is copied through QMetaType, while
not raising the deprecation warning when building Qt itself.

[ChangeLog][QtSql][QSqlQuery] Copying a QSqlQuery object via QMetaType
now raises a runtime warning. Note that copy operations for QSqlQuery
objects have already been deprecated since Qt 6.2, and are planned to be
removed in Qt 7.

Fixes: QTBUG-132752
Task-number: QTBUG-91766
Pick-to: 6.9
Change-Id: I48714ad53ec706a5e4e055c45a1c05f372382940
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-02-03 20:54:56 +01:00
Kristoffer Skau
c0e96e0c8b Add QSurfaceFormat::ColorComponentType
This patch adds a new enum ColorComponentType to QSurfaceFromats to
specify the pixel buffer format.

Task-number: QTBUG-126035
Change-Id: I01ef889691b469e54326268ef9d8fbf603367f94
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-02-03 20:54:49 +01:00
Aurélien Brooke
5d857ed3bc rhi: add QByteArray overloads avoiding copies to QRhiResourceUpdateBatch
It seems wasteful to make a copy of the buffer we want to upload inside
the update batch, especially when we construct a large geometry inside a
QByteArray in user code.

Avoid such copies, by creating update/upload overloads accepting a
QByteArray. The received QByteArray is moved inside largeData directly,
instead of allocating a new char[size] and then memcpying into it.

The QByteArray is still copied into smallData if its size is less than
SMALL_DATA_SIZE. This patch only applies to large buffers.

Modify 2 auto tests to use the new uploadStaticBuffer() overload.

[ChangeLog][RHI] Added QByteArray overloads to
QRhiResourceUpdateBatch::updateDynamicBuffer and
QRhiResourceUpdateBatch::uploadStaticBuffer that allow passing large
buffers without copy to the RHI.

Change-Id: I58f41b2f7889d88b565237819c0dcecf90988cb2
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-02-03 20:34:54 +01:00
Jan Arve Sæther
38fc8d845d Do not lie about keyboard shortcut to macOS users
QKeySequence::HelpContents maps to 'F1' on all platforms except macOS,
where it maps to '⌘ + ?'

Change-Id: Ic9b0acdbd686591792fcac1195f03ba334bde3fa
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-02-03 13:01:39 +01:00
Marc Mutz
91f9ba2993 XCB: replace header guards with #pragma once
Following qtbase/1c8884fc277c5916a420a3c14de68547a391f9fc's making
syncqt error out when an installable header contains #pragma once, we
can now flip the coin and use #pragma once as a static assertion that
the given header is not going to be installed, making it easier to
understand which headers are "public", which ones are "private" and
which ones are "neither, since never installed".

Do this for the XCB platform support files.

In qxcbglintegration.h, the header guard was actually broken (had only
#ifndef and #endif, was missing the actual #define).

As a drive-by, normalize vertical whitespace.

Pick-to: 6.9 6.8 6.5
Change-Id: Iede0605c38cda7606edfc7155bd8bfc95990c5bc
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-02-03 11:46:03 +00:00
Tor Arne Vestbø
3d42f31243 macOS: Emit font dialog change when dialog is not active window
The NSFontPanel emits changeFont even when not the active window, and
applications are expected to update their views accordingly.

As the changeFont action message is sent through the responder chain we
were only picking up the changes when the font panel was active, thanks
to the NSWindow delegate we were installing on the panel.

But when the active window is one of our other windows, we were failing
to process the changeFont message in our QNSView.

We now handle the message by forwarding it to the font dialog delegate,
so that we enter the same code path as before, and emit the right
signals for QFontDialog and friends.

Pick-to: 6.9 6.8
Change-Id: I97427c73fe46f129ca11afa6b2c222bf0f0fb0af
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2025-02-03 12:32:58 +01:00
Xaver Hugl
412b1ecd5c client: implement support for the color management protocol
This uses an "experimental" tag of the proposed protocol, which has been implemented by
several compositors. Once the protocol gets merged upstream, this should be updated to
use the final version from that as well.

Change-Id: I8653489fea44f404b759b046cd3fa910dc92479b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-02-02 15:00:13 +01:00
Christian Ehrlicher
678564291d Widgets/styles: don't create a QPen when not needed
Use QPainter::setPen(QColor) overload instead creating a temporary QPen
to gain advantaged of the newly introduced QPen operator=(QColor)
function from ab53500cfa11b988e7e4234583fa6eb5027b4c08

Pick-to: 6.9
Change-Id: Ib29a932a183b629f2c5f3ce32f4e00bd7ab24a03
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-02-01 10:51:14 +01:00
Volker Hilsheimer
1c3ee86f18 Fix warnings in benchmarks from QFile::open being [[nodiscard]]
Change-Id: I8a80af3614a92645be2d64d02ce81e9d263468c8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-02-01 02:44:03 +01:00
Volker Hilsheimer
823c2bfc13 Fix warning from ignored return value of [[nodiscard]] function
Change-Id: I1e293773d70cda1c58c4f3dc798ce2f65224ed9d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
2025-02-01 01:44:03 +00:00
Giuseppe D'Angelo
a74d283216 QNumeric: make the overflowing helpers constexpr
The qAdd/Sub/MulOverflow functions are useful to have in constexpr code.

In fact, they all already have some generic and constexpr-friendly
implementations (but see below).

The only issue is that these functions form a rather convoluted overload
set, which dispatch to different implementations (builtin, intrinsics)
depending on the compiler's capabilities.

Instead, centralize the implementation of the functions, which allows us
to detect if they are being called from constant evaluation and fall
back to the generic code in that case.

* On GCC, Clang, ICC-as-Clang: call the compiler builtin; it's constexpr
  on all the supported versions.

  In fact, make the detection more accurate: the old code excluded all
  Clang versions (incl. ICC-as-Clang) on 32-bit from using the builtins,
  including for addition and subtraction. That seems unnecessary,
  as they work just fine.

  The problem was that, for 64-bit arguments, Clang would generate a
  call to __mulodi4, and that failed to link. We can just special-case
  that; moreover, Clang 14 fixed this issue [1].

  Therefore, detect properly the compiler, incl. the Clang version.

* Otherwise, if we're in constant evaluation, call the generic
  implementation. This poses a problem: on platforms without native
  128-bit support, we are lacking an implementation of qMulOverflow
  when multiplying 64 bit quantities.

  In general, we did not guarantee its availability, but this regresses
  MSVC, which doesn't support __int128 but instead relied entirely
  on its intrinsics to perform 128-bit multiplications.

  To cope with this, add an implementation of a wide multiplication.

* Otherwise, use intrinsics (which are not constexpr).

* Otherwise, use the generic code.

There's a hair in this soup: INTEGRITY seems to only have non-constexpr
builtin (intrinsics), and it's also unable to detect if we're in
constant evaluation. This means that, during constant evaluation, we're
going to hit an error (call to the non-constexpr intrinsic).

Getting rid of the intrinsic and forcing the usage of the generic
version is tempting, but for now, these functions will simply not be
constexpr there.

A few drive-by fixes:

* The aforementioned detection of Clang, so it uses the intrinsics;
* Use Q_CC_GHS instead of Q_OS_INTEGRITY
* A couple of codepaths were checking if we are in two's complement,
  and doing different things otherwise. There is no need for the
  check, we never supported anything but two's complement.

[1] https://godbolt.org/z/v4z6W7qbd

[ChangeLog][QtCore][QtNumeric] The q*Overflow family of functions
are now callable from constant expressions on certain compilers.

Done-with: Thiago
Change-Id: I9fa2ab50a02b31358a916656e5b3329d77344efe
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-01 02:43:06 +01:00
Marc Mutz
cbea57f80b util/update_public_suffix_list.sh: use commit date, not wall clock
This is both more accurate and also more stable: The suffix-list
update usually takes several days to go through all branches; using
the commit date avoids using newer fetch dates in older branches.

Pick-to: 6.9 6.8 6.5 6.2 5.15
Change-Id: Ifefd7158e4104c7bbdfe6a2d8a505d8acf7275b4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-02-01 01:09:31 +01:00
Michał Łoś
2230f51590 Fix compilation for VxWorks ARM64
VxWorks libc for Intel don't have implemented __extendhfxf2 function,
which can be emitted by compiler when converting float16 to 80-bit long
double. When checking Qt6 support for ARM64 it was found that the same
issue applies to ARM64, which causes similar compilation error
(Undefined reference to __extendhfxf2).

Fix this by adding exclusion to ARM64 when testing long double in
tst_qfloat16::ordering() test function.

Change-Id: Ia229677e551cb6d72762c16973dae23b270da7f7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-01 00:06:35 +01:00
Christian Ehrlicher
13636f848d QMenu: Ignore disabled hotkey during hotkey search
When two actions in one menu have the same hotkey and the first action
is not enabled, the action search was selecting the first, disabled
action despite the fact that it could not be selected later on.

Pick-to: 6.9 6.8
Fixes: QTBUG-56952
Change-Id: I894ee09d9ccc7154ca506ef907924cd150ac6ed2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-02-01 00:06:35 +01:00
Assam Boudjelthia
51474d795a Android:CMake: add \cmakepropertysince to packaging type properties
QT_ANDROID_SYSTEM_LIBS_PREFIX and QT_ANDROID_NO_DEPLOY_QT_LIBS were
added in Qt 6.4, but they were missing \cmakepropertysince 6.4.

Pick-to: 6.9 6.8
Change-Id: Ife0f68e79d331f4923d1015431f5af65d80dca36
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-01 00:02:54 +02:00
Assam Boudjelthia
2abc459479 Android:CMake: remove \preliminarycmakeproperty for non-preliminary cases
Those Android CMake properties have been carrying the documentation tag
of \preliminarycmakeproperty by mistake.

Pick-to: 6.8 6.9
Change-Id: I739fee2f078300427557a29b25e1898d57cf04d7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-02-01 00:02:54 +02:00
Giuseppe D'Angelo
79a2cc13f4 QSimd: clean up some -Wundef warnings
While the whole qsimd_p.h file is suppressing -Wundef, the
compiler-supports macros are being used elsewhere, and triggering
warnings in other people's code (qhash.cpp, qfloat16.cpp, etc.).

Amend those macros to do the usual `defined(x) && x` check instead of
just checking for `x`.

Technically speaking expansion to defined is UB, but expansion of
functions is OK on our supported toolchains (we're testing for it).

Task-number: QTBUG-132900
Change-Id: I22b76d49aa32afde7f86d4261ccb33442219ac68
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-31 20:54:27 +01:00
Robert Löhning
42ea8c31fe libinput: Fix developer build without xkbcommon
Before this fix, the build failed with:
error: unused variable 'REPEAT_DELAY' [-Werror,-Wunused-const-variable]
error: unused variable 'REPEAT_RATE' [-Werror,-Wunused-const-variable]

Pick-to: 6.9 6.8
Change-Id: I44a76e2270c1f5d8af6bd018869db5e30e40ecbb
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-01-31 19:54:26 +00:00
Eskil Abrahamsen Blomfeldt
cbce69ebd6 Fix compilation with unofficial DirectWrite headers
Reportedly, some unofficial DirectWrite ports are missing the
default values to the arguments for IDWritePaintReader's
MoveToFirstChild() and MoveToNextSibling(), so we make this
explicit to work around the problem.

Fixes: QTBUG-133336
Pick-to: 6.9
Change-Id: Ia9a01e371e7424508db0d5ad3c75037caaf16854
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-31 20:54:26 +01:00
Alexandru Croitor
65f08c0971 CMake: Wrap path in quotes to avoid issues with spaces in paths
Otherwise running the deployment script fails on macOS with something
like

CMake Error at
 .qt/deploy_qml_app_texteditorexample_32987d3e6e.cmake:1 (include):
  include called with invalid argument:
   2/build/.qt/QtDeploySupport.cmake

due to the following generated content:
  include(build/texteditor space 2/build/.qt/QtDeploySupport.cmake)

Pick-to: 6.8 6.9
Task-number: QTBUG-126827
Change-Id: I8f9923db8dc670a6efbd6f75c48da5dfd1af687d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-31 16:13:49 +01:00
Fabian Kosmale
bda78d0aab Don't manually apply Q_DECLARE_METATYPE to builtin metatype
Change-Id: Iac5b596071ec60a8577394fae13b4681c372369f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-31 15:59:52 +01:00
Lauri Pohjanheimo
5fce67dde2 RenderToRgb10Texture test unblacklisted
Change-Id: I4a7e64e464ea04409154be2e7b3135ecd88a29fc
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-31 16:56:02 +02:00
Tor Arne Vestbø
ca6db761cf Show active font in nativetext manual test
Change-Id: Icdb95fd9318f2401b13aaf0b250403783d887b1d
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-01-31 15:55:35 +01:00
Tor Arne Vestbø
fab7ee3695 Enable emoji insertion menu item for nativetext manual test
Change-Id: I5a8a2179d60ca352da88dc45e42de87b81c6eca4
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-01-31 15:55:33 +01:00
Joerg Bornemann
4d95b6dccd CMake: Stop-gap fix for Qml user projects
We temporarily enable automatic find_package of Qt6FooPrivate whenever
Qt6Foo is find_package'ed, because

1. Currently, Qml user projects are broken unless they set
QT_FIND_PRIVATE_MODULES=ON.

2. The fix for qtdeclarative depends on the submodule update.

3. The submodule update is blocked by QTBUG-133352.

This fixes Qml user projects for people who use latest dev in all repos.

Change-Id: I2c2907e531e908515b51eae1ea90df555e40871e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-31 15:43:17 +01:00
Liang Qi
9379b95b53 Fix dangling references - GCC 15
This amends 8a6750475410629741de0417c28f574c25c65338 and
18def77d27f88ce26b6af29fe56a80429fed555d.

Pick-to: 6.9 6.8
Change-Id: I31068527458da3d25211743fb64e2624039bd78b
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-31 11:50:22 +01:00
Giuseppe D'Angelo
937ccb466a Test that macro expansion to defined actually works
Macros can't include preprocessing directives in their expansion, both
in C and in C++; the behavior is undefined otherwise. In fact, there is
implementation divergence for object-like macros even between GCC/Clang
and MSVC [1], so relying on this is dangerous. For this reason,
compilers emit warnings.

However, function-like macros work as expected [2] on all three
compilers. The new preprocessor for MSVC will also align it to GCC/Clang
for object-like macros, but it's not enabled by default in any C++ mode
[3]. Changing that is out of scope for this patch.

Interestingly enough, Clang already does a distinction between
object-like macros (warns *unconditionally*) and function-like macros,
where the warning is only enabled by -Weverything or -pedantic. GCC
lacks this distinction, and enables the warning on -Wextra or -pedantic.
[4]

There's a major use case for expanding defined into a function-like
macro:test whether another macro is defined and, if so, if it has a
non-zero value.

This can be done with something like:

  #define CHECK_HAS(X) (defined HAS_##X && HAS_##X)

  #if CHECK_HAS(FOO)

These kind of checks are useful in qsimd_p.h, masm in qtdeclarative, and
maybe other places. Alas, they will trigger -Wexpansion-to-defined
warnings due to them being formally UB. We can suppress this warning
because we know that the compiler does the right thing, the testing of
which is point of *this* patch.

This has positive value over *not* doing this and risking people doing
this kind of checks instead:

  #if HAS_FOO

(that is, the status quo) because the latter exposes people to bugs:

  #if HAVE_FOO // whops! was HAS, not HAVE
  #if HAS_FO0  // whops! typo

These bugs would be caught by -Wundef, that I'd like to enable, because
we've just had to fix a brown-paper-bag one. So the trade-off will be to
enable -Wundef, and ignore a "formally UB but works on all compilers"
warning, which I'm therefore suppressing.

Granted, in an ideal world, we would instead have HAS_FOO always
defined, to 0 if not enabled and to 1 if enabled. This would let us use

 #if HAS_FOO

and have -Wundef warn in case of typos. However toolchains don't do this
for platform-specific macros, and there's still the issue of 3rd party
code. We could work around that by pre-defining our own QT_CHECK_HAS_FOO
to 0 / 1, but that would require centralizing the macros (we'd centrally
need to do define every possibility), which is what some of these macros
don't want to do by design.

[1] https://github.com/llvm/llvm-project/blob/main/clang/lib/Lex/PPExpressions.cpp#L167
[2] https://gcc.godbolt.org/z/hG3zzbhaj
[3] https://learn.microsoft.com/en-us/cpp/build/reference/zc-conformance?view=msvc-170
[4] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118542

Task-number: QTBUG-132900
Change-Id: Ie4d28cfe91e6e9a8e7eedf92d5fa18913218817b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-31 11:48:32 +01:00
Cristian Le
b71647d069 Check for misspelled FEATURE_* variable
The feature names are normalized using `qt_feature_normalize_name`, but
a user might read `qt_feature` usage and not realize that they should
normalize the name in the `FEATURE_*` variable.

This change emits an error if it detects such invalid names.

Fixes: QTBUG-132464
Pick-to: 6.8 6.9
Change-Id: I33c7ab9f589c92e11e16d376660e8b6152339d12
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-31 11:24:10 +01:00
Giuseppe D'Angelo
ff0f038ea6 QRect: warn about int overflows in debug message
We now print the correct width/height of a rectangle, but we should warn
users that the rectangle so built is overflowing the `int`
representation.

Amends 0f336500a0add3e3a8bb31c5cc605e5e13e23833.

Change-Id: Iaed0f3c7457e37e80a9d5efad940d498aa059bd4
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2025-01-31 11:04:57 +01:00
Marc Mutz
3a284dc19d QSet: don't detach in remove()/removeIf() if nothing is being removed
QSet::remove() calls QHash::remove(), which unconditionally detaches,
so fixing the detach there, by pulling the isUnused() check to before
detach(), fixes it for both.

For removeIf(), the old code used begin()/end() for iteration,
detaching unconditionally, even if nothing was removed in the end.

In this case, fix by using cbegin()/cend(). That delays the detach()
until the first erase(), where it belongs. The end() iterator of QHash
(and therefore QSet) are stateless sentinels in all but name, so we can
continue to cache end(). Add a code comment to that effect.

Amends 62dad9be9e172597c56a970202299563aa04918e (for removeIf()) and
5b7c3e31b538376f2b4733bd868b5875b504cdb3 (for remove()).

[ChangeLog][QtCore][QSet] remove() and removeIf() no longer
unconditionally detach, but only if something is actually being
removed.

[ChangeLog][QtCore][QHash] remove() no longer unconditionally
detaches, but only if something is actually being removed.

Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-106179
Fixes: QTBUG-132831
Change-Id: I807577eafa1be478b0a2da45cf8c44936d5e48ed
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-01-31 05:36:16 +00:00
Marc Mutz
9f4325e673 QDuplicateTracker: shed memory_resource on clear()
The pmr::monotonic_buffer_resource ("pmr::mbr") strategy can only
allocate buffers; deallocation is a no-op. I chose it for
QDuplicateTracker because the tool was only used one-off: build it,
then destroy it. There were no other operations.

That changed when 090c7e3262dce93df83c73a4a822761e5d9b4650 added
clear().

Calling pmr::unordered_set::clear() will deallocate the nodes (but not
the bucket array), but due to pmr::mbr, nothing is actually
deallocated, so memory that was freed by the container isn't actually
reused by it, later. IOW: repeated grow-clear-grow-clear cycles would
forever grow the monotonic_muffer_resource, using more and more memory
and thus appear to be leaking it.

This isn't exactly optimal behavior, so try to shed the pmr::mbr's
extra memory with a call to mbr::release().

Unfortunately, C++17 originally failed to nail down the semantics of
pmr::mbr::release(), prompting LWG 3120 in response to observed
implementation divergence. In particular, MSSTL, at the time of LWG
3120 filing, didn't appear to allow to allocate() after release(). In
our tests, it does allow it, it just never falls back to the original
(stack) buffer, and, looking at the implementation, it doesn't look
like it can do so anytime soon (it doesn't remember the buffer, and
everything is inline, so they would seem to need a BC break to fix it.

We tried to work-around the problem by hard-resetting 'res' by going
through a destroy-recreate cycle. pmr::mbr is neither copy- nor
move-constructible, so that blunt instrument is, unfortunately,
necessary (std::optional would be an alternative, but has overhead
that affects all platforms). This crashed, though, so just call
release() and handle MSSTL's failure to reuse the initial buffer as a
QoI issue.

For all platforms, before release(), we also need to make sure that
`set` no longer holds any references into it, and, since clear()
doesn't shed capacity, we need to use the C++11 version of the
swap-trick (swap is actually UB here, because the allocators differ):
move-assign a default-constructed set.

Amends 090c7e3262dce93df83c73a4a822761e5d9b4650.

Fixes: QTBUG-132945
Pick-to: 6.9 6.8 6.5 6.2
Change-Id: I4796806e427602255439dcb1518aa9b661c7933e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-31 06:35:50 +01:00
Marc Mutz
2c212e15f8 QObjectData: Return const QMetaObject* from dynamicMetaObject() already now
It's semi-private API (ie. undocumented) and for most platforms¹, the
change is a no-op, which is why the approach here is a bit different
than your usual REMOVED_SINCE:

Normally, when only the return value changes, we mark the new overload
as QT6_*_NEW_OVERLOAD to allow the two function to coexist and the old
function to call the new one.

But the extra argument backing QT6_*_NEW_OVERLOAD would change the
mangling of the function even on platforms that don't mangle the
return type (the majority), and we'd have to decorate all calls that
could possibly be seen by QtCore's removed_api.cpp TU with
QT6_CALL_NEW_OVERLOAD. The main user of the API is moc-generated code,
though, and so I didn't want to have to change moc's output, even
though, currently, nothing in removed_api.cpp includes moc-generated
code. But it may, at some point in time.

This means I needed to grasp the nettle and duplicate the (granted,
trivial) implementation. Even a private helper function would mean
(maintenance and runtime) overhead for "normal"¹ platforms, so I opted
not to go there, either.

¹ those that (rightfully) don't mangle the return type, ie. all except
  ... MSVC.

As a benefit, we catch the mistake of modifying the dynamic
QMetaObject under the object's radar already now.

[ChangeLog][Potentially Source-Incompatible Changes][QtCore][QObjectData] This
(undocumented) class' dynamicMetaObject() function now returns a const
QMetaObject* (was: non-const). The backwards-compatible fix is to
receive the result in a const QMetaObject* variable (or to use auto),
and applying a manual const_cast, if a non-const object pointer was
actually required. Modifying the meta object that was returned by this
function was never supported and may lead to problems elsewhere.

Amends 0b044e8b055f9c1d93b278ed69aba76f7c886cb1.

Pick-to: 6.9
Change-Id: I4ebc43018a2a87433ab7a97554196842b97cf1ba
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-31 05:35:14 +00:00
Thiago Macieira
e19b633c46 QTest: fix bug dereferencing nullptr in toString<std::nullptr_t>()
Amends commit 0756cc1eae5fd8981983319fef1d084762a67b8d.

The generic instantiation of this function had a std::nullptr_t *
parameter, but callers had special code to pass a nullptr there because
we never needed a value of a nullptr (it's always a null pointer). For
example, in compare_ptr_helper():

        auto lhsFormatter = Internal::pointerToString<QObject>;
        auto rhsFormatter = Internal::genericToString<std::nullptr_t>;
        return compare_helper(t1 == nullptr, "Compared QObject pointers are not the same",
                              const_cast<const QObject *>(t1), nullptr,
                              lhsFormatter, rhsFormatter, actual, expected, file, line);

But in debug mode, some compilers did emit a load from this memory
location, causing a crash. So we just specialize this function to avoid
such.

We had a test for this... except it was never reached because the
earlier QCOMPARE() had already failed. For the test, this amends
commit ae021882330abc5f6fbaadca290e6e5670c89028.

Fixes: QTBUG-133330
Pick-to: 6.9 6.8
Change-Id: I2cd3bb475788431c6a0dfffd28e730e8b613e033
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-01-30 15:57:07 -08:00
Assam Boudjelthia
91d86e4f7a Android: add note about using qt_add_android_permission()
Pick-to: 6.9
Change-Id: Ie8d48ce1460b6f7fe4023f204be8fd2511cabe4d
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-31 01:14:36 +02:00
Assam Boudjelthia
40e18c7c7e Android: add note on using custom AndroidManifest.xml for permissions
Setting permissions manually require the user to point to the manually
managed AndroidManifest.xml file.

Pick-to: 6.9 6.8
Change-Id: Iae289ad32a12f869a5a0ec0261bc3e771d94a15d
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-31 01:14:35 +02:00
Alexandru Croitor
5717a4fd4a coin: Enable git cloning
Cloning the git sources will:
- allow embedding the git sha1 into the SBOM generated by the build
system
- ease development process in CI VMs when investigating issues.

This will slightly slow down the CI build phase by a minute or two.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Task-number: QTQAINFRA-6520
Change-Id: If554ed0fedca26ff77d04752288ee8497bc4b9ce
Reviewed-by: Toni Saario <toni.saario@qt.io>
2025-01-30 22:32:40 +01:00
Giuseppe D'Angelo
5b00521ecf qAbs: check that we're not overflowing
qAbs shouldn't produce a result if that is not representable by the
return type. Not only that, but attempting to negate an integral type
may trigger UB. For instance, if one calls qAbs(INT_MIN), the code will
attempt negating INT_MIN, causing UB.

Add an assert that checks that the return is representable.

Formally, things are slightly more tricky, because the unary operator-
applies integral promotions before negating the value. This means that
something like qAbs(short(SHRT_MIN)) is actually well-defined behavior,
although extremely surprising. Inside qAbs:
* the unary negation will promote the argument to `int`;
* the negation is well defined (will produce `SHRT_MAX+1`, in range);
* the result of the ternary operator inside `qAbs` is, indeed, `int`;
* the return type is `short`, so there's an implicit conversion from the
  returned expression to the returned value. This conversion is implicit
  and well-defined even in case of overflow. The fun bit is that it will
  yield SHRT_MIN (!), a negative number.

So, rather than checking that the applying unary minus to the _promoted_
type doesn't yield UB, I'll check that we're not dealing with the
minimal value of the input type.

Change-Id: I26fbbf10d3a3ac333876864cff74422cb4cdafb9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-30 22:32:40 +01:00
Marc Mutz
5c20f9aa5c QPainterStateGuard: also check for nullptr painter in save(), restore()
The ctor refuses to be called with a nullptr painter, but a moved-from
QPainterStateGuard object _will_ have a nullptr painter. An assert
gives a slightly nicer error message than "nullptr deref".

Extract Method verifyPainter() to not litter the executable with
string literals for every one of the these functions (some compilers
don't use the leeway extended to them by the standard to fold duplicate
string literals).

Found in API-review.

Amends ec3a5f4994a2bafc65fa8e01fb0861219580f622.

Pick-to: 6.9
Change-Id: I562e6a0ff5a4c8ce86418b998ed78c501441b61a
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2025-01-30 21:23:34 +00:00
Edward Welbourne
d6025aa054 Simplifications in QJalaliCalendar
Change-Id: I5e777453833dd1604fc05afb3bd06d5dd5a49dec
Reviewed-by: Magdalena Stojek <magdalena.stojek@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: MohammadHossein Qanbari <mohammad.qanbari@qt.io>
2025-01-30 23:23:33 +02:00
Edward Welbourne
cd442e439b Change handling of unspecified year in QCalendar::daysInMonth()
Previously, this was specified to return the usual number of days in
the month. What the date-time parser needs, though, is the longest
that the relevant month can be, in any year. So change its
specification to that. This affects all calendar backends, effectively
requiring daysInMonth() to treat Unspecified as if it were a leap
year.

[ChangeLog][QtCore][QCalendar][Important Behavior Changes] The
daysInMonth(month, Unspecified) corner case is now specified to return
the greatest number of days in that month across all years, where
previously it returned the usual number of days in the month. This
means QCalendar().daysInMonth(2) is now 29 rather than 28, with
similar for other calendars than the Gregorian default.

Change-Id: I165599c655df9fbd77700ed38d8860a4e5cca881
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-30 23:23:33 +02:00
Edward Welbourne
b612286696 Rework QLocale::uiLanguages()'s order
On back-porting commit 7f9ee43de783105d8de0a0b614751eec639131f8 to
6.8, I worked out how to move the maximal version of each locale ID to
the front, while keeping it after a shorter ID that can't be derived
from it. Forward-port a refactored (and more systematic) version of
those changes now to dev (and thus 6.9) so that we get reasonable
compatibility between versions (albeit with 6.8 still lacking
truncated forms, since its QTranslator takes care of those).

This, however, brought to light a problem in the subsequent addition
and insertion of truncations. Since non-equivalent truncations of the
maximal version may (and often do) use the same script, they match
equivalents that are now later than the maximal one, which caused all
truncations to be appended, where some should be inserted just after
the equivalents. Furthermore, had the truncations of the maximal one
been inserted, they'd have appeared just after it, before some of its
equivalents, where it should be after. Reworked the handling of
truncations to take account of the fact that entries come in blocks of
equivalent forms; any truncations inserted instead of appended should
be inserted after this block, not between its members.

Adapt tests to match. As a "drive-by", shuffle some Punjabi tests so
that the comment that applies to two of them is followed by those two.

Pick-to: 6.9
Task-number: QTBUG-131894
Change-Id: I67ea21cf279e8a3b2e8413c27ac0fa5dfabdaca7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-30 22:23:33 +01:00
Alexandru Croitor
062a7dc424 configure.bat: Use call when calling the helper cmake scripts
If an executable has a .bat or .cmd extension, and is executed without
a prepended 'call' command within a batch script, the parent batch
script execution will not continue once the child process has
finished.

Prepending call to the command ensures that the parent batch script
continues execution.

This changes ensures that configuration succeeds for the use case when
cmake is actually a batch script called cmake.bat or cmake.cmd.

We already use 'call' in qt-configure-module, so do it also in
configure.

Pick-to: 6.8 6.9
Change-Id: Ia42cb71787e88c850f1cbd1fcef5b6decbdeaabf
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-30 22:18:36 +01:00
Volker Hilsheimer
8563ed5405 Fix warnings in tests from QFile::open being [[nodiscard]]
QVERIFY the result, with filename printed if useful.

Change-Id: I1b21e213856458b7bc36682dd3671bd29c437b99
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-01-30 22:18:36 +01:00
Marc Mutz
a4fd95c51a tst_QSet: check whether QSet::removeIf() can modify elements
It can't, pfew. Was wondering for a moment, but of course, even the
QSet::iterator is really a const_iterator.

Pick-to: 6.9 6.8 6.5 6.2
Change-Id: I85caa64c1caca6d77569aa2ceb868a4aa0e5578d
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Magdalena Stojek <magdalena.stojek@qt.io>
Reviewed-by: Lena Biliaieva <lena.biliaieva@qt.io>
2025-01-30 22:18:36 +01:00
Marc Mutz
768ab20517 qpen_p.h: include what you need
In QtCreator, the file lit up like a Christmas tree from all the
undefined types :)

Amends the start of the public history.

Pick-to: 6.9 6.8 6.5 6.2 5.15
Change-Id: I558ad493a4848e6a28bd37a38f2432c5605e0f43
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-01-30 21:18:36 +00:00
Marc Mutz
530b2e1fc7 QtGuiTest: remove Q_NAMESPACE
There are no Q_ENUM/Q_FLAG/Q_INVOKABLEs defined in it, so drop
Q_NAMESPACE. We can always add it back in when something is added to
it that does require a meta object.

Found in API-review.

Amends 5ac4f04325a56d47812f528fe31ceb0d4932f664.

Pick-to: 6.9
Change-Id: I8b197f2cd835d1fe4893f2e9608dcaf0ffd14cd9
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-01-30 21:18:35 +00:00
David Redondo
7fcfc37905 QDesktopUnixServices: Fix #endif comment
So it doesn't confuse me or anyone else again

Pick-to: 6.9
Change-Id: I8ad5d4cb1b00e0edaffa90ed67e30246211e1a97
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-01-30 19:47:27 +00:00
Marc Mutz
d769ca41fc QPen/QBrush: de-inline compare helper functions
These functions expose implementation details of their respective
class, so, seeing as the classes are pimpl'ed and their op==s are
out-of-line, too, these functions ought to be out-of-line, too.

De-inline them, by calling a private out-of-line helper function. This
way, they can remain unexported and "real" hidden friends (= with an
inline definition).

As drive-by:

- in QBrush/QColor: check the properties in the order of cheapness
  (style(), color(), transform()), and don't copy QTransform just to
  check isIdentity() (access the member directly).

- in QPen/QColor: avoid the QBrush copy (access the member
  directly). This also retroactively endorses the noexcept on this
  function.

- in QPen/PenStyle: amend the comment that says it's allocating with a
  `// ### optimize`

Amends f0186862e16128343705abd0de5994e8ca05a909.

Found in API-review.

Pick-to: 6.9
Change-Id: Ibfd43b1f2200ef030d6739dad1bf026cc190606b
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-30 15:33:19 +01:00
Marc Mutz
c05982fda3 q17::uninitialized_value_construct: use C++17/20 semantics of voidify
While LWG 3870 changed the const/static_cast'ing for C++23, this is
q17, so use the C++17/20 semantics of casting away const- and
volatile-ness.

Found in API-review.

Amends 364ac13a79a8fff0447a62e9af5588db397c0bfd.

Pick-to: 6.9
Change-Id: Ie11589cbc96b8c3c36deaa6101a897f527d92a46
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-30 15:33:19 +01:00
Ivan Solovev
8511149d88 QSharedPointer: document rvalue overloads of various cast methods
The patch provides two documentation snippets: for an arbitrary arg
and for \c {*this}. That is because qdoc does not support passing
a command (e.g. \c) as a part of the snippet's parameter.

Amends e95fb04202b3f786037c10942fd4e912644fd7d2.

Found in Qt 6.9 API review.

Pick-to: 6.9
Change-Id: I4eed234d18e39f2fc0c30a647a423f3240e31d40
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-30 14:33:19 +00:00
Aurélien Brooke
2ef55de102 QProperty: replace a malloc() + memset() with calloc()
Change-Id: I748387b7012496423fb4f9ee7381a984f985d4d2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-30 10:38:57 +01:00
Aurélien Brooke
41c47fdd19 QArrayDataPointer: use Data::deallocate() instead of raw free()
Be symmetrical with the Data::allocate() in the constructor.

This is not strictly a no-op since we now call the exported symbol
QArrayData::deallocate() instead of inlining a free() call. However, it
allows future sized-free optimizations.

Change-Id: I2ef00a897f56a32a0f1188f69f159834e6ca5b64
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-30 10:38:55 +01:00
Aurélien Brooke
ed7d59c0a2 QArrayData: inline the allocateData function
It is already inlined by the compiler so this is a effectively a no-op.
The aim of this change is to make later work in this file cleaner and
easier to review.

Deduplicate the if check and alloc assignment, and remove the
unnecessary qsizetype cast.

Change-Id: I139f1132779ce4c583a5be689800940801142d36
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-30 10:38:51 +01:00
Frédéric Lefebvre
5229cba24f Add white space after double slashes in tst_qprogressbar and Q_OS_MACOS
Add white space after double slashes in tst_qprogressbar.cpp where
missing.

Change Q_OS_MAC for Q_OS_MACOS

Change-Id: Ifa7876e7de008ccbb6bcd2ee038e3f35416ed84b
Reviewed-by: Magdalena Stojek <magdalena.stojek@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-01-30 09:24:00 +00:00
Frédéric Lefebvre
e965d8a3ab Remove QString::fromLatin1 as not required in tst_qprogressbar.cpp
Remove QString::fromLatin1 in tst_qprogressbar::formatedText_data() as not required.

Make the code more tidy and easier to read.

Change-Id: I2437cfa1430270b6f045a5dfddc0114d5127d305
Reviewed-by: Magdalena Stojek <magdalena.stojek@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-01-30 09:23:44 +00:00
Liang Qi
1c0406ee17 tests: Skip tst_QClipboard for Ubuntu 24.04 GNOME/X11
Sometimes test causes kernel crash. Test is skipped until
gnome-shell 46.1 or newer is backported to Ubuntu 24.04 LTS.

See also https://bugs.launchpad.net/ubuntu/+source/gnome-shell/+bug/2095396

Task-number: QTBUG-132070
Pick-to: 6.9 6.8
Change-Id: Ia1c7f1737e225189b86cb2b2d2ff68a7cc1e838c
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-01-30 10:19:02 +01:00
Thiago Macieira
0f128fd7c5 QDataStream: move the QChar streaming operators to qdatastream.h
That frees qchar.h/cpp from having to know about QDataStream.

Change-Id: I7c217e32021f67ab27ecfffd47ba5ee025ecb1bf
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-01-29 19:22:20 -08:00
Marc Mutz
ac5ab8ce32 Don't export ~QESDP<QFontVariableAxisPrivate>
It's not needed, cf. QTBUG-128656 and
qtgraphs/6ae7164a5432bc49d7e9688dfd79c20515dd9333.

Found in API-review.

Amends cc128d802c6d9c87a1e00a8a88d5e6590a7195f4.

Pick-to: 6.9
Change-Id: I3860ea5ac3d17590b1134af40927387f19dea640
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-30 01:38:10 +01:00
Joerg Bornemann
d39f9a2af7 CMake: Fix package dependencies of Qt plugins
In a static build of Qt, building a QtGui user project pulled in private
Qt module packages. This happened, because plugins link against private
Qt modules, and we must wrap those link dependencies in
$<BUILD_LOCAL_INTERFACE> / $<BUILD_INTERFACE>.

This amends commit ad7b94e163ac5c3959a7e38d7f48536be288a187.

Task-number: QTBUG-87776
Change-Id: I45f919b7c0cbc9edf40a4818030de984b4afcc0c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-30 01:13:46 +01:00
Christian Ehrlicher
e0a44cd32e QMenu: Simplify check for SH_Menu_AllowActiveAndDisabled
The check for SH_Menu_AllowActiveAndDisabled is done in eight places.
Simplify it by added a helper function which checks if an action should
be considered (i.e. is not a separator, is enabled or
SH_Menu_AllowActiveAndDisabled is enabled).

Pick-to: 6.9 6.8
Task-number: QTBUG-56952
Change-Id: I65c6dc67b804dd4c5cf463767a525ec6f785bf1a
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-01-29 20:08:49 +01:00
Giuseppe D'Angelo
8e843ddba8 QProgressBar: prevent integer overflow
If `value` is INT_MAX and `lastPaintedValue` is -1 (the default), the
subtraction will overflow. Extend the arguments to 64 bits. The result
is only used for a double comparison anyhow.

Change-Id: Id4a5396c61da81932ac626b3102e583a74264df4
Pick-to: 6.9 6.8
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-01-29 20:05:18 +01:00
Giuseppe D'Angelo
45e90b73c7 QDateTime: prevent signed integer overflow
While the code checks for the possibility that leftMillis-rightMillis
may overflow, it fails to take into account that the result may be
minimal ("INT64_MIN", so to speak) and passes it to qAbs, triggering UB
in there. Since it's just a range check and we don't need the result to
be signed, use qUnsignedAbs.

Change-Id: I7f1a4bbc521fdc164ca20fedf0e995359a67ea4d
Pick-to: 6.9 6.8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-01-29 20:05:07 +01:00
Yifan Zhu
8a6d564a64 client: update mouse position on enter
Otherwise cursor position is not correctly set after a wl_pointer enter
event.

Fixes: QTBUG-133204
Pick-to: 6.9 6.8
Change-Id: I444fb63093ae08ae37f1e5b2863fb19fc7bb240a
Reviewed-by: David Redondo <qt@david-redondo.de>
2025-01-29 09:47:33 -08:00
Marc Mutz
15154fa4c5 QDuplicateTracker: don't value-initialize the stack buffer
The typical usage of a QDuplicateTracker should be to pass the
guesstimate for the number of entries as a constructor argument, or,
failing that, default-construct the object. In those cases, everything
is peachy:

   QDuplicateTracker<int> seen(n);
   QDuplicateTracker<int> seen;

But for users that subscribe to a AAA view and use

   auto seen = QDuplicateTracker<int>{};

or that emplace() a QDuplicateTracker in e.g. std::optional, we need
to make sure that value-initializing QDuplicateTracker doesn't
value-initialize the internal buffer (which can be several KiB in
size).

So don't = default the default ctor, but implement it as empty.

Amends f21a6d409ea0504c64cd72861fc16b6f3e080086.

Pick-to: 6.9 6.8 6.5 6.2 5.15
Change-Id: I930f40d2bb85b74d2216378d8b8ca854a53a49e4
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-29 18:43:40 +01:00
Tinja Paavoseppä
acd331cd15 Android: Update Activity reference to C++ when set
There already exists a method to do this, but seems at some point
calling it has been dropped. Add a call to update the native
reference whenever the reference in Java gets updated.

Task-number: QTBUG-130614
Pick-to: 6.9
Change-Id: If9654b504c88340feff2432973f8f9f2eaffa272
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-29 17:53:08 +02:00
Edward Welbourne
019d2e5974 Update testlib's copy of Linux's perf_event_p.h header
This isn't strictly necessary, as it doesn't affect anything we use
the header for, but it brings us back in sync so future updates don't
involve as many changes to review. Document why we amend the upstream
SPDX identifier (to a non-deprecated equivalent).

[ChangeLog][Third-Party Code][QtTest] The perf_event_p.h from Linux is
updated to match Linux kernel 6.13.

Pick-to: 6.9 6.8
Task-number: QTBUG-132871
Change-Id: I101734b743f6689ca64054008455b98e4f6b827c
Reviewed-by: Lucie Gerard <lucie.gerard@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-29 16:53:08 +01:00
Edward Welbourne
b60be8c14d Skip zone naming with no CLDR data
In the git version of CLDR v46.1, Acre's metazone inherits a generic
long name. However, root provides no metazone data for it to inherit.
So we ended up with an empty entry for Acre in the QlocaleXML file.
Harmless, but easy to avoid, so avoid it.

Pick-to: 6.9 6.8
Task-number: QTBUG-132851
Change-Id: I392d0922bebff731632e729a4931caa02dc3a404
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-01-29 16:53:08 +01:00
Joni Poikelin
e445067507 android: Fix file dialog name filter matching for extensions with numbers
Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-114957
Change-Id: I8e9ff3b9c7ad3fe8442caa49f6ad0bb6449bb9e9
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-29 17:53:07 +02:00
Morten Sørvig
31762e2e70 wasm: don't give native focus to non-focus windows
isActive() may return true if a (transient) parent window
is active (has focus).

Compare against QGuiApplication::focusWindow() instead.

Fixes: QTBUG-129233
Pick-to: 6.8 6.9
Change-Id: I834a5814a5db161bdea2ba3524d1010e0c0e3e6e
Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@qt.io>
2025-01-29 15:04:22 +01:00
Morten Sørvig
a9bbcdd7bf wasm: support foreign windows
Add support for embedding native html elements using
QWindow::fromWinId().

WId is an emscripten::val *, e.g. a pointer to val which
holds a html element. The element can be created either from
C++ using emscripten::val, or from JavaScript. User code
owns the val * as usual for WId; ownership is not passed to the
QWindow instance.

Set QWasmWindow::m_window to be the native element when
fromWinId() is used, and skip the rest of the QWasmWindow
implementation in that case: We don't need to install event
handlers or provide accessibility elements.

Make key and pointer event handlers stop propagation only
if the event was not accepted. This makes sure that input
events reach the embedded native element.

Limit setPointerCapture calls to when the event is targeted
for Qt elements only. Determining the true target can be
a bit tricky when shadow DOM is in use since the browsers
may retarget the event. Use composedPath() to get the true
event target.

Task-number: QTBUG-128804
Task-number: QTBUG-128732
Change-Id: I5ce66e93bacb06abfd042916687cd45fc9588c51
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-01-29 13:59:09 +01:00
Morten Sørvig
adce1fe9b5 wasm: move qwasmwindowclientarea content to qwasmwindow
This allows us to keep all event handlers in one place.

Move event handler registration to registerEventHandlers(),
which is called from the QWasmWindow constructor.

Change-Id: I31f22d6eb876b92bb15d4a140e0569f0288a5915
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-01-29 13:59:09 +01:00
Morten Sørvig
59e057ef42 wasm: streamline key events
Set the event type from the event handler instead of
determining the event type at run-time based on string
comparison.

QWasmDeadKeySupport adds a complication. This can't be
easily simplified or removed since it maintains state.

Change-Id: Iad6f02ee7e2dc22817d7ac606514a2b4022f8fb0
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
2025-01-29 13:59:09 +01:00
Giuseppe D'Angelo
8f762b546f QTextStream: fix UB calls to qAbs() with minimal arguments
QTextStream's operator<<(number) uses qAbs to extract the "absolute
value" of number, and passes that and the number's sign to an internal
formatting function. However qAbs is unsuitable for the task, because it
will fail if `number` is minimal, as it returns the same type of
its input.

Since we can afford to change the type of the result, call the private
qUnsignedAbs() function instead.

Change-Id: Ib813a199503f2d07c78bb76862ab2e15d68d0ec2
Pick-to: 6.9 6.8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-29 13:59:09 +01:00
Joni Poikelin
9940f3f280 Fix crash cases where window container tries to touch destroyed window
Fixes: QTBUG-133289
Pick-to: 6.9 6.8 6.5
Change-Id: I4b5a6ab12c32133d633e1bf11567119d52c1cb5a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-29 12:24:01 +02:00
Jøger Hansegård
07318c81a7 QTest: Reset repeat counter for each call to QTest::qRun()
This fix ensures that each call to QTest::qRun() runs all tests the
requested number of repetitions.

This fixes an issue where QTEST_QUICKCONTROLS_MAIN would only test the
first style, and skip remaining styles. The cause was that the repeat
counter was not reset between QTest::qRun() calls. Subsequent calls to
QTest::qRun() would therefore not run any tests.

Amends: 80a14c86b2739492d7f7fbdb1cbde1da85d1341d

Fixes: QTBUG-133207
Pick-to: 6.9 6.8 6.7
Change-Id: Idb164fd01ac0b8e04e5dd74c3625f2c343f742c5
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2025-01-29 09:38:46 +00:00
Christian Ehrlicher
892a020cc3 SQL/PSQL: use a QByteArray for preparedStmtId
... instead a QString as it gets converted to an utf-8 string anyway to
avoid this conversion.

Pick-to: 6.9
Task-number: QTBUG-132303
Change-Id: I3fcf721f9fd0d1dd181af262663fddd532262ee3
Reviewed-by: Thierry Bastian <thierryb@filewave.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-29 09:16:51 +01:00
Morteza Jamshidi
f7feed5ee8 QTextEdit: Use layout's bounding rect for placeholder text if possible
Instead of just relying on viewport's rect we can use layout's bounding
rect.

Fixes: QTBUG-116016
Change-Id: Ic1442dcee44e7c895d772df2b5c398002707ee09
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-29 09:16:51 +01:00
Thiago Macieira
e32f28034a QSystemLocale: bail out if accessed post-destruction
There's little we can do, but a lot of content ends up in QLocale very
late in the execution. Let's at least not crash.

Task-number: QTBUG-133206
Pick-to: 6.9 6.8
Change-Id: I77d41141cb115147f9befffdd5e69dac19c96044
Reviewed-by: Albert Astals Cid <aacid@kde.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-01-29 00:16:51 -08:00
Giuseppe D'Angelo
83c812e132 QNumeric: add a private qUnsignedAbs
Checking qAbs preconditions reveals that several places into Qt are
calling it with minimal values, causing UB. Those places do not actually
need that the absolute value is of the same type as the parameter.
Therefore, introduce qUnsignedAbs, which is like qAbs() but whose return
type is always unsigned, and therefore can accept everything.

This function is private; I don't want to encourage users to rely on our
extension.

Aggressively cherry picking because this will be needed in subsequent
bugfixes.

Change-Id: I2047768a5fd35f12bf898ca8c2008813434edd8d
Pick-to: 6.9 6.8 6.5 6.2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-29 06:36:48 +01:00
Marc Mutz
57aabff91e Give LegacyUncomparable::Unordered's value a symbolic name
We'll need it higher up in the file, but we don't want to/can't move
code around, so make -127 a symbolic constant.

Amends 39c7bf4631b401c681c24bb5a732a0359c8a6d7c, which, however,
merely moved the code around.

Pick-to: 6.9 6.8
Change-Id: Id6f2d51e5678b3bad7ae658cc3e38fd3909861d7
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-29 03:21:46 +01:00
Marc Mutz
875aaa39a2 QBasicMutex::destroyInternal(): avoid clazy warning about returning void
Says Clazy:

   removed_api.cpp:1291:5: Returning a void expression [clazy-returning-void-expression]

Just drop the return keyword.

Amends bc080a909b8bb67c1fb23afca69682ba86cdf526.

Pick-to: 6.9
Change-Id: Iccbc343f2dd72a7c75da5e703e8e0722a0c50f31
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-01-29 03:00:23 +01:00
Petri Virkkunen
34a4acfb14 QQ4A: QtView will listen to Application state
...  and remove itself from the view hierarchy when the Qt application
is no longer running, i.e. when quitQt() has been called after
returning from main().

Change-Id: I6898be4e48673271109aaef718fe3f0d2ba4406f
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-29 02:00:05 +02:00
Joerg Bornemann
61c6e90401 CMake: Add a way to mark modules as "load the private module too"
Add FIND_PRIVATE_MODULE argument to qt_internal_add_module. If this
argument is set for Qt6Foo, then find_package(Qt6Foo) will also
find_package(Qt6FooPrivate). This should only be necessary in
exceptional cases like Qt6Qml where Qt6QmlPrivate is used
unconditionally.

Task-number: QTBUG-87776
Change-Id: I8d6fbd0624c0008fc42294ff2d2ed36848963508
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-01-28 21:09:54 +00:00
Michael Weghorn
befce757fa a11y atspi: Report app parent
While the application's a11y object doesn't have a parent
within Qt's a11y hierarchy, the AT-SPI registry/desktop is the
parent of all application objects.

Therefore, report that one instead of using a null path.

With that in place, querying the application parent
via Accerciser's IPython console now gives the expected
result:

    In [16]: acc.role
    Out[16]: <enum ATSPI_ROLE_APPLICATION of type Atspi.Role>
    In [17]: acc.parent
    Out[17]: <Atspi.Accessible object at 0x7fbebc3fc1c0 (AtspiAccessible at 0x139d6410)>
    In [18]: acc.parent.role
    Out[18]: <enum ATSPI_ROLE_DESKTOP_FRAME of type Atspi.Role>

While at it, also add a "m_" prefix for the
AtspiAdaptor::accessibilityRegistry member.

Fixes: QTBUG-132935
Pick-to: 6.9
Change-Id: I0e174f73c837b233fe4d5788d1c375b404000025
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2025-01-28 21:00:34 +01:00
Michael Weghorn
8bb9a1f247 a11y uia: Support UIA_LabeledByPropertyId
In the Windows accessibility bridge, bridge the
QAccessible::Label relation to the corresponding
UIA property, UIA_LabeledByPropertyId [1].

Unlike UIA_DescribedByPropertyId,
UIA_FlowsFromPropertyId and UIA_FlowsToPropertyId
which all support "VT_UNKNOWN | VT_ARRAY",
i.e. returning an array of relation targets,
UIA_LabeledByPropertyId only supports "VT_UNKNOWN",
i.e. returning a single element.
Therefore, return only the first relation target.

Sample use with NVDA's Python console:

1) start the NVDA screen reader
2) run the "calendarwidget" example
   (examples/widgets/widgets/calendarwidget/calendarwidget.exe)
3) move focus to the "Locale" combobox
4) start NVDA's Python console (Ctrl+Insert+Z)
5) print information about the object reported
   via the UIA_LabeledByPropertyId property
   in NVDA's Python console:

    >>> focus.UIAElement.CurrentLabeledBy
    <POINTER(IUIAutomationElement) ptr=0x831b6c8 at cfb8b20>
    >>> focus.UIAElement.CurrentLabeledBy.CurrentName
    'Locale'
    >>> focus.UIAElement.CurrentLabeledBy.CurrentControlType
    50020

[1] https://learn.microsoft.com/en-us/windows/win32/winauto/uiauto-automation-element-propids

Change-Id: Ib03bfc00356b9bdab826c4c9c3d6b2b2b9fe531f
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2025-01-28 21:00:34 +01:00
Friedemann Kleint
ead6f79dc0 Notepad example: Use theme icons
Pick-to: 6.9 6.8
Change-Id: Id915ecbf218d419b972ff97637673827facf84a2
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-01-28 20:35:19 +01:00
Magdalena Stojek
09652502ab Add support for precision and width options in QLocale::toString()
Add QLocale::toString() overloads for integral types
handling fieldWidth and fillChar parameters, which
enable callers to control how the number is presented.

Task-number: QTBUG-122834
Change-Id: I5d36d7d5e4cf70b7e66c75c07148ec43540acc88
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-01-28 18:39:39 +00:00
Tim Blechmann
673400679d Platform: unix - avoid modifying the environment
Modifying the process environment can cause crashes in application code
that accesses the environment via non-qt functions on worker threads.
When launching a process, we can avoid modifying the environment of the
caller by using QProcess with setEnvironment. The codepaths without
QProcess support is still prone to these issues and could potentially be
improved via execve

Task-number: QTBUG-129222
Pick-to: 6.8 6.9
Change-Id: I4e2d93abaa0e392b341041faaae0ffd11e225bcb
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-29 01:40:32 +08:00
Alexey Edelev
48ef1633a3 Switch to qt_register_target_dependencies for Qt modules
qt_record_extra_qt_package_dependency is deprecated since 6.9

Pick-to: 6.5 6.8 6.9
Change-Id: Ia21fd9a75d14fadefd4f9dd392aa908e1c84d274
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-28 17:30:29 +01:00
Giuseppe D'Angelo
28d0e658e2 tst_QGestureRecognizer: do not leak the point device
QTest::createTouchDevice() passes ownership of the device to the caller,
so make sure to delete it.

Change-Id: I100d3de9eab8ec9f88ed3e0850ada9d988bd962e
Pick-to: 6.9 6.8
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-28 17:25:47 +01:00
Giuseppe D'Angelo
0f336500a0 QDebug: do not trigger integer overflow when printing a QRect
QRect::width() and height() may overflow: they're only safe to call
when right-left+1 (or bottom-top+1) is representable by an `int`.
Therefore, avoiding calling them from QDebug, which is supposed to
"always work" (otherwise, it's not of great debugging help...).

QRectF does not have this issue as it stores the width directly.

Change-Id: I438dbacae42c17730afb92f05d16e3eebb161255
Pick-to: 6.9 6.8 6.5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-28 17:12:45 +01:00
Volker Hilsheimer
b5538a5a0e JNI: Extract size check from fromContainer
Addresses header review comment.

Pick-to: 6.9
Change-Id: I302ae22da197fa8c317f0a4749d15b07fb5d0078
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-28 17:12:45 +01:00
Assam Boudjelthia
0f2c645020 Android: don't manage available screen size values under androidjnimain
Those values should be under the plaftoform screen as they are now, and
handling them also here is just duplication that's not needed.

Change-Id: Ib6be6655527aa86403173d477d137b92d8e51987
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-28 17:20:08 +02:00
Jan Arve Sæther
0d997213a6 Fix bug QGridLayoutEngine::cellRect()
lastColumn and lastRow could exceed the total column/row count, leading
to out-of-bounds accesses to the QList

QGridLayoutEngine::cellRect() is unused, so there is no risk of
regressions here. We fix it because the function might be used later.

So far the plan is to use it for visualizing the layout cells in QtQuick
Layouts.

Change-Id: Idd9db682039f2f81b3a6fbcd03990b6f15334d3e
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2025-01-28 14:59:51 +01:00
Thierry Bastian
e574cda7fc SQL/PSQL: slight improvement in code
added a details about code paths that cannot happen and added constexpr

Fixes: QTBUG-132303
Pick-to: 6.9
Change-Id: I98340c5a1f275c00aafb3294cf8e5e8368126b76
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-01-28 14:59:51 +01:00
Aurélien Brooke
61dbdbeb31 rhi: be more verbose in QRhiTexture::Format enum documentation
Add missing [since], explicit total size and fix spelling.

https://doc.qt.io/qt-6/10-qdoc-commands-tablesandlists.html#value

Pick-to: 6.9
Change-Id: I6934944ef4be119ae2934b986c7840d4d1eeea67
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-01-28 12:32:04 +01:00
Magdalena Stojek
2ebb3d8c37 Disable qlocale tests on WASM in CI
Emscripten compiler running out of memory in CI when adding more tests
to qlocale, preventing integration. Disabling the tests will allow the
changes to be integrated.

Task-number: QTBUG-133219
Change-Id: Ia6566fdeaae4ae54398ac8fedcbb7a225037f662
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
2025-01-28 11:29:26 +01:00
Assam Boudjelthia
7dcf58eedb Android: separate setting screen size from setDisplayMetrics()
The screen size doens't need to be updated each time the layout size is
changed, they don't always happen together. The screen size change
happens less often than the layout/available size. Thus, do handle only
layout change under setDisplayMetrics() and move screen size changes to
onDisplayChanged() callback where it logically belongs.

Along the way rename setDisplayMetrics() to handleLayoutSizeChanged()
to reflect what it actually does now after the cleanups.

Task-number: QTBUG-132720
Change-Id: I9dfcfe4a0d2c0be36fb0a5fbf5975c7d466ddef2
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-28 12:29:26 +02:00
Thierry Bastian
f346a6065d SQL/PSQL: Avoid copies of data in QByteArray when binding such a value
Fixes: QTBUG-132303
Pick-to: 6.9
Change-Id: I84e822078d684850c5c0384338cfa4c01fe5007f
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-01-28 06:29:06 +01:00
Thiago Macieira
327cfd55b1 Replace QBoolBlocker with QScopedValueRoolback
It was pre-Qt 4.5 (so pre-C++11), while QScopedValueRollback is 4.8.
Both are still old, but with Qt 6 and C++17, we can use CTAD.

QScopedValueRollback requires a value change to be explicit, which is
less surprising.

The uses outside of qtbase have also been fixed.

Change-Id: Ia930b1a2ed1e465a826ffffd179c1909e16583db
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-27 18:41:42 -08:00
Thiago Macieira
45886e6a81 QFileSystemEngine/Darwin: remove use of clonefile() on Apple systems
Because we called this before opening the target file, we did not check
that the destination file engine is the QFSFileEngine, and therefore we
may have passed a path that referred to a Qt resource path. We still do
that on Windows, but Qt resource paths start with a ':' character and
that is not allowed on Windows, so the Win32 CopyFile() function fails.

Moreover, this function *can* clone directory trees, which we don't want
to happen because it doesn't happen on other OSes. Instead, fall back to
the fcopyfile() call in cloneFile(). It will still do cloning where
permitted.

This was added in commit db0064b767474a89bc72ea4374f477682983c5f4,
before the fcopyfile() in 974b3adf8a099ca95fc2eabfc434038ce73f62c8,
though both were for Qt 5.10.

[ChangeLog][QtCore][QFile] Fixed a bug on Apple systems that would cause
copy() to copy a directory if the QFile pointed to a directory and the
destination was in the same volume. Now copy()'s behavior is the same as
in other OSes: directories are never copied.

[ChangeLog][QtCore][QFile] Fixed a bug on Apple systems that allowed
copy() to create a file with the name that referred to a Qt resource
path, if one tried to copy to that path. Qt resource paths can't be
modified using QFile.

Pick-to: 6.9
Change-Id: I996368f4c656ff10ff5efffd5b47c6ddde34fd10
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-27 18:41:32 -08:00
Assam Boudjelthia
36d2c01153 Android: don't call QPlatformWindow::setGeometry() explicitly
... under QAndroidPlatformWindow::setGeometry() since it's going to
be called under QWindowSystemInterface::handleGeometryChange().

Task-number: QTBUG-132716
Change-Id: I12d4cfd125fab73e47c5a66caf4275897ba112eb
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-28 04:15:39 +02:00
Assam Boudjelthia
060a65f6c8 Android: init display properties in QtActivityDelegateBase.initMembers()
This way we ensure we get initial properties and not have to worry about
calling them in the delegates at the start.

Task-number: QTBUG-132716
Change-Id: Ic009c8f55b8397e37b4f57b0c60f9a2428aa85d2
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-28 03:04:04 +02:00
Eskil Abrahamsen Blomfeldt
d58ad990e2 Port Freetype engine to COLR paint graph renderer
Use the cross-platform renderer code in Freetype as well as
DirectWrite to share as much code as possible.

Pick-to: 6.9
Change-Id: I643dced6b913138890b39eafc3984cca5ced0aae
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-01-28 01:13:04 +01:00
Eskil Abrahamsen Blomfeldt
9f22a51987 DirectWrite: Implement support for COLRv1
This traverses the paint node graph and renders
the emoji through a generic renderer. This renderer
is largely based on the renderer in the FreeType
backend and will be used there as well in a follow-up
patch.

Pick-to: 6.9
Fixes: QTBUG-113458
Change-Id: I44d17b0be8d85e38589edeb68793bf4ee4491eca
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-01-28 01:13:04 +01:00
Giuseppe D'Angelo
034a234796 QLine::translate: mark as constexpr
These functions were not constexpr, possibly because QLine was
constexpr-ified in C++11 times, and these functions bodies
require more than one line. This does not apply any more, so add
constexpr.

[ChangeLog][QtCore][QLine] The translate() overloads are now constexpr.

[ChangeLog][QtCore][QLineF] The translate() overloads are now constexpr.

Change-Id: Iee69a85b18ffa8d2533b0131f454546afeeba37a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-28 00:35:14 +01:00
Assam Boudjelthia
8047d2ec89 Android: simplify/refactor QAndroidPlatformWindow::setVisible()
Simplify the if condidions in this function for better readability.

Task-number: QTBUG-132716
Change-Id: I4a4eee61d4b9111d82272205133d7719b7be4a9e
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-28 01:35:14 +02:00
Joerg Bornemann
483768fb8e CMake: Fix examples built as external projects
Usage of a private module needs a respective find_package call now.

Pick-to: 6.9
Task-number: QTBUG-87776
Change-Id: I3a00a241c5e8637d28606c1f45a843b491c0a8bc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-27 23:02:02 +01:00
Doris Verria
059210b17e QWindowContainer: Improve docs to mention new change in behavior
Specify that since 6.8 tab focus can transfer in and out of the
embedded window if using a Qt Quick based window.

Pick-to: 6.8 6.9
Change-Id: I21d04457ee79497431f889e261f1cb6bd9fd39ee
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-27 21:41:06 +01:00
Thiago Macieira
e0a1f49156 QLocale: try to survive being created during application shut down
QLocale is very often accessed during global static destructors, so
let's try and survive if the default has already been destroyed. In that
case, we shall fall back to the C locale.

I've placed the call to systemData(), which updates the system locale,
before the initialization of defaultLocalePrivate, as the initialization
of the latter depends on the former.

Task-number: QTBUG-133206
Pick-to: 6.9 6.8
Change-Id: I48e29b45f9be4514336cfffdf5affa5631a956a3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Albert Astals Cid <aacid@kde.org>
2025-01-27 12:41:06 -08:00
Thiago Macieira
343dab0dc3 Remove QT_NO_GEOM_VARIANT
It was used by the bootstrap library, but it no longer uses QVariant at
all since cdbc76360ae4c12b25923a7cb392355a6485fc70.

Drive-by:
- remove unused qdebug.h include from qsettings.cpp
- put the GEOM includes with the other includes and sort them

Change-Id: Iabd451c0b462a39a60a0fffdd020e8d45cd8afc4
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-27 20:41:06 +00:00
Thiago Macieira
744fda9cb4 QObjectPrivate: encode the version number in the constructor parameters
Instead of allowing the code to start and then possibly fail at runtime.

This isn't a 100% sure solution because it's a function call. With lazy
symbol binding on some OSes, the mistake won't be noticed until the
function call is attempted. However, most OSes now resolve *all* calls
at load time so they can mark the GOT (or equivalent) pages read-only,
meaning the loading of the library will fail.

qversiontagging_p.h is a more sure way in OSes / executable formats it
works on.

Change-Id: If7867a37256b7141001dfffd9bd299bb1bbd7c63
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-27 12:41:06 -08:00
Eskil Abrahamsen Blomfeldt
1b85143d21 DirectWrite: Support embedded PNGs in color fonts
This does some refactoring on the color font support in
the DirectWrite backend and introduces support for loading
embedded PNGs from the font.

This gives us support for CBDT and SBIX fonts, which are both
based on embedding image files.

[ChangeLog][Windows] Added support for color font formats with
embedded pixmaps in DirectWrite backend.

Pick-to: 6.9
Task-number: QTBUG-113458
Change-Id: I695901b62600c37619c80aa915f60de13a4fca3f
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-01-27 21:41:05 +01:00
Thiago Macieira
5de7f4fe19 Bootstrap: disable QFile::copy() due to lack of QTemporaryFile
Without QTemporaryFile, QFile::copy() creates a file with a fixed name
in the destination directory, meaning that it would step over another
thread or process trying to copy at the same time. That's dangerous for
buildsystem tools, given the prevalence of ninja -j / make -j
executions.

Nothing in the bootstrapped tools uses this function right now. This
commit will simply ensure nothing begins doing it in the future.

Change-Id: Icdcf51fa5d94618d622afffd94d1263cf9df181a
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-27 12:11:23 -08:00
Thiago Macieira
9b006eb91a QFileSystemEngine/Unix: use copy_file_range(2) in cloneFile()
For remote filesystems on Linux, this can invoke a server-side copy to
avoid network traffic. For local filesystems, Linux can use an optimized
FS-specific call (which may be the same operation as the FICLONE, but
I'm not sure) or splice the data on its own.

Tested with:
 - FreeBSD ufs
 - FreeBSD ufs-to-tmpfs
 - FreeBSD tmpfs (tested ENOSPC with it)
 - Linux btrfs
 - Linux ext4
 - Linux tmpfs (tested ENOSPC with it)

Change-Id: I3ae11d555882bdbb0487fffd81cb5568171cee3f
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-27 12:11:23 -08:00
Thiago Macieira
fe75526542 QFileSystemEngine/Linux: detect sendfile() permanent errors
sendfile(2) isn't always able to send to all file types, so current code
only detected the ability to send by having sent something. This commit
tries a little harder to detect permanent data-send problems on the
first try. I'm unable to find a case where this fails on Linux, in
particular because we don't enter this block if the source file isn't
S_IFREG.

Now, on Linux, there's no file-copy pump:
openat(AT_FDCWD, "dummy.o", O_RDONLY|O_CLOEXEC) = 4
openat(AT_FDCWD, "/tmp/tmp", O_RDWR|O_CLOEXEC|O_TMPFILE, 0600) = 5
ioctl(5, BTRFS_IOC_CLONE or FICLONE, 4) = -1 EXDEV
sendfile(5, 4, NULL, 2147479552)        = -1 ENOSPC
lseek(5, 0, SEEK_SET)                   = 0
close(5)                                = 0
write(2, "\"Could not copy to /tmp/tmp/f: No space left on device\"") = 56
close(4)                                = 0

Change-Id: I88ce23447b0d7341848cfffd2c469e15cb69f5a6
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-27 12:11:23 -08:00
Thiago Macieira
be2df3c6e0 QFileSystemEngine: let cloneFile() inform QFile of permanent errors
The Unix implementation in QFileSystemEngine::cloneFile() was unable to
tell the upper layer whether the failure was permanent (like ENOSPC and
EIO) or whether the fast copy attempt wasn't possible. This resulted in
QFile always retrying even after ENOSPC conditions.

This commit resolves that.

Change-Id: I38a830a99a0d38bcb51efffdf34bb7fead639496
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-27 12:11:23 -08:00
Morteza Jamshidi
e6e210c240 Change window activation order if active window is moved
Active window should always be in front of the stack so bring it to the
front of the stack if it's not.

Pick-to: 6.8 6.9
Fixes: QTBUG-112758
Change-Id: Iff123d1e95f728f51b786106d83a429c111aa6a8
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-01-27 21:11:23 +01:00
Kai Köhne
ccc99bcf8b Doc: Update external link to freedesktop.org trash specification
Old link gives a 404

Pick-to: 6.9
Change-Id: I3e528a29a6ed2d0d97c3fcf1cf11c441a2882415
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Jaishree Vyas <jaishree.vyas@qt.io>
2025-01-27 18:44:23 +01:00
Christian Ehrlicher
9094ad18b0 SQL/PSQL: call deallocatePreparedStmt() unconditionally
deallocatePreparedStmt() knows by itself when to call the psql cleanup
routines or not. No need to have this logic outside this function.

Pick-to: 6.9
Task-number: QTBUG-132303
Change-Id: Ib1a5ba7b53c156f6a6b93f23a3ec8c851d7398fc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Thierry Bastian <thierryb@filewave.com>
2025-01-27 18:44:22 +01:00
Assam Boudjelthia
0e4f9ffa55 Android: update to Gradle 8.12 and AGP 8.8.0
Update to latest versions for Gradle:
* Gradle 8.10 -> 8.12
* Android Gradle Plugin 8.6.0 -> 8.8.0.

[ChangeLog][Third-Party Code] Updated Gradle to 8.12 and AGP to 8.8.0.

Pick-to: 6.9
Fixes: QTBUG-132852
Task-number: QTBUG-132851
Change-Id: I9445f0cd7347a6ee153a987ea28ab617b9cb6055
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Olli Vuolteenaho <olli.vuolteenaho@qt.io>
2025-01-27 19:44:22 +02:00
Giuseppe D'Angelo
349737c6a9 QRhiVulkan: disable -Wundef when including 3rd party headers
The header is -Wundef-unclean.

Change-Id: I30145f331ee1062961abaed14c7b79b84755abb9
Pick-to: 6.9 6.8
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-01-27 18:44:22 +01:00
Alexandru Croitor
c7027880aa CMake: Provide a way to find all available Qt module packages
A project might want to find_package all available (installed) Qt CMake
packages that contain qt modules.

A use case might be a qml app that needs to link to all of Qt, and
support showing qml files that can load any Qt qml module.

Add a new Qt6 COMPONENT called ALL_QT_MODULES.

It can be used like this:
  find_package(Qt6 COMPONENTS ALL_QT_MODULES).

The implementation will find all installed Qt modules by globbing over
all json files installed in $qt/modules dir, and treat the file names
as package names.

It will then tell Qt6 to find_package each of those packages.

Pick-to: 6.8 6.9
Change-Id: I89242307438576a0cbb3cdca80a9cb72818b6035
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-27 17:36:33 +01:00
Alexandru Croitor
bf83fffd13 CMake: Collect all known qml plugin targets into a directory variable
Just like we do with qt plugins, collect all found qml plugin targets
into two new directory scoped variables:
- QT_ALL_QML_PLUGINS_FOUND_VIA_FIND_PACKAGE
- QT_ALL_QML_PLUGINS_VERSIONED_FOUND_VIA_FIND_PACKAGE

The plugin target names are derived from the Config.cmake file names,
based on the existing assumption that qt_internal_add_plugin always
uses the target name when generating the Config.cmake file.

Pick-to: 6.8 6.9
Change-Id: I78c76488e133fb3c0374cbc149425726077f6c31
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-27 17:36:33 +01:00
Alexandru Croitor
47006aca44 CMake: Move qml plugin auto inclusion code into a separate macro
The code is moved into a macro without any modifications aside from
removing the escaping of variable evaluation and escaping of quotes.

It's kept as a macro similar to __qt_internal_include_plugin_packages,
because there might be calls to find_package() that set variables in
the current scope.

The reason for moving is easier maintenance (no more escaping).

Pick-to: 6.8 6.9
Change-Id: Ie6ddc26fe4ff8db0134f3542c2886f8b5d68dc51
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-27 17:36:33 +01:00
Alexandru Croitor
f7b8ff7177 CMake: Set versioned variables with found modules, plugins, types
Introduce two new directory-scoped variables containing versioned
(prefixed with Qt6::) target names of qt modules and qt plugins found
as a result of finding Qt packages:
- QT_ALL_MODULES_VERSIONED_FOUND_VIA_FIND_PACKAGE
- QT_ALL_PLUGINS_VERSIONED_FOUND_VIA_FIND_PACKAGE

To be consistent in the naming of the variables going forward,
deprecate the old QT_ALL_PLUGINS_FOUND_BY_FIND_PACKAGE variable
in favor of a new QT_ALL_PLUGINS_FOUND_VIA_FIND_PACKAGE.
The difference is 'BY' vs 'VIA'.

The non-versioned variables are modified not to contain duplicates:
- QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE
- QT_ALL_PLUGINS_FOUND_VIA_FIND_PACKAGE

Also remove duplicates from the variable that collects all found qt
plugin types:
- QT_ALL_PLUGIN_TYPES_FOUND_VIA_FIND_PACKAGE

A follow-up change will collect qml plugin targets.

This information can be useful to find out what Qt targets are
available in a project, for example to know what plugin targets or
types can be linked into another target, or which libraries can be
deployed.

Pick-to: 6.8 6.9
Change-Id: I4f158872f4a8f6ef6008f081270604f75b77ad9d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-27 17:36:33 +01:00
Assam Boudjelthia
6a75d0e95b Android: simplify QtWindow.setVisibility() if statement to oneliner
Change-Id: I27aad1c418c8dd5d4c7cbac51d2a2cda323573ea
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-27 17:02:24 +02:00
Laszlo Agocs
3869106cc5 rhi: gl: Honor deafultFbo from the QOpenGLContext better
The legacy infrastructure does not map very well to the modern one:
it turns out that, somewhat counterintuitively, targeting a
QRhiSwapChain for a QWindow may still mean rendering into a texture,
when using OpenGL on certain platforms.

For example, the Wayland platform plugin implements client-side
decorations by binding an FBO upon making a context current on a
surface for a (decorated) window, and it also makes
defaultFramebufferObject() on the context return the FBO id.

The expectation is that this is why errors such as
GL_INVALID_OPERATION are encountered in glDrawBuffers on Linux.

The QRhi GL backend's assumption that the QRhiRenderTarget being
a QRhiResource::SwapChainRenderTarget implies that the target
really is the color buffer(s) of a window surface is not in practice
sufficient on these platforms.

The bound FBO was already correct always (whatever defaultFbo reports),
but the code path hit was the wrong one. And there is different code
for MRT support (textures only) and stereo rendering (window surface
only).

Make sure defaultFbo() is queried before taking the decision which path
to hit.

Pick-to: 6.9 6.8
Fixes: QTBUG-122819
Fixes: QTBUG-132780
Change-Id: Iaaab57b031f430178ee4611a4f7a02c854010441
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-01-27 15:24:59 +01:00
David Redondo
f277586291 client: Clean up tablet_pad_group proxy
While Qt cannot do anything with them right now, these are server created
proxies and still need to be destroyed to be not leaked.

Pick-to: 6.9 6.8
Change-Id: I5fad05c6bbb05782bb997204b3dada80ab28b98e
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-01-27 14:55:58 +01:00
Laszlo Agocs
24d62ffd72 rhi: vulkan: Simplify frame sync
imageFence seems to have no purpose. And some of the
comments seem to be out of date / misleading.

More importantly, do the command buffer completion wait
before the acquireNextImage. Otherwise frame.imageSem
may have wait operations pending if the queueSubmit
did not get to wait on it yet. The expectation is that
this potential issue is what triggers the recent
validation layer releases' enhanced synchronization
checkers.

Pick-to: 6.9 6.8
Fixes: QTBUG-132808
Change-Id: Ib8e3884ccea343f5a839aa2ee17cd358fafeac69
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-01-27 12:39:22 +01:00
Aurélien Brooke
ed00c72ce3 Force C locale in tst_Moc::notifyError()
Otherwise, the test can fail because it detects "erreur" in French
instead of the expected "error" in English.

Change-Id: I7fce02cc9a6efd2c2f4bbbf72dc328b92a1eae74
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-27 12:39:22 +01:00
Kai Köhne
a4d3a82244 Doc: Fix link to RFC 8259
Fixes qdoc warning
    corelib/doc/src/json.qdoc:22: (qdoc) warning: Can't link to 'RFC 8259'

Amends 65fda988e92e

Pick-to: 6.9
Change-Id: I62c1cf05366cd13180d21d7b4cbf68c0c0f48e1d
Reviewed-by: Johannes Grunenberg <nerixdev@outlook.de>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-27 12:39:22 +01:00
Lucie Gérard
7cb90e1563 Make module ready for source SBOM checking
This includes:
- turning VERIFY_SOURCE_SBOM ON
- adding exception to the licenseRule.json files
- correcting the licensing given via REUSE.toml files
- renaming license files not located in LICENSES folder.
They need to be named LICENSE. to be ignored by reuse and
excluded from the source SBOM. The name are updated in the
corresponding qt_attribution.json

A lot of files are skipped during the license test,
but all are present in the source SBOM.
This is why  correction are needed before turning the
source SBOM check on.

[ChangeLog][Third-Party Code] Renaming the license files with prefix
LICENSE. to have them ignored by reuse tool.

Task-number: QTBUG-131434
Pick-to: 6.9
Change-Id: Iab517215bb10a17357d2d2436bba8d3af76e5cd1
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-27 12:39:22 +01:00
Lucie Gérard
153002f7d2 Add calling license check on generated source SBOM
The license check is only called if VERIFY_SOURCE_SBOM is set to ON
in the module_config.yaml. This way, a module can turn on the check
only when ready.

The license check is done via a perl script. Since no perl is
available for Windows on ARM64, VERIFY_SOURCE_SBOM is set to OFF
in this case.

Task-number: QTBUG-131434
Pick-to: 6.9
Change-Id: I183b7726928bbc925940330d39779a4ac2307254
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-27 12:39:22 +01:00
Piotr Wierciński
66b6366821 wasm: Update Emscripten to 3.1.70
Pick-to: 6.9
Change-Id: Id502e6ffa6ee7ef3b000d8e43f112dfb882fe354
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-01-27 07:47:59 +00:00
Tor Arne Vestbø
9509434ecb Don't pass along expose events for destroying QWidgets
When closing a popup window on macOS, and the NSView needs display,
for example due to the frame geometry having changed, the system will
ask our NSView to display one last frame, via NSOrderOutAnimationProxyWindow
initWithSnapshotOfWindow.

If this happens during the close() that the QWidget destructor does,
we no longer have a QWidget subclass to handle the corresponding paint
event, so we'll end up flushing an empty frame, using that for the
animation transition instead of the last valid frame of the widget.

Worse, if the top level is using RHI to flush, the texture list
might be stale, as there is currently no plumbing for a widget to
tell QWidgetRepaintManager about it deleting a texture that was
previously picked up and placed in the QPlatformTextureList. When
this happens we end up crashing on dereferencing the stale texture.

To mitigate these issues we now skip the expose event if the widget
is already in ~QWidget. This potentially means the close animation
will use a stale frame, but we can live with that.

Pick-to: 6.9 6.8 6.5
Change-Id: Iabe1d97019923ee3a1a86039630095d00c966156
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-26 13:19:45 +02:00
Tor Arne Vestbø
81ed068a51 Don't assume QDockWidgetGroupWindow has toolbars
As part of 3d99f90b50ab22ef5ab4433c57f9ee584a0a7cae we added logic
to look up the toolbar for a QMainWindowLayoutSeparatorHelper. In
the case of QDockWidgetGroupWindow the logic was broken, as it was
casting the layout's parentWidget(), the group window, to a QMainWindow,
instead of using the group window's parent.

However for QDockWidgetGroupWindow we shouldn't look for a toolbar
at all, as QDockWidgetGroupWindow can't have a toolbar. Using the
parent main window's toolbar is wrong, as mouse events for that
window will not affect mouse events for the group window, so the
bug in 3d99f90b50ab22ef5ab4433c57f9ee584a0a7cae is not triggered.

Fixes: QTBUG-132952
Pick-to: 6.9 6.8 6.5
Change-Id: Ic7845254e05bc358a39f79ec7622029d90173b45
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-01-26 13:19:35 +02:00
Thiago Macieira
c7a069870a Revert "QFlags: befriend the QDataStream serialization operators"
This reverts commits 729c0960b84183bcf9576f974cb5e3b3c3fdc6ef and
348b680ae56e92f061424a10c4baa726cf7f15d2. Friendship is not required.

The removal of the forward-declaration in qflags.h implied adding it
where it had been required but not present.

Pick-to: 6.9
Change-Id: Ie17963f95bb5fa98fd75fffd7e6e5289b58f1960
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-01-24 19:42:17 -08:00
Bartlomiej Moskal
1b02900ffe Android: Unblacklist testQuickSelectionWithMouse test from tst_QLineEdit
Test was failing on Android because of three issues:
  1. Mouse selection does not work well with Android, especially when
     predictive text is enabled. After changes in
     de5ae6917c819ff23f7d9c5742b50b15e0824877 commit, mouse selection on
     Android needs ImhNoPredictiveText to be set for correct handling.
  2. Test sends mouse press events on center position of the QLineEdit.
     On some devices, the text would sometimes end before this center
     position. To avoid this situation the width is set directly.
  3. Android expects the mouse click to be released before the next
     click. If it doesn't, the next selection won't work properly

This commit fixes all those issues and unblacklists
testQuickSelectionWithMouse test

Fixes: QTBUG-87417
Fixes: QTQAINFRA-6896
Pick-to: 6.9 6.8
Change-Id: Id19850446954196a077047e250ea24a91ae7255e
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-25 03:20:58 +00:00
Thiago Macieira
40eea11807 QFile/Unix: ensure the destination of copy() is empty before cloneFile()
This is potentially a bug in the !QT_CONFIG(temporaryfile) case in which
we wouldn't truncate the file after we had copied it.

Change-Id: Ieea7fb3ca9981e555140fffd2300fcebcdd800b5
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-01-24 16:26:34 -08:00
Thiago Macieira
8a720c162d QFile: use unbuffered mode for the file-copy data pumps
There's no need to have the QIODevice layer buffer the data and thus
allocate memory. In the case of QFile::copy(), it also improves the
error message output.

Previously:
"Cannot create /tmp/tmp/f for output: No space left on device"

Now:
"Failure to write block: No space left on device"

Pick-to: 6.9
Change-Id: I537a2a79ead9d1d9ac2efffdd650702a4424bac6
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-24 16:26:34 -08:00
Thiago Macieira
c15bfcd5c0 QCoreApplication: clean up after {win,mac} removal from Bootstrap
Amends commit bf8a5ab418a21d802910728ed24a0a7fad230526. Just some
tidying up.

Change-Id: I3d07a7b151241317ab6bfffd3e79a40db4dab441
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-01-24 16:26:33 -08:00
Thiago Macieira
d7007090bb Bootstrap: depopulate qcore_mac.mm to remove QOperatingSystemVersion
We don't need anything that the class provided, but we needed it because
everything is in a large .mm source file.

I've also removed portions of qcore_mac.mm that aren't needed for
bootstrapped tools, like telling whether dark mode is in effect (the
bootstrapped tools aren't GUI). I've also had to remove the check for
running under Rosetta, which hopefully is going to affect no one:
running moc & cmake_automoc_parser under Rosetta is going to be mighty
slow. Just use a native set of tools instead.

Change-Id: I4c0c716a5b57833abf63fffdf0c66b9ebaccffdb
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-01-24 16:26:33 -08:00
Wladimir Leuschner
b717945812 QWindows11Style: Default PE_IndicatorRadioButton to selected/unselected
In case there is no valid QStyleOption::styleObject, default the
PE_IndicatorRadioButton to the selected and unselected appearances.

Fixes: QTBUG-132906
Pick-to: 6.9 6.8
Change-Id: I5e9c13cb3384321e025e5af08ee3dab81feb07fe
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-01-24 22:00:52 +01:00
Wladimir Leuschner
dee731ae98 QWindows11Style: Reduce groove size of QSlider
Reduce the groove size of QSlider when using Windows11Style, so that the
minimum selectable value does appear so.

Fixes: QTBUG-133128
Pick-to: 6.9 6.8
Change-Id: I3e5a5378e2eace3920c06db8cb1198122c0937b5
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-01-24 19:59:38 +01:00
Alexandru Croitor
dbf44b61c1 CMake: Add a few more internal sbom helper functions
Add a few internal functions to allow
- getting the sbom project supplier
- project supplier url
- project namespace
- computing a project namespace
- computing a project file name
- getting a sanitized spdx id given a hint

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I0dc3df274eaf6882a6af021aabee75501b5083f8
Reviewed-by: Moss Heim <moss.heim@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-24 19:36:09 +01:00
Alexandru Croitor
f2472c2e6a CMake: Remove qt executable SBOM generation stale code
We never ended up calling _qt_internal_finalize_sbom for generic Qt
repo executables, and we never passed an SBOM type, so this code never
worked.

Remove it to avoid confusion.
It might be re-added in the future.
This doesn't affect the SBOM generation for Qt tools and apps.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: Iffde964efe2a6b70e6e0b64ec0803af5e84172fb
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-24 19:36:08 +01:00
Alexandru Croitor
ffe972d72c CMake: Fix SBOM inline comment
Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I53696003b144ad628169a345743e343cdfc022ae
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-24 19:36:08 +01:00
Alexandru Croitor
0be13fb699 CMake: Add qt exported target name and package name into SBOM
Add them to the PackageComment field of the SBOM.
Can be useful to map back the SPDX Package to the CMake target or
package.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: Icbbb90132038c489b55c4ee7a038aea593ce1ff6
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-24 19:36:08 +01:00
Alexandru Croitor
d2dea0bc08 CMake: Add a fake deterministic SBOM generation option
Replaces content like timestamps, version strings and checksums with
constant values to make the SBOM generation deterministic.
This is useful for reproducible builds, to allow cleaner inter-diffs
while developing new SBOM features.

Can be enabled by configuring with
-DQT_SBOM_FAKE_DETERMINISTIC_BUILD=ON

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: Id0003bdd23fe57abd70213a2a108885861693242
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-24 19:36:08 +01:00
Alexandru Croitor
3c516ffa87 CMake: Allow skipping some parts of SBOM generation
Makes it easier to debug diffs of SBOMs, due to lower amount of
content in generated files.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I5a1e8a9868cda199de4a7344b86a12f68fec31bf
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-24 19:36:08 +01:00
Alexandru Croitor
2857d8d5ea CMake: Add SUPPLIER as an option to SBOM packages
Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I22cae71dcc7582126320e17271a8c55bea1ad393
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-24 19:36:07 +01:00
Alexandru Croitor
4be604c55e CMake: Prepend underscore to qt_internal_sbom_set_default_option_value
Because it's in a Public cmake file.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: If3f92af848193cb824b88e93e17965ffed93cf2b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-24 19:36:07 +01:00
Aurélien Brooke
ff68e05bc3 rhi: vulkan: fix the pWaitDstStageMask parameter of vkQueueSubmit
It expects one mask per wait semaphore, where only one was given,
leading to an out-of-bound read.

Amends 202dd3cb39ab4408c44a8588b8d6fb9a1cc3a184.

Fixes: QTBUG-132356
Pick-to: 6.9
Change-Id: I6f7d33eb4568d1577e09411f7be751c8dc520429
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-01-24 19:36:07 +01:00
Aurélien Brooke
6f9e40ad39 rhi: remove unnecessary float casts
Since 5bb4baae0379d5903f547f0399be9620f5ab06a0 QColor functions already
return floats.

Change-Id: I8e5261397c5807123fb4b3288f229c23c2324995
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-01-24 19:36:07 +01:00
David Redondo
cd1686e55f QOpenGlContext: Always unset current context in doneCurrent()
Otherwise when no other context is made current until thread exit, the
QGuiGLThreadContext destructor will try to call doneCurrent() on an
already deleted context.

Pick-to: 6.9 6.8
Change-Id: If55dd69a72b8ab4012780a449f6a02729dd0ed43
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-01-24 19:36:07 +01:00
Assam Boudjelthia
48dbc72c44 AndroidTestRunner: print failed build output when no --verbose is used
This helps with better debugging where in most cases the tests are run
without --verbose, but if there's a build error, it won't be clear what
went wrong, and only re-running with --verbose would give such details,
which is just annoying to deal with.

Pick-to: 6.9
Change-Id: Icb8bcb8e5ba297d48b9e166c93523f25a21937b2
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2025-01-24 20:36:06 +02:00
Assam Boudjelthia
256fd95a71 AndroidTestRunner: don't automatically print logcat unless its a crash
Print logcats only if it's explicitly requested with the respective
argument or if there was a crash, i.e. where we can't get the test's
exit code. Otherweise, in case of normal failure, we don't really need
to pollute the output.

Pick-to: 6.9
Change-Id: Ic4e6db5d9fd6786bd28204a3ec87f63a7ec9764a
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2025-01-24 20:36:06 +02:00
Cristian Le
599ad25a65 Forward find_package hints to auto/cmake
If the tests are built and run as standalone or non-prefix build and a
find hint was used, e.g. `Qt6_ROOT`, then this type hint should be
forwarded to the `ctest --build-and-test` otherwise the internal
package would fail when it tries to `find_package`.

Pick-to: 6.9
Change-Id: If71852dd5124b8deeddd28ba835f1943d96ba2b8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-24 18:53:35 +01:00
Felix Lionardo
70b1db9c0e QNX desktop support
Adds functionality to communicate with a desktop manager. This feature
is only enabled if "desktop" is added to the QT_QPA_PLATFORM environment
variable (e.g., "QT_QPA_PLATFORM=qnx:no-fullscreen:desktop").

Pick-to: 6.9 6.8
Change-Id: If98e0dda43692abce47f2d8f5f340bd7276ec901
Reviewed-by: James McDonnell <jmcdonnell@blackberry.com>
2025-01-24 12:53:34 -05:00
Felix Lionardo
d0e64a36d2 Disable incremental updates for raster windows on QNX
Incremental updates don't always work
due to a misinterpretation of the rectangles passed in by the upper
layers.

Pick-to: 6.9 6.8
Change-Id: Id30c97f80904209726b3aaf37c52b2e14ee2f187
Reviewed-by: James McDonnell <jmcdonnell@blackberry.com>
2025-01-24 12:53:34 -05:00
Joerg Bornemann
ad7b94e163 CMake: Only load Qt6FooPrivate automatically when building Qt
[ChangeLog][CMake] CMake packages of public Qt modules don't provide the
targets of their private counterparts anymore. User projects must now
call find_package(Qt6 COMPONENTS FooPrivate) to make use of the
Qt6::FooPrivate target. User projects that rely on the old behavior can
set the CMake variable QT_FIND_PRIVATE_MODULES to ON.

For user projects, the warning message we know from QMake is displayed.
The warning can be disabled by setting the CMake variable
QT_NO_PRIVATE_MODULE_WARNING to ON.

Within Qt itself, find_package(Qt6Foo) will still
find_package(Qt6FooPrivate).

For static Qt builds, we need to wrap usage of private Qt modules in
$<BUILD_INTERFACE> or $<BUILD_LOCAL_INTERFACE> (if CMake's version is >=
3.26). Static builds with CMake < 3.26 will always load the private
modules if the Qt6FooConfig.cmake from Qt's build tree is loaded. This
is the case in non-prefix builds and (in the future) when building
examples as external project.

This amends commit fbbf4ace0188b9718b6d7808021c0b887fd52d9f.

Pick-to: 6.9
Task-number: QTBUG-87776
Change-Id: I78e95248f2b3fa73c3005c61df2fe4f71ad8eeb8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-24 18:53:34 +01:00
Morteza Jamshidi
cf9c94e851 Show window without activating if WindowDoesNotAcceptFocus flag is set
Added an extra condition to only show the window (without activation)
if Qt::WindowDoesNotAcceptFocus flag is set. (Mostly from qml)

Fixes: QTBUG-130912
Change-Id: I6b7a9cd03d726315b8531600c6a8b33436a3348b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-24 18:53:34 +01:00
Timur Pocheptsov
13109ba350 QTestLib: Add helper function to check for keychain access issues
To be used in network-related tests where we potentially are
using private/public keys and (on macOS) end-up with keychain
access blocking a test with dialogs requesting a permission
to access the keychain.

Task-number: QTBUG-132645
Pick-to: 6.9 6.8
Change-Id: Ide74633bf88b0453d5d8f8de56282c8cf8207380
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-24 12:27:16 +00:00
Fabian Kosmale
e4fbbdea05 _qt_internal_process_resource: Properly escape XML
XML requires escaping for certain characters, and we need to consider
this when writing out qrc files (which use XML).

This commit introduces a helper function,
_qt_internal_escape_xml_characters, to take care of the escaping.
It uses regular expressions to process the input strings. We take care
to start with '&', as '&' needs to be escaped, too.

We minimize the amount of escaping we're doing (the exact rules
differing between attributes and text), to avoid unnecessary work that
needs to be done when configuring a project. This is achieved by a
SUBSET option which can be passed to _qt_internal_escape_xml_characters.

Pick-to: 6.8 6.9
Task-number: QTBUG-131916
Change-Id: Ic1bd0eedee0343c3d70b6954842e21b3c550b092
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-24 12:30:37 +01:00
Marc Mutz
420ca3463e tst_QUuid: fix -Wreturn-type in make_minimal(QUuid::Version)
The code relies on -Wswitch, but lacked the Q_UNREACHABLE_RETURN() at
the end that compiler and code readers need to understand that we don't
accept values other than those enumerated, even though an enum variable
could hold other values, too.

Since the function is constexpr, can't use that macro directly, but
need to copy the usual GCC 8 magic incantation.

Amends 171ff57be1b8fd1c1b33cffbffa389790f239b5c.

Pick-to: 6.9 6.8
Change-Id: I6c9dd0e4178211f57da61aa6df70f8036370f158
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-24 10:44:47 +00:00
Andreas Eliasson
9182f60b45 Doc: Fix method docs for QOpenGLTexture::setWrapMode
The current method description seems like a copy-paste left-over.

Fixes: QTBUG-57209
Pick-to: 6.9 6.8 6.7 6.5 6.2 5.15
Change-Id: Ife9f9f7bc97d990f5d447208bd39c2d2b6a614fd
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-01-24 11:44:47 +01:00
Christian Ehrlicher
ed18ad9543 Windows11Style: fix drawing rounded corners in itemviews
When drawing an itemview item, the rounded corners (for current and
hovered item) were not properly drawn - the rounded corners of the
windows11 style were sometimes also visible where they should not be.
Fix it by using a clip rect and move the rounded corners out of the clip
rect on the appropriate places.

Pick-to: 6.9
Task-nubmer: QTBUG-131585
Change-Id: I4eccc1e65768306a5511cda6e18db8f56fe1eff6
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-01-24 05:15:11 +00:00
Thiago Macieira
39564261b2 QThread/Linux: disable the filling in of the trivial cpuset variable
We don't need it and it just makes the code slower with a large array.

Change-Id: I06dfa436309bfd249c06fffddb4cec658cf356a9
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-23 18:09:38 -08:00
Mate Barany
918566aedd Update CLDR to v46.1
[ChangeLog][Third-Party Code] Updated CLDR data, used by QLocale, to
v46.1.

Task-number: QTBUG-132851
Pick-to: 6.9 6.8
Change-Id: Id08d9337e11234d0ca428c7e435808be1b044f7c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-01-24 02:45:39 +01:00
Marc Mutz
a01b14f1de QTemporaryFile: add private API for an overwriting rename()
In many situations, it is desireable that QTemporaryFile::rename()
overwrites an existing file, such as when emulating QSaveFile because
one would like more control over the temp file (such as passing it to
a different process). The public API of QTemporaryFile did not allow
it, making the typical Unix mktemp + mv algorithm to avoid symlink
attacks unimplementable with public Qt API.

QSaveFile is not a 100% replacement, because it always follows
symlinks and places the temporary file beside the physical target
file, keeping the symlink intact, instead of placing the tmp file
beside the symlink and clobbering it, if the target happens to be one.

Extract Method QTemporaryFilePrivate::rename() and add a bool
overwrite parameter that causes the existing
QTemporaryFileEngine::renameOverwrite() to be called in lieu of
QTemporaryFileEngine::rename(). The non-atomic path via
QFile::rename() is not affected.

This makes the functionality available as private API, in case we need
it in older branches.

Task-number: QTBUG-132646
Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I0d5ca96c0a1a557854582e1a565a3db0d8af2a95
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-23 22:42:17 +00:00
Felix Lionardo
2dfbfd5f9a Add libfsnotify to the core library for QNX 8
QNX 8 moved the inotify API implementation to a separate library,
libfsnotify. Added qt_config_compile_test to verify inotify in libfsnotify

Pick-to: 6.9 6.8
Change-Id: I5906d8fd0f146dc9db8d9ae2d8c0053bff21b840
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-23 17:14:56 -05:00
Thiago Macieira
d8e205a003 client: use QDesktopUnixServices instead of QGenericUnixServices
Renamed in 3e29267df0e2f332290caad69e5bd5cfd61cf3da in qtbase.

Pick-to: 6.9
Change-Id: If857e206071226c2d0f6f42ce1c9b4d091b0bc63
Reviewed-by: Liang Qi <liang.qi@qt.io>
2025-01-23 22:02:38 +00:00
Jøger Hansegård
604b6d60d0 Use 0/nullptr to indicate invalid Windows event handle in QLocalServer
The CreateEvent function returns NULL/nullptr if it failed, not
INVALID_HANDLE_VALUE(-1).

Change-Id: I7fb94061f4e14c014bf63acb53d3eee8f295eb66
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-23 22:05:07 +01:00
Alexandru Croitor
0b7ff3d0a7 CMake: Add an option to pass --showinternal to qdoc
This adds an SHOW_INTERNAL option to qt_internal_add_docs that
passes the --showinternal option to qdoc.

The option can also be set for all calls by setting either the CMake
variable QT_QDOC_SHOW_INTERNAL or the environment variable.

Pick-to: 6.8 6.9
Fixes: QTBUG-118176
Change-Id: If72c4072e10bc5f12b0431a5f8abea6ee1e2bd69
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-23 20:06:16 +01:00
Alexandru Croitor
948b2f601d CMake: Add various option to pass extra args to qdoc execution
Calls to qt_internal_add_docs now accept the following options:
- QDOC_EXTRA_ARGS: Extra arguments to pass to qdoc
- QDOC_PREPARE_EXTRA_ARGS: Extra arguments to pass to qdoc prepare
  phase
- QDOC_GENERATE_EXTRA_ARGS: Extra arguments to pass to qdoc generate
  phase

In addition, the following cmake and environment variables can be set
to pass extra arguments to qdoc for all targets:
- QT_QDOC_EXTRA_ARGS
- QT_QDOC_PREPARE_EXTRA_ARGS
- QT_QDOC_GENERATE_EXTRA_ARGS

The cmake variables can also be set at directory-scope, before the
call to qt_internal_add_docs.

Pick-to: 6.8 6.9
Task-number: QTBUG-118176
Change-Id: I0e28f3b863d5ca4efd0256432130af1c9c965f9d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-23 20:06:16 +01:00
Alexandru Croitor
2fd16b2acb CMake: Clean up and document qt_internal_add_docs
Change the option handling code to be similar to our other internal
functions.
Break too long lines.
Add a doc comment.
Add a message(DEBUG) for the case when qt_internal_add_docs is still
called with one argument.
Rename doc_project variable to qdoc_conf_path.

Pick-to: 6.8 6.9
Task-number: QTBUG-118176
Change-Id: I73167f1e72e2abcdb90722ecd6ee00f7636b8a5d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-23 20:06:16 +01:00
Thierry Bastian
ca09bc8d7a Add support for PostgreSQL prepared statements with pgBouncer
Since 2023, pgBouncer supports prepared statements but only when
prepared/executed/removed at the protocol level.
So to support this, You need to call the appropriate functions
from libpq.
it does not change the behavior otherwise. You can note that to free
statements, libpq only has the function in v17.
Prior versions of postgresql will still use DEALLOCATE.

Fixes: QTBUG-132303
Pick-to: 6.9
Change-Id: I2456820bbea318e1715ae46617bf4d137815ca54
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-01-23 18:32:49 +01:00
Matti Paaso
acbbdee804 Fix Axivion analysis nightly fails
Axivion analysis for qt5 is currently ran only for linux and
qtactiveqt started to fail because it now uploads aftifacts also
for linux and is not skipped anymore. Adding condition to prevent
running Axvion analysis for qtactiveqt.

Task-number: QTQAINFRA-6752
Change-Id: I2ce141a1b7c6de387493651c4429edac65e49506
Reviewed-by: Toni Saario <toni.saario@qt.io>
2025-01-23 18:33:14 +02:00
Joerg Bornemann
ed7bc398d8 CMake: Remove transitory code from _qt_internal_find_qt_dependencies
...that tried to load Qt6Foo instead of Qt6FooPrivate. This might now
load the wrong package, since we've split CMake packages of public and
private Qt modules.

Enough time has passed, and we can assume that all
Qt6*Dependencies.cmake files have the _qt_package_name property set by
now.

Pick-to: 6.9
Task-number: QTBUG-87776
Change-Id: Icf18872dd49b1e3a82b7327027f7d6e48b656b70
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-01-23 15:25:49 +01:00
Cristian Le
6a4df2ac24 Make user tools symlinks relative
Fixes: QTBUG-132724
Pick-to: 6.8 6.9
Change-Id: I0f1d95ef6b66c81e2d12730eae3d5c0452a3a7a1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-23 15:25:48 +01:00
Cristian Le
a996442236 Export INSTALL_PUBLICBINDIR to QtBuildInternalsExtra.cmake
`INSTALL_PUBLICBINDIR` is only exported if it was defined by the user
when building QtBase. The conditional check aligns with the one used in
`qt_internal_generate_user_facing_tools_info`

Fixes: QTBUG-107016
Pick-to: 6.8 6.9
Change-Id: Id5c38555e1d22cb3c16d85261cb052c695b4de03
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-23 15:25:48 +01:00
Cristian Le
1192f2c877 Use _qt_internal_relative_path
Pick-to: 6.8 6.9
Change-Id: I1c4248bbf7e06536503224cbfceb57f41de019bc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-23 15:25:48 +01:00
Cristian Le
334acc2eb3 Add _qt_internal_relative_path
This is a compatibility function for `cmake_path(RELATIVE_PATH)`.
For CMake<3.20 it uses `file(RELATIVE_PATH)` instead

Pick-to: 6.8 6.9
Change-Id: Ibf9ca221c1753bd99dcc1820bffaea28f9bfe5af
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-23 15:25:48 +01:00
Liang Qi
225f8e069b QDesktopUnixServices: avoid to call virtual function in constructor
This amends 1969b1a90a79dad049694bd1540f8627d5f26875 .

Pick-to: 6.9 6.8 6.5
Change-Id: I1be4e229d531f8a91e1ad3133a5b62784d18bb41
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-01-23 14:54:48 +01:00
Giuseppe D'Angelo
517dcbf42e QOpenGLEngineSharedShaders: disable copy/moves
The class manages resources via raw pointers, and as such it's certainly
not copiable. Explicitly disallow such copies. (It might be made
movable, but no-one needs to move it, so I'm disabling moves as well.)

This fixes warnings in QMetaType, which would otherwise pick up
copy/moves as the class is also marked as a Q_GADGET.

Change-Id: I983765b35304c8ab9ad42d31bcb729cfc9bfa2ac
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-01-23 14:14:24 +01:00
Laszlo Agocs
20b07bfa30 Drop a limitation for R8/RG8 formats for Mesa in hasOpenGLFeature
The mentioned version is from 2015.

Pick-to: 6.9
Change-Id: I330bd8ec08ab815a85d3e4e5afc44f314ade2ef6
Reviewed-by: Kristoffer Skau <kristoffer.skau@qt.io>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-01-23 14:14:23 +01:00
Laszlo Agocs
3c338def89 rhi: vulkan: Support initializing without a Vulkan instance given
Problem is, this has potential issues down the line. For example,
if one pops up a QQuickWindow afterwards, also with Vulkan, and
wants to do things like enabling the debug layer (QSG_RHI_DEBUG_LAYER
and similar), that will not work since the instance is already up.

In absence of better solutions, drop a warning as well and keep this
undocumented for now.

On the plus side, this allows applications to implement things like
enumerating adapters with Vulkan and then launching a QQuickWindow
with the selected adapter. With other APIs (D3D) this is a breeze,
but is impossible here due to the very unfortunate concept of Vulkan
instances, and handles such as a VkPhysicalDevice being tied to the
instance.

An application has no way of knowing what VkInstance Qt Quick will
create/use, unless the developer does the extra boilerplate to
provide their own, which is an overkill in this case. So offer some
way to make this work, even if there are some pitfalls.

Pick-to: 6.9
Change-Id: I1fc11f90cd1bf3fdac945ed5a7221f596368d30e
Reviewed-by: Kristoffer Skau <kristoffer.skau@qt.io>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2025-01-23 09:59:16 +01:00
Laszlo Agocs
4f5b1c75a9 QVulkanDefaultInstance: warn if setting flags has no effect
Pick-to: 6.9
Change-Id: Ib939e56f0e8bc3e04725fb3660d30a8d3e13fad3
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Reviewed-by: Kristoffer Skau <kristoffer.skau@qt.io>
2025-01-23 09:59:13 +01:00
Laszlo Agocs
2b451c81a3 rhi: Introduce a way to enumerate adapters/physical devices
Requesting a given "adapter" (or whatever the native equivalent of that
is, e.g. a VkPhysicalDevice with Vulkan) has already been possible
either via the index-based environment-variables (QT_D3D_ADAPTER_INDEX
and QT_VK_PHYSICAL_DEVICE_INDEX), or by passing in a VkPhysicalDevice in
QRhiVulkanNativeHandles or an adapter LUID in QD3D1xNativeHandles to
create(). (the latter is what QQuickGraphicsDevice's fromAdapter() or
fromPhysicalDevice() builds on, and is one of the enablers for the
OpenXR integration in Qt Quick 3D for instance)

There was however no way to enumerate the adapters via QRhi APIs, in
order to implement something such as "iterate through the available
adapters and choose one from the list", without resorting directly to
DXGI or Vulkan. This is what enumerateAdapters() enables now.

Implemented for D3D11, D3D12, and Vulkan. There are no plans to
implement it for others for now. (meaning the resulting list is always
empty then)

For symmetry, it is also possible to get a single QRhiAdapter based on a
provided native adapter identity (i.e, LUID or VkPhysicalDevice),
although in practice that is just a heavier way to achieve the same that
was already possible by passing those native handles directly to
create() instead of going through a QRhiAdapter.

[ChangeLog][RHI] Introduced enumerateAdapters() in QRhi to provide a
an abstraction for enumerating adapters (physical devices) with
Direct 3D and Vulkan.

Fixes: QTBUG-129932
Change-Id: I072553afe594cbad6ebfa1ffe849a782c4c181db
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Reviewed-by: Kristoffer Skau <kristoffer.skau@qt.io>
2025-01-23 09:59:08 +01:00
Konsta Alajärvi
d8f75f34c9 Unblacklist tst_qrhi threeDimTexture()
Unblacklist tst_qrhi threeDimTexture() test function, by skipping
it with Android OpenGLES.

Fixes: QTQAINFRA-6333
Change-Id: I795dd73fc7b35ab065f206030458088d829be9c8
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-23 08:44:56 +00:00
Marc Mutz
b80679a90f tst_QSet: check whether remove/removeIf detach if nothing is removed
They do.

Task-number: QTBUG-132831
Pick-to: 6.9 6.8 6.5 6.2 5.15
Change-Id: Ia4e9de7e443d11af9675924718c551a06bc4b447
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-01-23 06:27:03 +01:00
Vlad Zahorodnii
4e1ad21b79 Accommodate more space for new shapes in Qt::CursorShape in Qt 7
Currently, the Qt::CursorShape enum can accommodate only two new shapes
because Qt::LastCursor must be less than Qt::BitmapCursor.

The cursor shapes change rarely but it would be nice to keep them open
for extension in order to be able to react to new UI/UX ideas if needed.

Change-Id: I53ed9d742a09bb06bab73a906643c62a77a207b0
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-01-23 05:47:32 +02:00
Assam Boudjelthia
2ce9140c6c Android: suppress deprecation warning for safe area APIs before Android R
We already handle both cases of pre and post Android R APIs, so  we can
safely suppress the code using older API after extracting it to its own
method.

Change-Id: I3f5d6dab480c5fb32d35f615db719a4a0eb3f45d
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-23 05:26:04 +02:00
Shawn Rutledge
622133ace2 doc: Improve QTextTableFormat::setBorderCollapse and related docs
We changed the default in 6.8. It was documented in the changelog but
not in docs. Amends 09ea47f8113bdce437253b19a91f739aeef7a333

Pick-to: 6.8 6.9
Fixes: QTBUG-132173
Change-Id: I1b6bf69931ba12025cf95e80c12a5073a94af598
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2025-01-23 02:41:57 +01:00
Thiago Macieira
d3b5705c94 QThread/Linux & FreeBSD: replace the QVLA with a real VLA and bump max
We don't need to use the heap, because this array won't get too big.
This commit raises the limit from 4096 logical processors on Linux to
1048576 (i.e., the square). 4096 is less than one system I've had access
to since I wrote this code in 2021 (64 sockets of hyperthreaded 60-core
Intel 4th Generation Xeon Scalable processors = 7680 logical
processors). The 4096 limit would also be reached by a "mere" 16 sockets
of 288-core Intel Xeon 6E processors.

I've also made it grow slightly faster by multiplying by 4 instead of 2.

Change-Id: I7c0d8b5e7809faba72c2fffdf99500868dfd7db4
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-22 13:04:55 -08:00
Thiago Macieira
8500e73040 tst_QTcpServer: add missing const
So the array itself is also const.

Amends a94731c2ad85f9dd40050a780f67c911bf12668e.

Pick-to: 6.9
Change-Id: Ic4d78d3d059dd47f776ffffdd0971b1aa35a69e9
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-01-22 13:04:46 -08:00
Volker Hilsheimer
ab89118b8f JNI: remove noexcept from QJniArrayMutableIterator methods with preconditions
Pick-to: 6.9
Change-Id: Ifdb0c09eec6a269a826ab80e443a11a7858a21b6
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-22 22:38:27 +02:00
Volker Hilsheimer
5fbecf7cb7 QSFPM: Fix closing comment of deprecated invalidateFilter block
Amends 4605f0fd81497688664deee025de40f44837c10d

Change-Id: I3e48272dd87ea0c665ebacd75f4752a965cb8d45
Reviewed-by: David Faure <david.faure@kdab.com>
2025-01-22 22:36:37 +02:00
Vlad Zahorodnii
0345b46ac7 Add QKeySequence::fromString() benchmark
An application may need to load shortcuts from the settings at startup,
so QKeySequence::fromString() should be fast enough if there is a lot of
shortcuts.

This change adds a QKeySequence::fromString() benchmark so one could get
partial insight in its performance.

Change-Id: I9e15c0e9a199787189d5076a41154f127d2930a3
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-01-22 22:35:33 +02:00
Christian Ehrlicher
83ff179f85 QAbstractFileIconEngine: store pixmaps with correct key
QAbstractFileIconEngine stores the generated pixmap in a QPixmapCache
with the size as key. This is wrong as the size is multiplied by the
current devicePixelRatio so this has to be done also for the key.

Pick-to: 6.9 6.8
Change-Id: I6d8ceedc950d23abf9c4d79d92e86848b9508c9b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-22 21:12:33 +01:00
Ivan Solovev
348b680ae5 QFlags: add QT_NO_DATASTREAM checks to datastream operator declaration
Amends 729c0960b84183bcf9576f974cb5e3b3c3fdc6ef.

Found in Qt 6.9 API review.

Pick-to: 6.9
Change-Id: Ieb81fe000e61fef54a003f52789fa1475aac5239
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-01-22 19:33:19 +01:00
Ivan Solovev
b150955043 Restore the docs for QFlags debug streaming operator
The unconstrained implementation was removed, so qdoc was not able to
find a proper function. Provide a fake definition that matches what
qdoc expects. In this case the users shouldn't really care about the
constraints that the actual implementation has.

Amends 0c707c6ebece18677deaccccdfec5d48c587106f.

Found in Qt 6.9 API review.

Pick-to: 6.9
Change-Id: I6207b491fa94cc62d217af7dc7687923dc6971a4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-22 19:33:19 +01:00
Ivan Solovev
f1d2d47f60 Fix SFINAE constraint in flags debug streaming operator
So that it allows overloading.
Also move the type T declaration into the function scope, as it
could never be used as a constraint anyway, and we do not want
users to pass custom type there.

Amends 0c707c6ebece18677deaccccdfec5d48c587106f.

Found in 6.9 API review.

Pick-to: 6.9
Change-Id: I086d65bdef7be2f9e0e67e96cc8a9ac76eaa5b0f
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-22 19:33:19 +01:00
Assam Boudjelthia
aa1c594c4c Android: remove unused imports
Change-Id: Ia23fc2f93bf47e9e0ede098399bc36e992287ace
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-22 20:33:19 +02:00
Assam Boudjelthia
090b66acf3 Android: extract QtSurface.getHolder() to a var and re-use it
Change-Id: If0dfc66a3905640c6074f74849bcfca923c06ba5
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-22 20:33:18 +02:00
Assam Boudjelthia
740d995a89 Android: suppress deprecation warnings for pre-Android 30 system ui APIs
Those APIs are already guarded with an API check, so we can silent
javac warnings about them.

Change-Id: I98dc12520e25c513ed97d750446f188dcf084362
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-22 20:33:18 +02:00
Assam Boudjelthia
d25064b04d Android: don't pass x/y dpi values to setDisplayMetrics()
Those values are only used to calculate the final value for the screen
size, which means we can simply do the calculation first and pass the
final values anyway and avoid carrying those params and making things
harder to read, and since those values are tied to the screen, we can
deffer calculating the physical size to the screen itself.

Dpi values are at least DisplayMetrics.DENSITY_LOW, if the xdpi/ydpi
returned metrics values are below that.

Task-number: QTBUG-132720
Change-Id: Idd6a4db24a460aeb66e626cd93d52b87566ce69c
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-22 20:33:18 +02:00
Assam Boudjelthia
65c41c6be6 Android: get rid of default screen sizes and physical size
The default screen size and physical size are not needed, since
QAndroidPlatformScreen constructor calculates that shortly after we
assign it a default value. As for the default available geometry,
we need to keep that, but we can move that to live directly under
QAndroidPlatformScreen class, with that we can reduce the chained
calls from androidjnimain.cpp to the platform integration to the
platform screen.

Task-number: QTBUG-132720
Change-Id: Icd2db91ab36a68cd53c3dfb702f41f6b519e476b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-22 20:33:18 +02:00
Assam Boudjelthia
6f79d46e80 Android: handle density and refresh rate changes in onDisplayChanged()
As it makes more sense that they belong there.

Task-number: QTBUG-132716
Change-Id: I1bc44ee046c470e40767b1e8f098241eb9bbafee
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-22 20:33:18 +02:00
Assam Boudjelthia
3efd1996a3 Android: update density on its own when it's changed
Instead of doing it every time under setDisplayMetrics().

Task-number: QTBUG-132716
Change-Id: I0887c086d7f653b0170e107a86cb0115582bbc89
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-22 20:33:18 +02:00
Assam Boudjelthia
3305eb10da Android: don't call onSurfaceChange() native method with every change
We don't need to re-assign the surface each time it's changed,
instead the assignment needs to be done only when creating or
destroying the surface.

Task-number: QTBUG-132721
Change-Id: I72c8c81a692b9e739af0e0a7b0f934b69a9a0fa8
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-22 20:33:17 +02:00
Ahmad Samir
e9f726db84 examples: check return value of QFile::open() calls
QFile::open() is marked [[nodiscard]].

Change-Id: I0fa884b329a47c4ad59f40d66b5fbc38f3a5648e
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2025-01-22 19:53:25 +02:00
Ahmad Samir
3b95bfe7c7 QString/QByteArray: add nullTerminate{,d}()
As requested in code review.

utf16() guarantees that the string will always be \0-terminated which
could mean allocating behind the scenes. On the other hand
nullTerminate{,d}() makes it obvious that the data may be deep-copied.

For QByteArray, this partially reverts
e0206fe9d47bfbf18a0d4c2e5e780504305f72e7. Adding the same method to
QByteArray was requested in code review for API symmetry.

[ChangeLog][QtCore][QString] Added nullTerminate() and nullTerminated()
methods (like chop() and chopped()), which are useful for strings
constructed with fromRawData() when calling methods that expect
\0-terminated strings.

[ChangeLog][QtCore][QByteArray] Added nullTerminate() and
nullTerminated() methods, which are useful for byte arrays constructed
with fromRawData() when calling methods that expect \0-terminated data.

Change-Id: Iec33b889a9ab62460b7a0df8f9b2189f3f794a54
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-22 19:11:10 +02:00
Marc Mutz
09fa335fb2 Update public suffix list
Version 47264b57765919188b9f4144de8d95cf77e1b6dc, fetched on
2025-01-22.

[ChangeLog][Third-Party Code] Updated the public suffix list to upstream
SHA 47264b57765919188b9f4144de8d95cf77e1b6dc.

Pick-to: 6.9 6.8 6.5 6.2 5.15
Task-number: QTBUG-132851
Change-Id: Iba19f5006e8cb60505505c96a4e4649b075cae6e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-01-22 18:00:46 +01:00
Marc Mutz
15a0b9624d util/update_public_suffix_list.sh: update the pick-to's
Drop 6.7 and add 6.9.

Task-number: QTBUG-132851
Change-Id: I68d787578ce4070c030e30ea95d710a6e1298f19
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-01-22 18:00:46 +01:00
Marc Mutz
b9f74f9a0b util/update_public_suffix_list.sh: adapt to PURL addition to qt_attribution.json
Also add a comment to publicsuffix-list's entry that the update is
done by a script that should be updated whenever this file's contents
change.

Amends 36dca3c04f759449f74008a3e79021a179b0f35e.

Pick-to: 6.9 6.8 6.5
Change-Id: I1a0e51568e6d4300197c09f759ad3d82277a74d1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-01-22 18:00:46 +01:00
Konsta Alajärvi
a34b5d60e0 Unblacklist tst_qrhi renderToTextureArray
Try to unblacklist renderToTextureArray test on android

Fixes: QTQAINFRA-6334
Change-Id: I59c914b66645dc30e7f1a34f9aefc7fb66e95a67
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-22 13:06:35 +00:00
Liu Jinchang
735c205ff4 Disable chroma subsampling for high-quality JPEG saves
Set horizontal and vertical chroma subsampling factors to 1 when quality
exceeds 90 to preserve color details in high-quality JPEG images.

Fixes: QTBUG-109856
Change-Id: Id5f6a2bbd07cb07991fed44a79498c505db3f3ba
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-01-22 19:57:18 +08:00
Morteza Jamshidi
d4ccceabf4 Use old position to set window position after recreation
Like window state and visibility, the window position should also
remain the same after the window is recreated.

Fixes: QTBUG-128790
Change-Id: Iad8599da7ef83eff6a93f7f071e6b452491a0d87
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-22 12:57:18 +01:00
Tuomas Vaarala
9261b68395 Remove quotation marks from objcopy call parameter for QNX
If the objcopy call parameter is in quotations marks it fails the call
and prevents separate debug info builds for QNX.

Fixes: QTBUG-132801
Pick-to: 6.8 6.9
Change-Id: Ifadf57f80eb5c354aedeb8985bc7a0c9b79dc62e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-22 13:57:18 +02:00
Mitch Curtis
742a0ed72f Make iconbrowser manual test directly openable in Creator
This avoids the need to run qt-cmake-standalone-test and then import
the test, as described in QTCREATORBUG-25389.

Pick-to: 6.9 6.8
Change-Id: I010d6613debb2e34ef3809d2da78ca33ade4d602
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-22 18:16:12 +08:00
Christian Ehrlicher
38277a88f1 SQL/ODBC: escape values in connection string
The previous attempt to escape invalid characters for username/password
did not work for e.g. '}' or '{'. The msdn documentation is somewhat
inconsitent here but after testing it looks like putting the
username/password inside '{' and '}' no matter if needed or not is the
easiest way. We have to escape '}' by doubling it though.
No need to escape the DSN - testing on windows revealed that ';' is not
allowed in there and '\'' and '"' at the start of the DSN is perfectly
fine without any escaping.

Pick-to: 6.9 6.8
Fixes: QTBUG-122642
Change-Id: I04d007d343dd65eb0dbc0252518843eb43cd9ab8
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-01-22 05:16:02 +00:00
Thiago Macieira
c93e98648c qlogging.cpp: clean up of QT_BOOTSTRAPPED
Amends commit df2e07549e6edd1d271cce1d86cadd4a33dfd8fc which removed
this file from the bootstrap build.

Drive-by remove pre-thread_local content, which isn't needed in 2025.

Change-Id: I406c748a5f0aedb5a846fffde5a2f5eb5f875f14
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-22 03:28:39 +00:00
Thiago Macieira
5ca803a3d0 QMessageLogger: simplify the backtrace code
By moving one of the #if, we can remove the other.

Change-Id: I167cf466ef965758e5e8fffd94f8f8169599e3c6
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-21 19:28:39 -08:00
Ahmad Samir
db5163dca9 Benchmarks: port Q_FOREACH to ranged-for
Simple cases, all local const containers.

tst_QHash: rename the template parameter to "Str". My eyes saw
"QList<String>", but my brain somehow assumed QList<*Q*String>. You
could argue that I am a bit slow, but it has tricked someone else in
code review, so just rename it for the sake of clarity.

Drive-by, remove braces from one-line for-loop-block.

Task-number: QTBUG-115839
Change-Id: Ia1a56bea7b931efb377ba8c04ee8933561abf341
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-22 05:28:38 +02:00
Lorn Potter
cdcfaf796e wasm: remove internal unsupported libraries from build
we have no access to system devices, so no need for discovery
or framebuffer.

Change-Id: Ie697f4b24b3a38efeff67fc670549a055da57745
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-22 02:24:46 +00:00
Lorn Potter
44b513f192 wasm: remove unsupported libraries from wasm build
We do not support printing and sql, so best not to build and
shipping them.

Change-Id: Ibc929b127fd8416aa3d3b784a6ed0c2ce86db80d
Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-22 12:24:45 +10:00
Marc Mutz
b5ed7fb203 Short live q20::exchange()!
We have weaned ourselves off of qExchange(), which, however, has C++23
semantics (is constexpr and noexcept), while we only require C++17 atm.
At the same time, we have more and more uses of a constexpr exchange(),
iow: the C++20 extension.

We have the qNN namespaces for this, so let's use it: Add
q20::exchange(), with C++20 semantics (constexpr, not noexcept), and
use it to port the only remaining qExchange() user (since ported to
2×std::move() to make the header compatible with QT_NO_QEXCHANGE),
QScopedValueRollback.

No user requires the C++23 noexcept on the function (compilers will
figure it out, because the std::exchange is fully inline), and we
can't provide a q23::exchange() even if we needed to, because the
author of P2401 forgot to ask to update the value of
__cpp_lib_exchange_function...

Fixes: QTBUG-133038
Pick-to: 6.9 6.8
Change-Id: I003df445001d1c5ab02402119c5e5106aa156263
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-22 00:08:28 +00:00
Volker Hilsheimer
4605f0fd81 QSortFilterProxyModel: add endFilterChange, deprecate invalidateFilter
This adds the typical end*() call to match the beginFilterChange() call
introduced by 00ce45efe16ff440651746a94c62e0d5c1f6e435. Pairing those
calls is necessary to make sure that the model can keep track of changes
between the old to the new filtering and emit the correct signals.

By deprecating the invalidateFilter() functions, we also make it clear
that existing code needs to be ported to the new API calls to avoid the
potentially incorrect or missing signal emissions.

Introduce a new FilterDirection enum with flag type FilterDirections
to indicate whether a row- or column-filter (or a filter impacting both
directions) changed. Replace the internal Directions enum with that,
it's no longer necessary.

Task-number: QTBUG-115717
Change-Id: I31c43ba846d665ef26c8a013d064421484f006cb
Reviewed-by: David Faure <david.faure@kdab.com>
2025-01-22 00:34:51 +01:00
Thiago Macieira
40ad963e1a tst_QMessageLogger: disable Android once and for all
The messages said "This test crashes on Android" bu tit appears the
problem is not a crash, but that the executable can't be executed. The
file appears to be present and yet execve() is producing ENOENT (No such
file or directory). That probably means it's the interpreter stored in
the ELF header's dynamic section that is not found.

Fixing that is SEP[1].

[1] https://en.wikipedia.org/wiki/Somebody_else%27s_problem

Pick-to: 6.9
Change-Id: I3025825c5e00f47a5a40fffd53c47131db3676dc
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-21 13:27:36 -08:00
Alexandru Croitor
baddc0a195 CMake: Build executables in single-config debug-and-release builds
If qtbase is configured with -debug-and-release -force-debug-info,
which maps to '-GNinja Multi-Config'
'-DCMAKE_CONFIGURATION_TYPES=RelWIthDebInfo;Debug'

and then qtopcua is configured with -GNinja -DCMAKE_BUILD_TYPE=Release
building the 'all' target would not build executables or tools.

That's because the targets have their EXCLUDE_FROM_ALL property set to
exclude any non-first multi-config, and Release doesn't match
RelWithDebInfo.

Such a scenario can happen for our multi-config windows builds, when
someone tries to build a repo not with qt-configure-module but rather
with cmake directly. They would then not specify the same build types
or generator, which can happen when opening in an IDE like Qt Creator.

Make sure to also check if the current generator is a multi-config
one, in addition to whether QT_FEATURE_debug_and_release is ON, before
adding the genex to the EXCLUDE_FROM_ALL property.

This allows building and installing executables and tools in such a
scenario, because in a single config build, the genex would not be
added, even if QT_FEATURE_debug_and_release is ON.

Pick-to: 6.8 6.9
Fixes: QTBUG-132609
Task-number: QTBUG-132338
Change-Id: Iaee1a0afb19df97ee1263dbaf27c8e29fc127831
Reviewed-by: Jannis Völker <jannis.voelker@basyskom.com>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-01-21 21:16:42 +01:00
Giuseppe D'Angelo
78a46bf16b QEasingCurve: fix (de)serialization in QDataStream
The serialization code did stream out a function pointer as an integer,
and then tried to set it back -- effectively, it has *never* worked
since the beginning of public history, unless
serialization/deserialization were done within the same process.

While we cannot support streaming custom easing functions, we can
recover the non-custom functions from the type, which was also streamed
out; setType will take care of that, and we'll just ignore the
subsequent field in the stream.

If one tries to stream out a QEasingCurve with a custom curve, what do
we do? I've decided to just print a warning and stream _something_ out,
so I can keep some degree of behavioral compatibility and aggressively
cherrypick this patch.
AFAIK, there's no support for such a scenario in QDataStream: all
out-stream operators have a wide contract, and there's no Status flag
that meaningfully represents this case (and I doubt anyone checks QDS'
status while writing into it).

Change-Id: Ifa80cf3a9003cab074ddf112022c09b364497007
Fixes: QTBUG-132575
Pick-to: 6.9 6.8 6.5 6.2 5.15
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-01-21 21:16:42 +01:00
Nicholas Bennett
afa34d5f37 Docs: Add that Qt Print Support is not available on Android
Created a list and added Android to the existing mention of iOS.

Fixes: QTBUG-132742
Pick-to: 6.9 6.8
Change-Id: I6e906980d28b54daf18c019eb9299a9d67daef3d
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-21 20:16:42 +00:00
Eskil Abrahamsen Blomfeldt
308ee2738f Update Harfbuzz to version 10.2.0
[ChangeLog][Third-Party Code] Upgraded Harfbuzz to version
10.2.0.

Pick-to: 5.15 6.5 6.8 6.9
Fixes: QTBUG-132855
Change-Id: I542c054ccdc311b17363456c693a2057c2e496c1
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-21 20:21:21 +01:00
Edward Welbourne
549bab4150 QtTest: Update valgrind (fatuously) to v3.24.0
Nothing has changed in the headers we use, aside from the version
number, since v3.23.0, so we may as well declare ourselves up to
date.

[ChangeLog][Third-Party Code][QtTest] Valgrind headers are up to date
with Valgrind v3.24.0.

Pick-to: 6.9 6.8
Task-number: QTBUG-132871
Change-Id: Ib2ad8d73e662535a014d241b46cc50214b45f50b
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-21 19:21:21 +00:00
Edward Welbourne
a419db7160 Correct description of 3rd-party CPU cycle counters
Pick-to: 6.9 6.8
Task-number: QTBUG-132871
Change-Id: Ia0a467297393be72ff7d39b7333ad86e09057dff
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-21 18:50:43 +01:00
Edward Welbourne
d48ceb1c10 Use QLocale::Language as row type instead of a mess of casting via int
Change-Id: Id3345cfe6dd77a747a22e7c5292a012a4ac1fdb8
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-21 18:50:42 +01:00
Edward Welbourne
cbf49f735e Amend QLocale::uiLanguages() order
Include each of an entry's truncations right after the entry if its
script (or, where absent, the one implied via likely subtag rules)
matches and there is no later entry that it should appear after. This
is a compromise between prefering strictly equivalent matches to
potentially incompatible ones and prefering candidates derived from
earlier entries in the original list. Defer to QLocaleSelector (see
QTBUG-112765) the addition of options to give the caller control over
how to make that compromise.

Pick-to: 6.9
Fixes: QTBUG-131894
Change-Id: I8750f4f40530c94638853388f47fcae1008db8d5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-21 18:50:42 +01:00
Edward Welbourne
7f9ee43de7 Include more pruned likely-equivalent entries in QLocale::uiLanguages
We were including, for each entry we got from CLDR or the system,
minimal and maximal additions from CLDR's likely-subtag rules, plus
versions with script omitted and possibly also territory added, when
likely-equivalent to the original. Include also the converse, with
territory omitted and possibly also script added when
likely-equivalent, so as to control order when these entries also show
up by truncation of others.

Pick-to: 6.9
Task-number: QTBUG-131894
Change-Id: I363bfe31867be43807fe3b4942dafa186b8d2e94
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-21 18:50:42 +01:00
Edward Welbourne
2c39365aad Rework QLocale::uiLanguages() to be a bit more straigthforward
Skip duplicates as a separate step, to save some complications. Other
than that, achieve the same results by post-processing the list,
instead of trying to integrate the finding of fallbacks into the main
iteration. This makes the code easier to think about and cope with
further complications as we come to them.

Pick-to: 6.9
Change-Id: If06eae5fd1e91e88b52b3d32ccaba8cbb8e3c8af
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-21 18:50:42 +01:00
Edward Welbourne
09b77a8d07 Add a QDuplicateTracker<T>::contains()
When even some values I haven't seen may need to be left for later,
but values I have seen are definitely to be discarded, I need to know
if I've already processed them before doing the fiddly check for
whether to defer; but if I decide to defer, I haven't yet processed
and need the later check, to which I've deferred, to see the value as
still new, even though I did once ask about it before. So I need a way
to query without adding to the set.

Pick-to: 6.9 6.8 6.5
Change-Id: I712f1c400147210c149aeec6de1d15d2e095d6a9
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-21 17:50:42 +00:00
Liang Qi
3e29267df0 platforms: rename QGenericUnixServices to QDesktopUnixServices
The implementation follows XDG Desktop Portal mostly, and is for
desktop, not generic unix.

Task-number: QTBUG-130884
Pick-to: 6.9
Change-Id: I88456abb37b8b23cfec00ee8eac8ffee9a65ed9f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-21 18:00:53 +01:00
Liang Qi
f8d0e4798c Use QPlatformServices instead of QGenericUnixServices on embedded
Including bsdfb/directfb/eglfs/integrity/linuxfb/vkkhrdisplay.

QGenericUnixServices is mainly for desktop usages which uses dbus
and xdg things.

Task-number: QTBUG-130884
Pick-to: 6.9
Change-Id: I003ec780aa039610cb5c36cd67cabbf173d8f642
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-21 18:00:53 +01:00
Liang Qi
1969b1a90a QGenericUnixServices: avoid dbus calls on non xdg envs
Fixes: QTBUG-130884
Pick-to: 6.9 6.8 6.5
Change-Id: I2525293f776676cda63e61c3c5093045dbafcf38
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-21 18:00:53 +01:00
Liang Qi
ff51ea5418 qpa: lazily populate the services object except xcb
In order to optimize the footprint of QPA plugins, we avoid to
create QPlatformServices object in QPlatformIntegration constructor.
It benefits embedded platforms and others.

Task-number: QTBUG-130884
Pick-to: 6.9 6.8 6.5
Change-Id: I5c0d2616ace9fbc0e077eece32d8836b40fc83dd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-21 18:00:52 +01:00
Soheil Armin
967d9b8cf2 Android: Make use of ItemDataRole in QtAIM tests
Previously we were using raw zero-based integer values
for roles in QtAbstractItemModel tests.

Roles starting from 0x0 to 0xFF are reserved for pre-defined roles
defined in Qt::ItemDataRole enum.

This change will change the base role value to Qt::UserRole.
It will later help us to use QAbstractItemModelTester as this
tester class expects certain types from pre-defined role values.

Task-number: QTBUG-132880
Change-Id: Ie19739cd7bf49829fe58f5ad53078942d47a433b
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-21 17:23:39 +02:00
Soheil Armin
b751a12f7a Android: Incorporate QAbstractItemModelTester into QtAIM CI Tests
QAbstractItemModelTester performs non-destructive tests on test models.
It helps with catching the most common errors in the test model.

Task-number: QTBUG-132880
Pick-to: 6.9
Change-Id: I719f4223d84e66c1d94cbd0380bfdb77b07da7b6
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-21 17:23:39 +02:00
Morteza Jamshidi
7ebdce3cde Differentiate cached cursors with different hotspots or dpi scales
Increased cache accuracy by adding cursor hotspot and dpi scale
to the QWindowsPixmapCursorCacheKey.
Also added cursor hotspot to the QXcbCursorCacheKey.
With this change qt supports creating cursors based on the same
disk file but with different hotspot or dpi scale

Fixes: QTBUG-122381
Change-Id: I1ed6f8fab7f72fe5b658c4f68fa86bc8a033040f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2025-01-21 14:59:35 +02:00
Ilya Fedin
71c4dab8d0 QWaylandWindow: prevent a crash when calling requestXdgActivationToken
It could crash if it's called when there's no mShellSurface

Pick-to: 6.9 6.8
Change-Id: I9b279e915ea661b121da672ebd46be458a1a9218
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-01-21 15:31:38 +04:00
Ivan Solovev
9a3199fec2 qtformat_impl.h: do not include <version>
We intentionally include <version> in the most low-level Qt
header, so that all other headers could just assume that it
is always available.

In this case it is already available from qtconfiginclude.h,
which is included from qtconfigmacros.h.

Amends 20b6ebea84997ecd70d37640f68232c60cc7231f.

Found in Qt 6.9 API review.

Pick-to: 6.9
Change-Id: I430c7392b5237ec582708e3ae1170eabc7c3a402
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-21 12:29:39 +01:00
Ivan Solovev
bb716c0111 QEventDispatcherWin32: properly support 64-bit timeouts
The Windows timer APIs take intervals as uint milliseconds.
As a result, the code was unconditionally truncating an qint64
millisecond value to uint, leading to incorrect timeouts.

Detect such cases, and implement a logic to adjust the interval passed
to the Windows APIs and send a timer event at every second timeout.
This will give a 1ms or 2ms error in the timeout calculation, but that
should be an acceptable tolerance when we talk about intervals around
50 days or longer.

Adjust the tst_QChronoTimer::remainingTimeInitial() test to check that
the remaining time is not less than "expected interval - 1 minute".
This should allow to catch cases when internal calculations are
terribly broken.

It's not really possible to provide even a manual test for timeouts
that are larger than std::numeric_limits<uint>::max(), so just rely on
the existing tests to make sure that the updated implementation does
not break regular cases with smaller timeouts.

Amends 0d0b346322f6b078e6fe60cd3612e8d08a0d5f00.

Task-number: QTBUG-129170
Change-Id: Ib9885dcb7aca18e9fb193fad14bace0efeb437da
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-21 12:29:39 +01:00
Shitong Xu
34f1b6b6d1 QFileDialog: the lastVisited not loaded correctly
Url passed from the QFileDialogArgs will never be invalid, it will
always be the value that user passed into or the lastVisited or the
working directory. And because of this, the fixes code of QTBUG-70798
will never be invoked, and the `lastVisited` will never be initialize if
nativedialog is in use.

I wrote an init function to initialize the `lastVisited` global
variable, to make sure the value will be loaded correctly

Fixes: QTBUG-70798
Pick-to: 6.8 6.9
Change-Id: Id05f63db7b4738e6317721741111882a565437e3
Reviewed-by: Xu Shitong <xushitong@uniontech.com>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-01-21 19:29:39 +08:00
Thiago Macieira
1dcc5a6dd2 QMessageLogger: test that QT_FATAL_{WARNINGS,CRITICALS} work
Pick-to: 6.8 6.9
Change-Id: I8a7f56d67043bae14e10fffdfbaf3060486edbf1
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-21 01:42:46 -08:00
Thiago Macieira
037f6be428 tst_QMessageLogger: rename helper main.cpp -> qlogging_helper.cpp
So it's easier to find in the IDE, as otherwise everything is
"main.cpp".

Change-Id: I8d4663c84603113376a1fffd2f78f87635f3310f
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-21 01:42:46 -08:00
Friedemann Kleint
3e1707d430 Standard dialogs example: Fix compilation with QT_NO_CAST_FROM_ASCII
Add missing tr(), use literals.

Pick-to: 6.9 6.8
Change-Id: I35387e29ce1b08f9df0ade5ee743b33561639f7a
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2025-01-21 07:46:39 +01:00
Friedemann Kleint
f388ca8841 Standard dialogs example: Fix some clang-tidy warnings
- Use auto * when initializing with new
- Initialize variables
- Fix static invocations
- Use per-class includes
- Minor cleanups

Pick-to: 6.9 6.8
Change-Id: I137bc7dfad63bc55a1b1bbc3f42d758bbfdb86ba
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2025-01-21 07:46:35 +01:00
Thiago Macieira
ef73a5f175 QMutex: improve codegen for non-futex lockInternal()
Amends commit ff9da1db0b0963f967f45ab430ec40a3051b70b4.

QDeadlineTimer's Forever constructor is constexpr inline, while the one
taking an integer is neither. In an LTO build, the compiler might have
realized that it's constant, but let's be sure.

Pick-to: 6.8 6.9
Change-Id: I2c07caec660e05efe695fffd6ac8ec3120258a96
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-01-20 19:43:16 -08:00
Thiago Macieira
1957597aa6 QMutex:🔓 replace testAndSet with fetchAndStore for futexes
For systems where we know for sure that we're using futexes, this moves
the storing of the nullptr (i.e., the unlocking) from unlockInternal()
up to unlock() itself. Thus, it replaces a compare-and-exchange
operation plus a store operation with a single one: a simpler exchange.

I don't expect measurable gains with this, as the branch into
unlockInternal() still depends on the result of an atomic operation.

Change-Id: I120dbdc21e678f4b858ffffd60e6ee013ffff555
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-01-20 19:43:16 -08:00
Thiago Macieira
85ebb9d52a QMutex: replace QT_MUTEX_LOCK_NOEXCEPT macro with constexpr trait
This says better what it is and I'll use the trait for the unlock
operation.

Pick-to: 6.9
Change-Id: I46752ca2ee71297d77e5fffdddaa193b6c86dbbc
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-01-20 19:43:16 -08:00
Thiago Macieira
507024317f QCoreApplication/Win: add a better way for ActiveQt to override qAppFileName
Right now, the DLLMain in qaxserverdll.cpp calls GetModuleFileName() on
the hInstance for the DLL and passes the path to QCoreApplication to
override the path. This adds a way for it to simply pass the hInstance
handle, which will automatically cause qAppFileName() &
QCoreApplication::applicationFilePath() return the DLL's path, which in
turn influences the default QCoreApplication::libraryPaths().

Pick-to: 6.9
Change-Id: I3cc172288c54c3938566fffdfb62985000ce2e9c
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2025-01-20 19:23:33 -08:00
Thiago Macieira
08cd38078e tst_QProcess: remove duplicate DisableCrashLogger variable
Amends 90bc0ad41f9937f9cba801b3166635f6f55e0678.

Pick-to: 6.8 6.9
Change-Id: I3faad81a5748ed0942d4fffd93c82124fc18b751
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-20 19:23:32 -08:00
Thiago Macieira
aecafffe56 qlogging.cpp: sort the headers and move qt_windows.h to the bottom
Standard practice.

Change-Id: If8d08785be6073236e92fffd0acea703f5a7f49d
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-20 18:03:39 -08:00
Thiago Macieira
e3ca467f40 qlogging.cpp: move the qt_gettid() function to a header
Just for code organization.

Change-Id: Ifa5da67b98f07f669e4ffffd1a0fc10b4087b6b2
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-20 18:03:39 -08:00
Friedemann Kleint
e90115b5f7 uic: Write Palette/Gradient code with fully qualified enumerations
Pick-to: 6.9
Task-number: PYSIDE-1735
Change-Id: Ica05108d8802f235fd067095072547c1461e7387
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2025-01-21 00:18:36 +01:00
Ahmad Samir
be3bf632e1 QString: add {setUtf16,setUnicode}(const char16_t*) overloads
This is a first step for adding QT_NO_INTEGRAL_STRINGS in the next
commit.

Mark setUtf16(const ushort *) as obsolete.

Use the weak overload workaround, so that the call isn't ambiguous if
it's called on a nullptr.

[ChangeLog][QtCore][QString] Added setUtf16(const char16_t *) and
setUnicode(const char16_t *) overloads.

Pick-to: 6.9
Task-number: QTBUG-125871
Change-Id: I25d12c19876466c235c0d9928aae6fd332836bf5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-21 01:18:36 +02:00
Ahmad Samir
6b7c354f5a tst_QKeyEvent: compile with QT_NO_FOREACH
The containers are local (window.keyEvents is a member of Window, which
is constructed on the stack, so a local container too), and they are not
changed during iteration, so use ranged-for and std::as_const.

Drive-by change: make loop variable a const&.

Task-number: QTBUG-115839
Change-Id: I9ad40068ff6209cf57f31ce0d4f38882eddbfc44
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-21 01:15:26 +03:00
Ahmad Samir
9b44acfd26 Docs: fix qdoc enum's \value "since" syntax
Square brackets.
https://doc.qt.io/qt-6/10-qdoc-commands-tablesandlists.html#value

Pick-to: 6.9
Change-Id: I1d9237461a4eafb72b28ae019c02ba72f82d0f17
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-21 00:15:26 +02:00
Christian Ehrlicher
c917d16f4b Widgets: add enum values to QStyleOptionViewItem::ViewItemFeature
Add two new enum values:
IsDecoratedRootColumn: notifies the style that the current cell also
contains place for the tree column branch indicator so it can e.g.
properly draw rounded edges in a cell or complete row.
IsDecorationForRootColumn: the item contains the information to draw
the tree column branch indicator.

Pick-to: 6.9
Task-number: QTBUG-131585
Change-Id: Iee2823fe3a227630f926d0448095a10fad2b0ba7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-20 21:03:50 +00:00
Christian Ehrlicher
2ec4c28470 Windows11Style: don't set minimum width for QAbstractSpinBox
There is no need to set a minimum width for QAbstractSpinBox in
QWindows11Style::polish() as this might override the user preferences.
Also the minimum size handling is now properly done within
sizeFromContents().

Pick-to: 6.9 6.8
Change-Id: Ibc1fd7a6f862fc85e3739025b9de581aa235d74c
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2025-01-20 22:03:50 +01:00
Edward Welbourne
9574e8cbef QMimeType::comments(): skip locale-name-trimming
Pruning the part of a locale name after the first '_' should now be
redundant, as QLocale::uiLanguages() now includes the resulting
truncations. It may do so later in the sequence than the pruning used
here, where the pruned version either might be a bad choice (due to
being in a script incompatible with what we started on, e.g. pruning
pa_PK to pa, which uses a different script) or would also arise from
some later, more specific, entry (as when uiLanguages() is expanded
from {en_NL, en_150}, where checking en immediately after en_NL would
bypass the more specific en_150 when present).

Pick-to: 6.9
Change-Id: I4c7c199ca16a8e4803843547c5a689cea11af1f2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-20 22:03:50 +01:00
Andreas Eliasson
bc733ea787 Doc: Fix typo in in scope resolution operator
Fixes: QTBUG-132911
Pick-to: 6.9 6.8 6.7 6.5
Change-Id: Iaa7c4830abd273ccfe558e089da5072a83607f26
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2025-01-20 22:03:50 +01:00
David Faure
3ff989acaf Docs: remove \internal in the docs for encodeMetricF()
The documentation for QPaintDevice::PdmDevicePixelRatioF_EncodedA
refers to encodeMetricF() which was nowhere to be found in the
documentation because it was marked as internal.

Pick-to: 6.8 6.9
Change-Id: I37707bc641d359f367f77c958043b6dfa33d4dcb
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-20 19:46:00 +00:00
HIDAKA Takahiro
30c7586392 iOS: Fix rotation zero for standard Apple Pencil (not Pro)
Since standard (non-Pro, 1st gen, 2nd gen, and USB-C) Apple Pencils
do not support rotation (barrel roll), the rotation value
should be set to zero.

Task-number: QTBUG-128467
Change-Id: I33511c39cab1fb14a2ef622ab98ce49eb95f3295
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-21 04:45:59 +09:00
Shawn Rutledge
1accd24216 Avoid dangling d-pointer deref in QWidgetWindow::handleMouseEvent
If you drag-and-drop a OpenGLWidget in Designer, the main window gets
re-created when the OpenGLWidget is instantiated. So in general (in
rare cases), at the end of QWidgetWindow::handleMouseEvent() we might
have a different window, and therefore can't reliably call
QWindowPrivate::maybeSynthesizeContextMenuEvent() without checking for
a valid pointer.

Amends 84a5f50c7766c99f62b22bb4388137e0aa8dd13d

Pick-to: 6.9
Fixes: QTBUG-132912
Change-Id: I7b220b4daceab988aadabf9427ef6b2d5624e00d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2025-01-20 20:45:59 +01:00
Alexandru Croitor
6404714183 Remove unsupported linker script objc_namespace.sh
According to the discussion in QTBUG-132398, the script stopped
working in newer Xcode versions, and also didn't cover new
Objective-C language features.

Remove the script to avoid confusion.

Pick-to: 6.8 6.9
Fixes: QTBUG-132398
Change-Id: I37b96ac6a77af1fcc4221591cb1f6320fa9a024b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-20 18:51:27 +01:00
Giuseppe D'Angelo
ca9200910e Do not rely on transitive includes when using libc++
Libc++ is migrating towards fine-grained headers [1], removing indirect
inclusions. To prevent breakages in client code, this feature is opt-in,
happening when one bumps the C++ version used or defines the
_LIBCPP_REMOVE_TRANSITIVE_INCLUDES macro.
This commit adds the macro when building Qt. I'm pretty confident this
won't cause breakages because we have also been building Qt on the CI in
C++ > 17 modes.

[1] https://libcxx.llvm.org/DesignDocs/HeaderRemovalPolicy.html

Change-Id: I7553274ef51ccc9b462c98fdab55b27e5715afaa
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-20 17:51:56 +01:00
Giuseppe D'Angelo
34f60877bd TinyCBOR: prevent a -Wundef warning
Follow the same "pattern" as for the rest of the #if directive: first
test if a macro is defined, then test the value. Otherwise the code
triggers a -Wundef when building in C++.

Task-number: QTBUG-132900
Change-Id: Icc838bf8dfafed1ab317ff70cb19559b72b22dc9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-20 17:51:56 +01:00
Alexey Edelev
453b20ea94 Add the meta target that allows building all plugins at once
Add the qt_<plugin_type>_plugins_all target that allows building
all plugins of the <plugin_type> from build tree at once.

Change-Id: Ie5057b9c51dcdfba36e3572064533d698d7549e9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-20 17:51:56 +01:00
Alexey Edelev
8272b747d3 Replace qt_record_extra_qt_package_dependency with qt_register_target_dependencies
qt_register_target_dependencies does the same thing as
qt_record_extra_qt_package_dependency but in more convenient way.

Update the qt_register_target_dependencies signature and adjust naming,
it now accepts PUBLIC and PRIVATE multi-value arguments and called
qt_internal_register_target_dependencies.

Use it and deprecate qt_record_extra_qt_package_dependency.

Pick-to: 6.5 6.8 6.9
Change-Id: I0594cf699ec1e3af7210dd7450fa3f81c1f565ae
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-20 17:51:56 +01:00
Alexandru Croitor
9f59379198 CMake: Use a unique resource identifier in simpletreemodel example
To avoid the following error:

 The custom command generating
    .rcc/qrc_editabletreemodel.cpp
  is attached to multiple targets:
    editabletreemodel
    editabletreemodel_tester
  but none of these is a common dependency of the other(s).  This is
  not allowed by the Xcode "new build system".

Pick-to: 6.8 6.9
Fixes: QTBUG-131631
Change-Id: I1c5d0702596a4f8f723d9080bc5304d6ad06853b
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-01-20 15:44:08 +01:00
Petri Virkkunen
f910954928 Android: JNI: Use void as default return value type on call[Static]Method
By using void as default template argument in callStaticMethod and
callMethod, we can avoid having to type <void> after every void method
call, while still allowing the caller to remain explicit about the type
if they want to.

Change-Id: Id7143d1116364be7699712d1fead257f26f20420
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-20 15:36:13 +02:00
Mårten Nordheim
2defca4187 QFile::rename: error out if overwrite fails when changing case on case-insensitive filesystems
The generic copy-and-remove fallback will first open the original file
with a different case, truncate it, and then remove the original file.
Leaving us with no file at all.

Task-number: QTBUG-132785
Pick-to: 6.9 6.8 6.5
Change-Id: Ia5a41d26c1d6d6bdc231c71acf15bd2ea496c715
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-20 13:25:52 +01:00
Eskil Abrahamsen Blomfeldt
b154af082c Request actual font family request in final color font fail safe
When we're trying to resolve a font for color emojis, we will
prefer any color font over the selected font (since a normal
font may have monochrome glyphs for emoji characters and that's
not what we are after).

If there are no color fonts on the system at all, we need to do
a final match where we ignore whether the font is in color or
not and just return it anyway.

In this final pass we would find the first best match among the
fallbacks (typically the first one), but never actually check
the font that was requested in the first place. This was a
mistake. Unless it does not exist, we should just return the
requested font family.

Pick-to: 6.9
Task-number: QTBUG-132377
Change-Id: Ie53a6bd665ebdaaca92bf0c33fabf5195e1aa5fe
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-01-20 13:25:52 +01:00
Assam Boudjelthia
a8d8fb83cc AndroidDeployQt: explitly constuct the qmlDomCommand args list
Construct the arguments list explicilty to QStringList to avoid calling
QProcess::splitCommand() and potentially splitting a path with spaces
that shouldn't, this also saves from having to deal with shell quotes.

Fixes: QTBUG-132891
Pick-to: 6.9 6.8
Change-Id: I48f6c219830269c507f146b654bcfa025f0e3203
Reviewed-by: Olli Vuolteenaho <olli.vuolteenaho@qt.io>
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
Reviewed-by: Soheil Armin <soheil.armin@qt.io>
2025-01-20 10:20:27 +00:00
Eskil Abrahamsen Blomfeldt
2e1db65417 FontConfig: Fix detection of color fonts
There were two mistakes in the code that intended to detect
if a specific font was a color font in the FontConfig database.

1. The "int n" parameter in FcPatternGet*() is not an array size,
but an index, so it should be 0 and not 1.

2. We need to add FC_COLOR to the list of properties in our pattern
when populating the database, otherwise we will just fail to match
it and none of the system fonts will be listed as color.

Pick-to: 6.9
Fixes: QTBUG-132377
Change-Id: Ib3c112e8a354abacd05679c62283a1f1abfb40ee
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-01-20 07:39:32 +01:00
Thiago Macieira
b119fee87d De-duplicate the disabling of crash dialogs in our unit tests
The code was duplicated in multiple places.

Pick-to: 6.5 6.8 6.9
Change-Id: If2ab30b7afbf6d2f99c9fffd999218802b734d5e
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-19 19:24:28 -08:00
Thiago Macieira
bec49144f8 QThreadStorage: remove unused moc-skipping guards
QT_MOC_CPP is not the same as Q_MOC_RUN, which moc's preprocessor still
sets. It appears Qt 3's qmake set it when ALLMOC_HEADER was set... a
feature that doesn't appear in Qt 4 (but exists with cmake_automoc).

MOC_SKIP_{BEGIN,END} appears in Qt 3's moc, but not in Qt 4's. But they
weren't in qthreadstorage.h at the time, so I guess they were added in
the 4.0 development cycle when QThreadStorage changed, but before moc
was rewritten (which deleted the Qt historic repository's oldest file,
moc.l).

Pick-to: 6.9
Change-Id: Ibfff778c9f4d17af006dfffd8545fb24b495ecdd
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-19 23:52:15 -03:00
Thiago Macieira
ec52f8c4f1 QThread/FreeBSD: remove the unnecessary Linux compat layer
It's now in the FreeBSD headers themselves, so we don't need our own.

Change-Id: I136aa8018a2c02f70ab8fffd484f07f287ca0305
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-19 11:49:42 -08:00
Ahmad Samir
6f0f39673f tst_QUniqueHandle: silence GCC/Clang -Wself-move warnings
And remove NOLINT(clang-diagnostic-self-move), silencing the warning for
Clang seems to work for clang-tidy too (tested locally).

Amends 03bd9491491881529ad28cd6d672edfdda9a0065.

Pick-to: 6.9 6.8
Change-Id: Ibdf982a728f2c6150f2911173dc3c9246f3662b8
Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-19 08:26:52 +02:00
Jonas Kvinge
55a4c6e9fc QXRenderGlyphCache: Add QColor parameter for QFontEngineFT::loadGlyphFor
Fixes build after commit 39df9e1858a4115bc19b6a4dee5d687c5ee00d21

Pick-to: 6.8 6.9
Change-Id: Ice151b27591470ae81e07953f50e1abf9244ea28
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-01-19 01:44:58 +01:00
Liang Qi
faea5e128a textinputv3: need to commit() after disable()
https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/master/unstable/text-input/text-input-unstable-v3.xml

disable() - Disable Text Input On A Surface

Explicitly disable text input on the current surface (typically
when there is no focus on any text entry inside the surface).

State set with this request is double-buffered. It will get
applied on the next zwp_text_input_v3.commit request.

Done-by: lilydjwg li
Fixes: QTBUG-132195
Pick-to: 6.9 6.8
Change-Id: Iaae1d306fba235b9fc3eba3f0215ca85375f3a3d
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-01-18 23:39:34 +01:00
Thiago Macieira
bd57467f4e QMetaType: use the heterogeneous lookup feature of QHash when possible
This probably doesn't make a difference because QByteArray::fromRawData
is inline, does not allocate memory, and (as of the last commit)
noexcept. As an beneficial side-effect, we get to test that feature in
QtCore's own build.

Change-Id: Ifd19cfdba83064bbf4d3fffdd032622ec102e234
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-18 12:06:10 -07:00
Ivan Solovev
0d047ca713 QtTypeTraits: fix order of the includes
Amends 08c6cc62c743e172fbf064ccaad1159b2a1fb850.

Found in Qt 6.9 API review.

Pick-to: 6.9
Change-Id: I1ed29a913e34ecf093a98c2053c319f0edfb9135
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-18 20:06:00 +01:00
Thiago Macieira
b5e05e1af7 QCoreApplication: remove the indirection to {app,manual}_libpath
Instead of storing a pointer to a QStringList to indicate whether the
list was populated or not, use the QList's d-pointer. Unlike QString and
QByteArray, QList does not have isNull(), so we roll out our own.

Pick-to: 6.9
Change-Id: I6903de324c8215ed4934fffd9d997a34f2e7fa99
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-18 19:05:48 +00:00
Thiago Macieira
a314e4b985 QCoreApplication: move the QRecursiveMutex into QCoreApplicationData
There's no need for it to be a global, if the data isn't either. I have
a vague recollection of the data also being globals back in the
day... (they used to be plain QStringList pointers).

Pick-to: 6.9
Change-Id: Ie5f1a71d0b20a0195822fffd992101c94824a07f
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2025-01-18 16:05:47 -03:00
Thiago Macieira
9fe44e4779 Move the libraryPath tests from tst_QApplication to tst_QCoreApplication
Those aren't GUI tests. I suppose they've been in tst_QApplication since
Qt 2 or 3, when there was no QCore/GuiApplication yet, and were never
moved.

Pick-to: 6.9
Change-Id: I30b3c1a309ba2c720210fffd045ebd0bcfa803fe
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-18 16:05:46 -03:00
Thiago Macieira
cc4abefb1d QMutex: mark the out-of-line, *Internal() methods Q_NEVER_INLINE
With LTO, I'm seeing GCC conclude that it's best to inline the
lockInternal() and unlockInternal() methods into the public ones and
then emit out-of-line copies for those. That's actually sub-optimal, so
force GCC not to do it.

Pick-to: 6.9 6.8
Change-Id: I88c29098757ea6e70c00fffde56989ec05b136bd
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-01-18 11:05:34 -08:00
Allan Sandfeld Jensen
7ad2083ec3 Fix CMYK8888 on big-endian platforms
Pick-to: 6.8 6.9
Fixes: QTBUG-132875
Change-Id: If7e945607125a5ae5ce1f8323df27ab8481e329c
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2025-01-18 15:22:56 +01:00
Marc Mutz
4771dc3087 Move the <version> include from qcompilerdetection.h to qtconfiginclude.h
The idea of b2ed29b8d9b33dcece83000aee28073dd27f1cd9 was to have the
contents of <version> (if it exists) available in all Qt headers.

Since we broke up qglobal.h into smaller pieces, qcompilerdetection.h
is no longer necessarily included by any given Qt header, which
thwards the original idea.

Try with qtconfiginclude.h, which exists since
61935786c30b0209811fa32f7a02f138da8570b2 (Qt 6.6).

For Qt 6.5, we'll need to add it separately to qtversionchecks.h and
qtconfigmacros.h, whence qtconfiginclude.h was extracted, as well as
keeping it in qcompilerdetection.h, which includes qtconfiginclude.h
only since 22029a76c37d8d670479d523684a84f7966ed434.

Amends the breaking of qglobal.h into smaller headers, without being
attributable to any one of the individual commits that made up the
change, or else amends b2ed29b8d9b33dcece83000aee28073dd27f1cd9.

Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-108228
Change-Id: I909196bd767e8d9e016069f1a59994d40e646e59
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-18 14:34:54 +01:00
Volker Hilsheimer
988a3cd95d Doc: fix linking issue in QHeaderView; reflow
QHeaderView has no resizeMode property, only a ResizeMode enum type that
is then used in the sectionResizeMode API.

Fix that reference, reflow the paragraph, and apply some light editing.

Amends 9e3a96189d9db8a458e65cd5078509afe7a160db

Pick-to: 6.9
Change-Id: I240c3f64fd45c96f4d3ba95c2086a638468e137f
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
2025-01-18 14:34:54 +01:00
Aurélien Brooke
2de013eb6f rhi: remove code duplication in QRhiResourceUpdateBatchPrivate
Change-Id: I22ae50d9fbc2f446e819c9d5f740946808bbdfce
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-01-18 08:47:20 +01:00
Giuseppe D'Angelo
39ab9e0041 Testlib: wrap cycle_p.h header
The header triggers compile warnings -- -Wundef, to begin with.

Since it's included from multiple places, we either fix the header or
wrap it. The header isn't maintained upstream (we actually keep patches
"on the side"), so I'll go with the wrapping option, and suppress
-Wundef in there.

Task-number: QTBUG-132900
Change-Id: I8fdd32fa2ec1cde83ef28945259bce836439f73f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-18 06:49:45 +01:00
Giuseppe D'Angelo
fc4aff1249 QLoggingCategory: fix -Wundef
We want to test if QT_BUILDING_QT is defined, so use the right
construct.

Pick-to: 6.9 6.8
Task-number: QTBUG-132900
Change-Id: Iac26f70021a337a2c476618979b4b8eb180ffd3b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-18 06:49:44 +01:00
Giuseppe D'Angelo
f04dfa8666 QTestLog: use the right preprocessor test for C++ features
Use ifdef, not if, otherwise we trigger -Wundef if the feature
is unsupported.

Pick-to: 6.9 6.8
Task-number: QTBUG-132900
Change-Id: I8a779da59bf2c7add14ace6405faf19b7ca48c28
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-18 06:49:44 +01:00
Qt CI Bot
a3726edbbf Merge integration refs/builds/qtci/dev/1737160502 2025-01-18 05:33:52 +00:00
Assam Boudjelthia
4d5a5d502f Android: remove unused scaled density property
This value is used by nothing throughout the Qt Android code.

Task-number: QTBUG-132716
Change-Id: I694d016131b7eccd9ea5789e77f0501676a7f21a
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-18 07:33:37 +02:00
Assam Boudjelthia
c13e2213a8 Android: remove unused top/left inset params of setDisplayMetrics()
Those two params are already marked as unused, so there's no point in
calculating them passing them and then not using them.

Task-number: QTBUG-132716
Change-Id: I840473a42ac4256164252df805b52b859d2fa3de
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-18 07:33:37 +02:00
Shawn Rutledge
97605760ae QWindowPrivate::maybeSynthesizeContextMenuEvent: preserve spontaneity
Call QCoreApplication::forwardEvent() rather than sendEvent() to ensure
the QContextMenuEvent is spontaneous if the mouse event is.

Pick-to: 6.9
Fixes: QTBUG-132873
Change-Id: I6198c2105210d2841f43ef81a9be0f917272846f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-18 06:15:27 +01:00
Thiago Macieira
029bb47e12 QJson: Remove QT_JSON_READONLY
moc (and thus the bootstrap library) has needed JSON output since Qt
5.15 (commit da284ef10e0ef80776b9fc9b7bb0e6dc8d71ba63 "Add support for
machine-readable JSON output to the MOC").

Pick-to: 6.9
Change-Id: I4b8cf51c092eb35cc383fffd48d120f0cb2c56b0
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Johannes Grunenberg <nerixdev@outlook.de>
2025-01-17 16:45:58 -08:00
Assam Boudjelthia
9875976ed1 Android: remove unused scaled density property
This value is used by nothing throughout the Qt Android code.

Task-number: QTBUG-132716
Change-Id: I694d016131b7eccd9ea5789e77f0501676a7f21a
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-18 02:16:45 +02:00
Assam Boudjelthia
bddccc689b Android: remove unused top/left inset params of setDisplayMetrics()
Those two params are already marked as unused, so there's no point in
calculating them passing them and then not using them.

Task-number: QTBUG-132716
Change-Id: I840473a42ac4256164252df805b52b859d2fa3de
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-18 02:16:40 +02:00
Volker Hilsheimer
9d35561f6f JNI: handle narrowing before creating a new Java string
Emit a warning if the string we get is too large for Java, and cast
the size to jsize before calling JNI.

For consistency, replace the Q_ASSERT in QJniArray's size check to use
the same logic.

Addresses header review comment; code was not handling this case before
it got moved into the inline helper either.

Pick-to: 6.9
Change-Id: I00d68509be8b5f7304dda2e824fa0ced0f8f8d48
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-17 21:54:56 +00:00
Alexey Edelev
a57d5b1fd6 Fix the unsupported Q_UNREACHABLE_RETURN statement in constexpr functions
GCC 8.x does not treat __builtin_unreachable() as constexpr and
disallows using the Q_UNREACHABLE_RETURN macro. Guard the statements
with the respective checks.

Amends b0b34c56a99130bfc9c82cb006653ce6b8f0516e

Pick-to: 6.8 6.9
Task-number: QTBUG-125285
Fixes: QTBUG-132804
Change-Id: I88cdbe3bae1a336edc255e3e93e8d948bde253da
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-17 20:29:19 +01:00
Ivan Solovev
256b56f581 Fix docs for new QDebug streaming operators of std containers
Added the missing function declarations to the #if Q_QDOC part of the
header. Also fixed a typo in the std::unordered_map docs.

Amends 850d4895be565931d18c92e5e2f9a33b7f26de6d,
0c96528e8d43ad4309bdca14b179a5045984655a,
a9fe57fefaac0cb047e4c02e0b8c8f8327e0a58c,
and a8c9a5617c72ad2e55bf497df6ff2c2e141cbdef.

Found in Qt 6.9 API review.

Pick-to: 6.9
Change-Id: I792023b506e2afdbdca4bca3197887e50c98a788
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-17 19:29:18 +00:00
Ivan Solovev
b9a5a7852c Provide docs for std::array QDebug streaming operator
Amends b294927a1270f7d0c5aaf0bbe93b617ac995e149.

Found in Qt 6.9 API review.

Pick-to: 6.9
Change-Id: Iab64d52c506030dd755d61edc376bb47865478ff
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-17 20:29:18 +01:00
Tor Arne Vestbø
23312f2566 Make qtbase and all other modules significant on macOS 15 by default
Unless a module overrides it by setting the environment variable
COIN_CTEST_FORCE_IGNORE_EXIT_CODE.

As this change trickles through submodule updates we'll mark modules
as COIN_CTEST_FORCE_IGNORE_EXIT_CODE if needed.

Change-Id: Ia37d6e4c4dee41a3dd7446fa23ab96593dab9402
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-17 20:29:18 +01:00
Tor Arne Vestbø
dbfc3c9c38 macOS: Ignore stderr in tst_QProcess::terminateInChildProcessModifier
As we produce crash reporting via Swift on macOS 15 now.

Pick-to: 6.8 6.9
Change-Id: Iab4777b29bcaa66eff9d2f1de63072f5744d56df
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-17 20:29:18 +01:00
Volker Hilsheimer
5c783083f5 Fix doc warning
Amends 4d31372a869d6734258eb7c081375581b367759e.

Pick-to: 6.9
Change-Id: I685a0687e8519f92602857a8259260e3b081864d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-17 17:02:52 +01:00
Soheil Armin
68785b3e59 Android: Handle dotted URI QML Modules in Java code gen
A QML module can have URI that include dot character.
In this change, we refactor the code generator to create
the same hierarchies as a Java package structure. Each
QML module URI will be appended to the base application
package name to form a package that represents the QML
module as a Java package. Then the generated code of each
QML component will be placed in a single file.

This change, also refactor how to generated code should
be written in the file, by buffering the generated code
to a QByteArray first, and then flushing it into the
target file. We also create a marker file inside the
directories of each module, so that we can entirely
remove the directory and all its files before generating
new code during the next build.

Fixes: QTBUG-125891
Fixes: QTBUG-125970
Fixes: QTBUG-125971
Pick-to: 6.8 6.9
Change-Id: Iebce6495d9d29af32c3f1f97274c252444d2864e
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-17 16:02:52 +00:00
Soheil Armin
7ed88eb565 Android: Improve qmldir discovery of QML to Java codegen
Recursively find all qml modules, built by this project.
Later, the qmldir of these modules will be used to
generated to code.

The command line argument -i of qmldom tool had
to be replaced with -I. The -i was incorrect as it
expects the qmldir file while -I accepts a QML directory
to be included.

Fixes: QTBUG-125892
Fixes: QTBUG-125970
Pick-to: 6.8 6.9
Change-Id: I4099e488d3d7f4b79566e6ea19eca95f57f7c2fd
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-17 18:02:52 +02:00
Ivan Solovev
9a1a828ae5 QCommandLineParser: convert MessageType to enum class
Amends bad618606d64e943e3fa78e7d1dbc8e1fab55480.

Found in Qt 6.9 API review.

Pick-to: 6.9
Change-Id: I424fc1f80e36343f1aef4b05c551579ec0f04eba
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-17 17:02:52 +01:00
Jaishree Vyas
40f7454c91 Doc: Add setModel(open) option to the documentation
Changed the Model Dialogs section adding open() function.

Task-number: QTBUG-127777
Pick-to: 6.8 6.9
Change-Id: If5086f4e2226c4d032fe1bcfbf2ef550803973c8
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-17 17:02:52 +01:00
Edward Welbourne
f8128f2809 QLocale::uiLanguages(): only QString-ify the locale names we do add
We can test whether the candidate is already in the list by exploiting
the comparison of QLatin1StringView with QString (and related
QStringList::compare() overload), so we don't need to convert the
QByteArray to QString unless we're actually going to add it.

(This does lead to the prior name being converted twice, but the
second of these is about to go away.)

Change-Id: I8e47cbb4c9e44ad8ef13d04e930a4619845418ef
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-17 17:02:51 +01:00
Christian Ehrlicher
952ec8db3a SQLite: Update SQLite to v3.48.0
[ChangeLog][Third-Party Code] Updated SQLite to v3.48.0

Pick-to: 5.15 6.5 6.8 6.9
Fixes: QTBUG-132862
Change-Id: If22497590dededc7b0c6f5dcc8d6d909f1e032a2
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2025-01-17 13:05:45 +01:00
Frédéric Lefebvre
ec6ed20c66 Remove manual test Delegate as irrelevant
Tests QLineEdit and QComboBox in a QStyledItemDelegate. Seems more like
a bug reproducer.

Remove delegate manual test as irrelevant.

Change-Id: I17ae04716641aa4ad0ca932db640be71636ddf31
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-01-17 08:49:05 +00:00
Thiago Macieira
4daed28772 QCoreApplicationPrivate: move translation NSDM to improve packing
This way they aren't in the middle of a block of booleans.

Pick-to: 6.9
Change-Id: Iba067f6f23db7c059cddfffdc27231dd09b6898e
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-01-16 16:05:20 -08:00
Thiago Macieira
ede95ef7e9 QCoreApplicationPrivate: make the type member 8 bits
So it packs better with the booleans around it.

Pick-to: 6.9
Change-Id: I330164b99fcbbf9e9629fffd52bcbb38bec4ac0e
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-01-16 16:05:20 -08:00
Thiago Macieira
61924c622a QMessagePattern: merge and improve %{time}-printing code
All modern compilers implement divisions and modulus via multiplications
and shift, so the codegen is practically the same (three multiplications
in total). But the new code allows more than 136 years of uptime (49710
days).

Drive-by fix indentation in nearby line.

Pick-to: 6.9
Change-Id: Iea806bd7dfac1f852c66fffd41c2ac6660e7cc65
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-16 16:05:19 -08:00
Thiago Macieira
9dc294143d QMessagePattern: replace Q{Elapsed,Deadline}Timer with std::chrono
There's nothing wrong with those two, but we don't need the middle men
to the monotonic clock. This also reduces the sizeof QMessagePattern by
one quint64 (QElapsedTimer is 16 bytes in Qt 6).

Pick-to: 6.9
Change-Id: I0eb171f03ee8f3a7148bfffd5534a7f3daba3a01
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-16 16:05:19 -08:00
Thiago Macieira
b86bcf5c25 QMessagePattern: add Q_ASSERT to setDefaultPattern() and improve codegen
Amends commit e04f109456bbcb184963b8ed71944b958b35c201.

This function does not free the pointers stored in literals, so add a
couple of assertions to indicate that it's only safe to call from the
constructor. And that being the case, we can update the tokens
unique_ptr in two steps, which makes the compiler not attempt to call
delete[] on the previous pointer.

Pick-to: 6.9
Change-Id: Ibe76a7df795e9c6d6191fffdf45e3b3ef6f0f344
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-16 16:05:19 -08:00
Thiago Macieira
c9ca74660b Bootstrap: disable the entire convert/view QMetaType code
Nothing is using it and this greatly simplifies the code, both for the
bootstrap build and for the maintenance of QtCore.

Change-Id: I5c48d16ccdd468834a80fffdf6ec94d06ae655dd
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-16 16:05:19 -08:00
Thiago Macieira
c1026f2ff0 Bootstrap: remove the ability to register custom QMetaTypes
Nothing was registering them, but moc does query types by name and that
searched the always-empty custom type database. This commit simplifies
the code a bit.

Change-Id: I7aac990cf04c9c514441fffdbb9faca471c92ffe
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-01-16 16:05:19 -08:00
Petri Virkkunen
74bdd85209 QQ4A: All Loaders extract metadata and applicationArguments
Just like regular Q4A apps and Android service apps, we should also
extract and set the common environment variables and app parameters for
QQ4A apps, so call extractContextMetadata() from the QtEmbeddedLoader
ctor.

In order for QtTest library to know where to output test results,
androidtestrunner passes it some parameters via "applicationArguments"
when launching the application. These params should be passed from the
launch intent to the main application, so now the base QtLoader class
parses this info in extractContextMetadata(), so that it's not just
parsed by QtActivityLoader.

Change-Id: If0444847676d197689b087c5f6684552f8ea73aa
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-16 22:41:25 +02:00
Petri Virkkunen
dad9ce46f0 Quick for Android: Call quitQt() after main() exits
In Quick for Android case, if Qt exits itself (Qt.exit() in QML, etc),
we get deadlock in startQtApplication after the user-provided main()
exits.

This is due to terminateQt waiting for a semaphore that - in a normal
Q4A context - is called when the hosting Activity itself is destroyed
from another thread via an activity status callback.

Task-number: QTBUG-130342
Change-Id: I9cd701e0ea86a445e13a6568c4954de6e356e98a
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-16 22:41:20 +02:00
Tinja Paavoseppä
3bcf55daa5 Android: Quit hosting Context only when app is entirely Qt
When quitting Qt, only quit the hosting Activity or Service if it's
primarily a Qt app, i.e. Qt is in the driver's seat. When using QtQuick
for Android, i.e. Qt is just a View, we do not want to forcefully quit
Activities, that is up to the app code.

Task-number: QTBUG-123711
Pick-to: 6.8 6.9
Change-Id: Ib98700be8693c3d30a296998b863b0f224c9bf69
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-16 22:41:16 +02:00
Tinja Paavoseppä
be33f2d323 Android: Do not start Qt app if it has already been started
Call startQtApplication() in QtView even if the Qt libs
have already been loaded, to make sure the app gets started
also when the Activity is recreated. Check whether Qt app
is already running inside the method itself to avoid hanging up
because of trying to start it twice.

Task-number: QTBUG-123711
Pick-to: 6.8 6.9
Change-Id: I3b009e4c2f40af9f258ce32b7e181c3faa21c194
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-16 22:41:13 +02:00
Tinja Paavoseppä
7c7b63f3e8 Android: Create new QtThread when needed
When we quit Qt in an Android app, we also quit the Java thread created
to act as the Qt main thread. This works well for normal Qt for Android
apps, where the lifetime of the Qt part and the whole Android app is
essentially the same. However, in QtQuick for Android Qt can be just
a part of the entire app, and the lifecycles are not directly tied.
Hence, we might want to quit Qt when the part of the app that has it
is not active, and restart it when the Qt part of the app comes
active again, and for this we need to create a new QtThread.

Set the QtThread variable to null when it has been terminated,
and if it's required again, create a new instance.

Task-number: QTBUG-130610
Pick-to: 6.8 6.9
Change-Id: I430e195fd319a20c9627ed98d6f30858cebc49c4
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-16 22:41:10 +02:00
Tinja Paavoseppä
9f8e49360c Android: Separate JNI initialization from JNI_OnLoad
Currently, we create references to Java classes and objects
in JNI_OnLoad. However, that is done only once, when the
Android QPA plugin is loaded, and in case we would like to stop
Qt entirely and then start it again, we want
to reinitialize all these things. Move these initializations to
a separate method, and call it before starting the Qt runtime and
app.

Remove the synchronization block guarder by m_mainActivityMutex
in QtNative.startApplication(), as it calls startQtAndroidPlugin()
which now will call activity() if the JNI needs to be
reinitialized, leading to a deadlock as that method is guarded
with the same object.

Task-number: QTBUG-130610
Pick-to: 6.8 6.9
Change-Id: I826dfb9b032a6c615f2408d484d1f4f0ea528d02
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-16 22:41:06 +02:00
Ulf Hermann
4f05eac0a8 Core: Remove duplicate QtPrivate namespace
The logging category macro already puts the logging category into the
QtPrivate namespace. There is no need to wrap it into another QtPrivate
namespace.

Pick-to: 6.9
Fixes: QTBUG-132111
Change-Id: I99a7aa16662e3515c5f96d6736d47c1d0e45034c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-16 20:41:32 +01:00
HIDAKA Takahiro
38aa7f5fe7 iOS: Add QPointingDevice for Apple Pencil
For Apple Pencil 1st generation, it supports xTilt and yTilt
capabilities.

Task-number: QTBUG-128466
Change-Id: I572a303a4d213417004cacadbc7cef9c96334720
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-16 18:44:40 +00:00
Bartlomiej Moskal
0a017308cc Android: Unblacklist textMargin test from tst_QLineEdit
Older devices may have lower screen resolution. In this case, the
hardcoded width may not work as expected. For example, all text may
not fit in QLineEdit.
This was the reason why the tst_qlineedit::textMargin test failed on
some Android devices (especially x86 emulator with Android API 29).
When the left and right margins were set to 20, all tested text did
not fit in QLineEdit. When we clicked at the beginning of QLineEdit,
we clicked on the second character of the text. The cursor was moved
to position 1, which caused the test to fail.

This commit updates textMargin test to make sure that tested text will
fit in to the QLineEdit.

Task-number: QTBUG-87417
Fixes: QTQAINFRA-6897
Pick-to: 6.9 6.8
Change-Id: I35352ac1e6f975e72d5c9638f8520f8ddd1d56ae
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
2025-01-16 16:37:57 +00:00
Volker Hilsheimer
4d31372a86 API review: add revision and docs for QWindow::safeAreaMarginsChanged
Pick-to: 6.9
Change-Id: Ie43915510449880bc5a054b9cea7fdd8f48db9b9
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-16 16:30:14 +01:00
Ivan Solovev
453d8797f7 QChronoTimer: add test for interval (u)int overflow
Now when we ported all dispatchers to QAbstractEventDispatcherV2
interface, we can reliably verify that we support timers with > 24 days
intervals. Also add a 50 days test to check for uint overflows.

Adding larger intervals requires test adjustments, because for coarse
timers the actual interval may be up to 5% larger then specified.

Amends 0d0b346322f6b078e6fe60cd3612e8d08a0d5f00.

Task-number: QTBUG-132388
Change-Id: I152cb305c8460801f16bba0c5cd6758c366bce84
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-16 16:30:14 +01:00
Liang Qi
def4f827da widget: clear WA_OutsideWSRange when needed in QWidgetPrivate::create()
which follows the behavior in QWidgetPrivate::setGeometry_sys().

Pick-to: 6.9 6.8
Fixes: QTBUG-129698
Change-Id: Ia85e9470111eea9e3392cdf38c3da2db232ef065
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-16 15:53:55 +01:00
Soheil Armin
190c85b706 Android: Fix incorrect JNI call from QAndroidItemModelProxy::sibling()
The return type of the QtAbstractItemModel.sibling() method is
a QtModelIndex Java type.
The JNI call from QAndroidItemModelProxy::sibling() is using
<jobject> as return type of QJniObject::callMethod(). This will
result in a non-matching JVM function signature.

This change replaces jobject with JQtModelIndex as the QtJniType.

Pick-to: 6.8 6.9
Fixes: QTBUG-132841
Change-Id: If157858f1ed49e25c8fbdfb9bb5c1fc2b7052826
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-16 15:54:26 +02:00
Eskil Abrahamsen Blomfeldt
0107e05e50 FontConfig: Don't register hardcoded fonts as color fonts
This amends 16850709306589a2433c0038605d365a6b6bedad. The patch
aimed to pass false for the color font parameter, but got it in
the wrong position, so it passed false for the pixel size instead.

The registerFont() function is a real mess, and it should be cleaned
up, but this at least fixes the immediate bug.

Pick-to: 6.9
Task-number: QTBUG-132821
Change-Id: Id54989960aa5f86d3c79423d004530bb6a4fa475
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-01-16 14:54:26 +01:00
Bartlomiej Moskal
43f2fdc25c Android: Unblacklist tst_QLineEdit selection tests
Using the left/right keyboard key will deselect the text but also
move the cursor. In this case, to be consistent with the test, the
cursor must return to the previous position. This allows to
unblacklist tests:
  - undo_keypressevents
  - leftKeyOnSelectedText

Task-number: QTBUG-87417
Fixes: QTQAINFRA-6890
Fixes: QTQAINFRA-6895
Pick-to: 6.9 6.8
Change-Id: I8a6d7cca332fe365ca820a67c23d9cd3fc36fc43
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-16 13:54:26 +00:00
Eskil Abrahamsen Blomfeldt
41199de2d8 Add logging output to emoji segmenter
Change-Id: I33291128d27131ea77e8199862faf1dbcd5bf68f
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-01-16 14:54:26 +01:00
Eskil Abrahamsen Blomfeldt
81e596c24f Freetype on Windows: Detect system color fonts
For populating the freetype font database on Windows, we're using
GDI, which does not support color fonts. Therefore we were
registering all system fonts as monochrome, which was okay, because
our Freetype backend did not actually support the color font format
used on Windows.

Since 29a1c57183958b3951db4e7ba9504918a3caa761 we now support COLR
fonts, so they should be added with the correct properties.

Since GDI does not provide this information, we create a temporary
freetype face from the font file when resolving the family during
matching.

Pick-to: 6.9
Fixes: QTBUG-132255
Change-Id: Ib62632de7fe8d9dc533abe4ae2368090a382cca7
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-01-16 14:25:59 +01:00
Eskil Abrahamsen Blomfeldt
d2c8c12183 Add some additional debug output to font matching
The font matching process consists of multiple passes, so to help
us keep them apart, this adds some informative output to explain
where we are in the process.

Pick-to: 6.9
Change-Id: I54f0712cc8600d2b1e1bf4b8688e2ae198e0453b
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-01-16 14:25:59 +01:00
Alexei Cazacov
0ec4447d7a Docs: Describe QTextFormat::TextUnderlineStyle property
This commit describes the QTextFormat::TextUnderlineStyle,
TextVerticalAlignment, and TextOutline properties and their allowed
values

Task-number: QTBUG-126954
Pick-to: 6.9 6.8
Change-Id: Ib961331d9a06edb2bedf0a6b93afebef0cd467cb
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2025-01-16 14:21:07 +02:00
Marc Mutz
441a96ba16 QSet: remove misleading bool comparison with 0
Q6Hash::remove() returns a bool, not an integer, like Q5Hash::remove() did.

Pick-to: 6.9 6.8 6.5
Change-Id: Ia2907c7a2a4177f9b5ad05ca1ef3b9a5baa8137a
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-01-16 09:01:41 +01:00
Thiago Macieira
438c8e503d qfloat16: simplify the legacy EXTERN_TAGGED content and mark for removal
Amends 21950e3085bd45dbd4b55fb76e3d47319cbb11d7.

This functionality was an ill-advised attempt at reducing compilation
times that added more legacy we have to keep until 7.0, instead of
properly fixing QMetaTypes.

qfloat16 is a built-in type whose name in the macro and the one obtained
from C++ match ("qfloat16"), and has no legacy operations to be
registered. This function only needs to return the ID.

Change-Id: I2a8300dd44bcfc1a2479fffd2f76964206b9e58a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-15 19:46:18 -08:00
Thiago Macieira
981c2e8b74 QCoreApplicationPrivate: use std::unique_ptr for origArgv
Pick-to: 6.9
Change-Id: Id03feb55d3c3899aa4fffffdc0b3ee7b0742f9e8
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-15 19:10:31 -08:00
Thiago Macieira
f68df05a77 QCoreApplicationPrivate: use NSDMI to initialize the members
This removes the need for #if in the initialization list and the ugly
whitespace-before-punctuation syntax.

Pick-to: 6.9
Change-Id: Id33ec83e574360f65c9bfffd22b8cb450156477b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-01-15 19:10:31 -08:00
Thiago Macieira
bf8a5ab418 Bootstrap: remove qcoreapplication_{mac,win}.cpp & QStandardPaths
We don't need to discover the application's name or file path. This also
removes the only use of QStandardPaths::findExecutable(), so we can
remove the entire class too.

Change-Id: Id297dc9b56ada635cfc9fffd679ead9378fffb03
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-15 19:10:30 -08:00
Wladimir Leuschner
3f42d2baac QWindows11Style: Make disabled menu item non-selectable
QWindows11Style inherits the stylehint policy for
SH_Menu_AllowActiveAndDisabled from QWindowsVistaStyle, although the
inactive selection is not visible. This patch makes disabled menu items
non-selectable.

Pick-to: 6.9 6.8
Change-Id: Ib59988cfad444f9f8203628d4b3e1f72d6775b46
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-16 02:17:29 +01:00
Ahmad Samir
9a1260e3f9 Remove unused qdebug.h include from private headers
Pick-to: 6.9
Change-Id: I03c951d03ab2410298878d0689c0d50bdd4eedf2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-01-16 02:07:44 +02:00
Ahmad Samir
22ab256e37 Replace qdebug.h include with forward-declarations in private headers
Only one header so far.

Amends 731538fdd469452e721b568fcbd808b437332008.

Pick-to: 6.9 6.8 6.5
Change-Id: I7449b4f91d8b44f4efab71d4d0fe259022d847a4
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-16 00:07:44 +00:00
Eskil Abrahamsen Blomfeldt
9e5887a5d4 Support COLRv1 fonts in Freetype backend
COLRv1 fonts are not automatically rendered by Freetype, but
is currently gaining traction and the default emoji font on
Android 15 is in this format.

What we get from Freetype is a scene graph that we can render
ourselves. This patch implements a recursive renderer for the
graph.

One current limitations is that conical gradients are not fully
compliant with the spec. I have so far not been able to find
any fonts where conical gradients are used, so this is left
as a semi-supported feature for now. It's certainly not
needed for the Android emoji font.

Pick-to: 6.8 6.9
Fixes: QTBUG-130909
Fixes: QTBUG-131116
Change-Id: I2484743602ad16f01318ecd6de2b245b38a8f566
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-01-15 23:48:54 +01:00
Assam Boudjelthia
9920c33500 Android: de-duplicate display size calculation code
Same logic for calculating the display's size is done in few places
while being simple duplication, this de-duplicate it.

Task-number: QTBUG-132716
Change-Id: I9e65a271fdce1769316f4e05012faf7f194b81b1
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-15 21:29:08 +02:00
Assam Boudjelthia
95c21244cc Android: move getRotation() directly under handleOrientationChange()
This call is done only from handleOrientationChange().

Task-number: QTBUG-132716
Change-Id: Ib483a8d37c61514bc1a3cf1ca107518ffaaeb572
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-15 21:29:03 +02:00
Assam Boudjelthia
0abdca8790 Android: use one common getDisplay() method
Use one method getDisplay() which handles different API levels and call
it from various code paths instead of doing the same over and over.

Task-number: QTBUG-132716
Change-Id: I0b246631b7dd45789f01e6fa6360d8c76c13fee9
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-15 21:28:58 +02:00
Assam Boudjelthia
495f7cceb2 Android: cleanup refresh rate handling between java and c++
Keep refresh rate calculation and handling in one place and one method
that various delegates call with a context. Also, don't try to update
the refresh rate each time with setDisplayMetrics() beacuse refresh rate
updates are done under the display listener's onDisplayChanged().

Task-number: QTBUG-132716
Change-Id: I689c7a1c350695c27efc6d1bcc9c159855736e43
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-15 21:28:54 +02:00
Assam Boudjelthia
2d2b9fea7d Android: simplify orientation change handling
Currently we rely on both onConfigurationChanged() and onSizeChanged()
in QtRootLayout to report orientation changes, because the former might
be invoked when the new size is not updated yet, so we're doing many
calculations to ensure we don't end up missing or calling change handler
more than we should.

However, instead of all that, we could simply post
the handler under onConfigurationChanged() which would end up eventually
invoked after onSizeChanged() has been called already.

Task-number: QTBUG-132718
Change-Id: I9fbc826518b81a9e4417eba6cd3cf999637201b9
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-15 21:28:49 +02:00
Assam Boudjelthia
9ba94b1e62 Android: don't touch system bars colors in fullscreen
In fullscreen mode, don't try to touch the system bars
colors neither making them transparent or restoring the
default colors as it's irrelevant as the bars are not
visible.

Task-number: QTBUG-132720
Change-Id: I3b3cc604d8b1241b50555fd964a51e7836c9034c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-15 21:28:45 +02:00
Assam Boudjelthia
7344d21c73 Android: don't call requestLayout() under setSystemUiVisibility()
That call already handles Ui visibility changes so no need
to do the call to requestLayout() manually.

Task-number: QTBUG-132720
Change-Id: I2f0828afa2036dfc72eccd76fe1cbbdbe30322cd
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-15 21:28:41 +02:00
Assam Boudjelthia
2c40e9b91c Android: don't run setSystemUiVisibility with same params
Cache fullscreen and expandedToCutout values and run
setSystemUiVisibility() only when changes has been
made.

Task-number: QTBUG-132720
Change-Id: I51559e485653d4091e79391962bc82042714f7be
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2025-01-15 21:28:36 +02:00
Ivan Solovev
0fb3661f13 QEventDispatcherWin32: consistently use ms precision in calculations
Windows does not support nanosecond-resolution timers, so we ceil
nanosecond interval to milliseconds in registerTimers().
Later on, we also use millisecond-resolution to calculate the expected
timeout.
However, the remainingTime() method was using nanosecond resolution when
doing the calculations. As a result, we could never get remainingTime()
equal to the specified interval.

This patch uses the same ceil-to-milliseconds logic in remainingTime()
to make all time calculations consistent.

It's not really possible to provide a reliable unit-test for this case,
because we can only check that the remaining time does not exceed the
specified interval.

Amends 0d0b346322f6b078e6fe60cd3612e8d08a0d5f00.

Task-number: QTBUG-129170
Task-number: QTBUG-132388
Change-Id: I48eaa15d55174e1925fc5eb3ca76b78d85e46f42
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-15 17:03:59 +01:00
Christian Ehrlicher
f4b64f9c12 WindowsTheme: Draw icon overlay manually instead of relying on the api
Fix drawing the link overlay icon - we must not set the device pixel
ratio here as we don't know the exact value.
Also fix some styling issues introduced with the previous commit.

This amends fd7bc16e9fbdc63bd22ba90d0c20b36ccffd2bae.

Pick-to: 6.9 6.8
Task-number: QTBUG-131843
Change-Id: I382527d17e8187bfae7cf40f352e6f87965671a1
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-15 14:07:49 +01:00
Ahmad Samir
185cba6e95 Replace qdebug.h includes in public headers with forward-declarations
qdebug.h includes many Qt and STL headers, so if you include a Qt header
you get all those transitive includes, which may affect build time.

- Where appropriate use the printf-like syntax of qDebug() and co.,
  these don't need the QDebug streaming operators
- qfloat16 is used in an inline member function, so include it
  explicitly

[ChangeLog][Potentially Source Incompatible Changes] Various Qt public
headers don't include QDebug any more; if you need QDebug's streaming
you'll have to include it in your code.

Task-number: QTBUG-132439
Pick-to: 6.9
Change-Id: I750587e17a3b38fa226cd3af8eaccc8da580f436
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-15 13:28:16 +02:00
Michał Łoś
a10acaca08 Skip QResourceEngine cleanupTestCase on VxWorks
COIN is using patched std::optional header for VxWorks, which is based
on 23.09 version of this system, and fixes few compilation and runtime
issues, unfortunately it introduced runtime error as well. This error
causes std::optional to not destroy contained object in destructor,
which is a source of fail in tst_QResourceEngine::cleanupTestCase().
This fail was quieted down using QEXPECT_FAIL for VxWorks, due to exact
reason being unknown at the time.

It was found out that unpatched version of std::optional header in
VxWorks 24.03 fixes most of issues found in 23.09, so there is no need
to use old header. Additionally it cleans contained object in destructor
properly, so this is the one that should be used. In order to use it,
COIN will need to refresh VxWorks images, but this in turn will fail
this test with XFAIL.

Replace QEXPECT_FAIL with QSKIP in tst_QResourceEngine::cleanupTestCase
for VxWorks, update comment accordngly.

Once unpatched optional version from VxWorks 24.03 will be used on COIN,
skip will be removed entirely.

Task-number: QTBUG-130069
Pick-to: 6.9
Change-Id: Ib446d04b2fabb027dad7af909ac00b7b30e76b53
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-15 08:45:17 +01:00
Assam Boudjelthia
a5f80b4732 Android: use the correct ABI folder to load uncompressed libs
It's possible that the first ABI from Build.SUPPORTED_ABIS would return
an ABI that's not packaged in the APK, for example if an armeabi-v7a APK
is run under the device supporting arm64-v8a, in that case the returned
path would be that of an arm64-v8a while it's not actually packaged
inside the APK.

Fixes: QTBUG-132155
Pick-to: 6.9
Change-Id: I0f311accee246fa2d1d0b8aaf424d034b4b2d04c
Reviewed-by: André Klitzing <aklitzing@gmail.com>
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2025-01-15 02:10:58 +02:00
Eirik Aavitsland
fd6f593c7f Update bundled libpng to version 1.6.45
[ChangeLog][Third-Party Code] libpng was updated to version 1.6.45

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I8e3f7c889608e8071888239ed0b6003911d1a39f
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-01-14 23:56:12 +01:00
Vlad Zahorodnii
4c34634808 tst_QAccessibility: Use QKeySequence::toString() properly
The test gets a string representation of a key sequence by stitching
the individual parts manually. It is not a portable approach and the
test relies on undocumented behavior of QKeySequence::toString().

A more reliable and portable approach is to pass the Qt::Key value to
QKeySequence and let it do its magic.

Change-Id: I2a0e8734c93fa4f86f11324f26d8967d22e14247
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-14 20:48:57 +02:00
Edward Welbourne
12f8ebf5cb Add tests that zh-TW now correctly prefers zh-TW over zh translation
The bug, QTBUG-121418, was actually fixed earlier by commit
84afaafc9c6968dd76fcadc5392065d340543521 (or, for 6.8, commit
8c40e8cf12bb931149367677c56816864265249c), but escaped our attention
at the time.

Fixes: QTBUG-121418
Pick-to: 6.9 6.8
Change-Id: Ie24eb172674189079aede7a39584ea760aac1b0c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-14 19:36:37 +01:00
Frédéric Lefebvre
d19d2d261e Remove tst_inputMethodHints manual test as broken
Tests input method hints, but currently does not work and does not
check these properly.

Remove as broken/irrelevant

Change-Id: Iad1bc2a14d2e69b13b7f882b1191d3b810c26c43
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-01-14 15:56:04 +01:00
Ahmad Samir
16fc1e0778 Every private header should include at least another private header
To get qversiontagging_p.h included. See:
https://codereview.qt-project.org/c/qt/qtbase/+/494388/comment/fed896c4_9e7cae6e/

Pick-to: 6.9 6.8 6.5
Change-Id: Ifcc7f9cb0ed57f1af9d3283309498546a81fbb17
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-14 16:52:46 +02:00
Giuseppe D'Angelo
ade3bb1c52 QShortcut: fix build under QT_NO_CONTEXTLESS_CONNECT
QShortcut has a constructor that takes a _parent_ object and a
function to invoke, and it will internally connect its activated()
signal to that function. This connection will not provide a
context object (the parent is not used to this purpose).

Given it's not clear what the context should be if any (the parent?
`this`?), I'm not at ease at just supplying "something" as the context.
Instead, hide the constructor if we're under QT_NO_CONTEXTLESS_CONNECT.
There's another constructor where the caller can supply a context.

Change-Id: I21befcc86eeb07e65eadee1222757ecc5bab1d2c
Pick-to: 6.9 6.8
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-14 15:37:42 +01:00
Eskil Abrahamsen Blomfeldt
39df9e1858 Implement COLRv0 support in Freetype engine
COLRv0 fonts are both scalable and in color, which was not
previously handled in the Freetype backend because it only
supported color fonts with embedded bitmaps. This patch
simply correctly detects the scalable color fonts and
render them through the same mechanism as other color
fonts.

[ChangeLog][Freetype] Added support for COLRv0 format color
fonts.

Pick-to: 6.8 6.9
Task-number: QTBUG-131116
Change-Id: I290e7525c24b4cf2ec872a366e5193f54712a3a4
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-01-14 15:16:47 +01:00
Nicolas Fella
dff8816c76 QWaylandTablet: Use floating point tilt
Change-Id: Ib8476fd74ade7c50cf36909fd9148c78f21c83b1
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-01-14 13:46:28 +01:00
Piotr Wiercinski
213a2610d8 wasm tests: Add option to run Chrome in headless mode
Running Chrome in headless mode helps to circumvent
a lot of issues with GPU driver/Wayland interactions
that we encounter in CI.
Run Chrome in headless mode if corresponding environment
variable is set.

Pick-to: 6.9
Change-Id: I1cf290f484054766e2b99d99045e7b39d5662210
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
2025-01-14 10:32:14 +01:00
Ahmad Samir
c0fcb2db24 network/*/removed_api.cpp: include qdebug.h explicitly
Since the removed API uses QDebug. Requested in code review.

This is needed for a subsequent commit (removing qdebug.h from public
headers when possible), but I split out to its own commit to ease
backporting.

Pick-to: 6.9 6.8
Change-Id: I76980634b9ebbae7cf010d99f5095aa94a825824
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-14 11:02:04 +02:00
Giuseppe D'Angelo
eb533c81b8 QStringConverterBase: make it move-only
The class declares a protected destructor, which interferes with the
RO5. The only subclass in qtbase is move-only; QTextCodec (in
Core5Compat) is not even movable.
Make QStringConverterBase move-only as well.

Pick-to: 6.9 6.8
Change-Id: I20d16df79f7ad8e7e7a8af339954cfa2d1482e96
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-01-14 08:59:15 +00:00
Volker Hilsheimer
20a401cd9f QTestLib: handle all Qt::Key values in keyToAscii
Since the function is implemented to return 0 for many non-alpha-numeric
keys already, make that the default implementation and remove the
Q_ASSERT(false). Instead, emit a warning.

Amends 1a820560000c7669812de9e2283a539118b24e51, after which the
QQuickShortCut test in Qt Quick trips the assert.

Change-Id: I6c6ac0a80043c1bbb7683bc47c1092a12b9cf230
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Reviewed-by: Jules Bertholet <julesbertholet@quoi.xyz>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2025-01-14 00:39:48 +01:00
Mate Barany
95abc38ba6 Update qtimezonelocale_data_p.h with correct CLDR v46 data
The data for the CLDR update was generated from an incorrect xnr.xml
that has contained an extra &lt; and hence the generated
qtimezonelocale_data_p.h is also incorrect.

Update qtimezonelocale_data_p.h with the correct CLDR v46 data.

Task-number: QTBUG-130877
Pick-to: 6.9
Change-Id: Ibc87e137b1519be470704ed519c0988333625af5
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-01-14 00:39:48 +01:00
Giuseppe D'Angelo
f6e99f347d QListSpecialMethods: honor RO5
This looks like another case of a base class with a protected, defaulted
destructor, which interferes with RO5. Explicitly redeclare the other
special member functions in order to suppress the warnings coming from
the deprecated copies.

Pick-to: 6.9 6.8
Change-Id: Icf8c8817ef001d0503683d071c4f004db64caa2d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-13 23:08:09 +00:00
Giuseppe D'Angelo
74b875641f function_ref_base: honor the RO5
I'm not entirely sure why function_ref_base declares its destructor. I
guess it's declared in order to make it protected, because the class is
non-polymorphic and inherited by function_ref, and one may want to avoid
slicing. On the other hand, function_ref_base is an implementation
detail, living in a `detail` namespace; so that sounds very unlikely.

In any case, the class is clearly meant to be copiable, so add back
(as protected) the missing special members.

Pick-to: 6.9 6.8 6.5
Change-Id: Ibf909e1746e65eecf8b8990839a6e4c9eb56ca13
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-13 23:08:09 +00:00
Christian Ehrlicher
a930fb758d Windows11Style: adjust size of flat buttons
Flat buttons were larger than normal buttons - therefore also add
marginsRemove(QMargins(2,2,2,2) for the flat case too.

Pick-to: 6.9 6.8
Task-number: QTBUG-132433
Change-Id: Id010d45bf85c5d7d09ff8db8bda44b1be7d85297
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2025-01-13 23:49:46 +01:00
Marc Mutz
8e75e1c185 q(v)snprintf: fix a typo in the deprecation warning
Found in API review.

Amends afd0bb28fbac6d4c24c6785bff9c72bd56eaceb4.

Pick-to: 6.9
Change-Id: I694dfc3f16ea90bca07a47c1d57ba1cf21b23f1a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-13 22:49:46 +00:00
Ahmad Samir
8a2cb53b37 Remove unused qdebug.h includes
Pick-to: 6.9
Change-Id: I09ad5987bde71ca37c7869c4dd63fb4f41c707ea
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-13 22:22:12 +02:00
Ahmad Samir
158f2c95c8 Include climits explicitly instead of relying on transitive includes
Pick-to: 6.9 6.8 6.5
Change-Id: Ib55b337aa6e0a93c7ac7ee9bf492784cc81808d7
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-13 20:22:11 +00:00
Thiago Macieira
3bc8ebc12f QString: put quotes around the test string in arg() qWarning
So it's less ambiguous in case there's a comma in either the pattern
string or the replacement one. It will still be ambiguous for strings
with quotes themselves, but escaping requires content not present in the
bootstrap library.

Drive-by test that unsigned and floating point also complain.

Pick-to: 6.9
Change-Id: Ia8ca184a7d54b240d653fffd631dbcb7f9e1c97d
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-01-13 16:14:03 -03:00
Thiago Macieira
ff484b3111 tst_QApplication: test quit() not ::exit() from an event loop
Amends Qt 4.8 commit 8dd8db250d92521fda619bdcf3e1c859b37b2da0.

The report in QTBUG-12673 says "quit()" and the backtrace clearly shows
the issue was attempting to cleanly exit the event loop while a modal
dialog was showing. The test instead tested ::exit().

That was actually an important test because nothing else in the Qt test
suite was testing this, but now it's included in the exitFromEventLoop()
test for QCoreApplication, QGuiApplication, and QApplication.

Task-number: QTBUG-12673
Change-Id: Ie7bd19af7103f3066b10fffda299d1168c8f677e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-01-13 16:14:03 -03:00
Piotr Wierciński
010ed17884 wasm: Add helper for pluging preloads
Dynamic linking on WebAssembly involves preloading .so libraries
during startup of application. Normally, those plugin preload
lists are generating manually by user, which can be tedious.
Add a bash script which demonstrates how to call python
programs to generate preload lists.

Pick-to: 6.9
Change-Id: I0a9869ad0d26606f8b33af2c38248cec3088dd0d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-13 18:23:10 +00:00
Ivan Solovev
8472004a89 Use [[noreturn]] on QCommandLineParser::showMessageAndExit()
... instead of Q_NORETURN, as the attribute should be unconditionally
available since C++11.

Amends bad618606d64e943e3fa78e7d1dbc8e1fab55480.

Found in Qt 6.9 API review.

Pick-to: 6.9
Change-Id: Ia008acf0777867f551c7e1cc3423f29f8ed6fbed
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-13 19:23:10 +01:00
Tor Arne Vestbø
8de8800670 tst_Q*Application::runHelperTest(): Run test without activating app on macOS
As that will steal focus from tst_QApplication, which is needed for
subsequent tests.

Pick-to: 6.8 6.9
Change-Id: I5720c4a2bb45f98894616e01da10b9c40a2b6735
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-13 19:23:10 +01:00
Tor Arne Vestbø
f411ac4752 tst_Q*Application::runHelperTest(): Disable CFLog spam on macOS
Otherwise the "+[IMKClient subclass]: chose IMKClient_Legacy" log
spam will break the test.

Pick-to: 6.8 6.9
Change-Id: Iccfb46204394bbc1b084de4b1e7b2f1ea6b4f05b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-13 19:23:10 +01:00
Edward Welbourne
2578d72a7c Remove constexpr from a function that doesn't need it, and asserts
The call to q_assert() isn't constexpr, so can't happen in a constexpr
function. Most compilers shrug this off as they can see the code
actually is unreachable, but apparently debug builds on QNX can't work
that out. Since nothing actually needs the function to be constexpr,
remove that qualifier. In the process, move the offset-case, which is
also unreachable, to the end of the switch, closer to the unreachable
end of the function (since I failed to spot that there were two
unreachable parts at first).

Pick-to: 6.9 6.8
Fixes: QTBUG-132698
Change-Id: Ibdde7abd91d284e1c1af53e2b5e142fc234400a8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-13 17:56:27 +01:00
Volker Hilsheimer
b562c36a9a QFontVariableAxis: add debug stream support
Was missing from this new value type, and is quite useful for this type.

Addresses API review comment.

Pick-to: 6.9
Change-Id: I07ea7ded7f963b2032c377f024bb88e9d54a4d5c
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-13 16:38:43 +01:00
Moss Heim
21bd32b2cc CMake: Fix typo in comment
Pick-to: 6.8 6.9
Change-Id: I6151bd27d5310ac153c7c2c8fbb97a9de68a4f01
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-13 15:38:43 +00:00
Thiago Macieira
63520fd6a3 QVariant: clean up after its removal from Bootstrap
Amends commit cdbc76360ae4c12b25923a7cb392355a6485fc70.

Change-Id: I8214429e66b3b3c20fe9fffd5b4e7f522b589215
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-01-13 12:04:21 -03:00
Thiago Macieira
eac724605a qconfig-bootstrapped.h: merge the bottom entries into the list and sort
They were in a separate block as a result of this file previously being
used for two sets of bootstrap builds: qmake and Bootstrap. Therefore,
this amends commit 43c28aa9046967abeb4ad042c8be1aa23a19c282 ("Use Core
library for qmake instead of the Bootstrap library").

Nothing checks QT_NO_TEMPORARYFILE any more, so remove that instead of
moving, thus also amending b57a9a3cd9c95ab6549ea672715245210720c8da
("Bootstrap: remove QTemporaryFile").

Change-Id: Ib5c5500be2898f72b333fffda91ec1f6bfe83353
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-13 12:04:21 -03:00
Thiago Macieira
bbb4e7ca87 qconfig-bootstrapped.h: remove QT_FEATURE_settings
It's unused, aside from an equally-unused #include.

Change-Id: I6ecd9e5ac0036241201efffd7b009a960d88dc43
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-13 12:04:21 -03:00
Thiago Macieira
0ce7368261 qconfig-bootstrapped.h: remove zstd feature and comment
There's no more rcc.pro and rcc hasn't been bootstrapped since 6.0,
because we don't need it to store the QMimeDatabase databases.

Change-Id: I8fd9211b20a0d794d4abfffdeff99fb4ede5475b
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-13 12:04:21 -03:00
Thiago Macieira
63364a792e qconfig-bootstrapped.h: remove QT_FEATUREs related to qrandom.cpp
Amends 9e214cbcdd138d2363b836c005450d27c0191f74 ("Bootstrap: remove
QRandomGenerator"), which was the only user of both getauxval() and
getentropy().

Change-Id: I7d8c223b3bbfd86ef997fffdf046e2f4867889ff
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-13 12:04:21 -03:00
Thiago Macieira
2d2cba103f Bootstrap: remove QSystemLibrary and QWinRegistryKey
They're unused.

Pick-to: 6.9
Change-Id: I781690cca811cdbab757fffd30b64fccb197ef46
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-01-13 12:04:21 -03:00
Thiago Macieira
0604a6e760 Bootstrap: disable all debug/info/warning messages and assertions
The three bootstrapped tools should validate their arguments properly,
so there's no need to have them print something. They aren't means to
test the Qt classes either, so assertions shouldn't apply.

Change-Id: I580758610c7262414b64fffd54f84eb16743673d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-13 12:04:21 -03:00
Thiago Macieira
24b5cea95c Bootstrap: remove the QDebug streaming class
And fix some compilation bugs if QT_NO_DEBUG_STREAM is defined.

Drive-by fix the grammar in the qcommandlineparser.cpp qWarning().

Change-Id: Ia9287ea189ae4a4b7545fffdbff7dbb9196de519
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-13 09:04:21 -06:00
Thiago Macieira
2d40e30e34 Bootstrap: remove unused sources
None of this is used.

Change-Id: I8ced5410f276d47065fafffd4bcad394de968599
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-13 12:04:20 -03:00
Soheil Armin
bf76387507 Android: Fix synchronization issue of QtAbstractItemModel and its proxy
Java methods of QtAbstractItemModel may get called from Qt GUI thread or
Java main thread. Situation is the same with internal proxy methods,
where they may directly or indirectly called from these two thread.
At the same time, a chain of calls may happen from these threads, so
some functions may get called indirectly from a single caller thread.

In this change, we are adding a map of QObject* to QRecursiveMutux
where the QObject is a QAbstractItemModel, either the proxy instance
or a reference to an underlaying QAbstractItemModel when the model
is implemented in C++.

Each call to any function locks the QRecursiveMutux instance associated
with the QAbstractItemModel instance. A connection from
QObject::destroyed to a lamda, helps to remove the map entry when
the model is destroyed.

Pick-to: 6.9 6.8
Fixes: QTBUG-127467
Change-Id: I18dcdc207e201b3883526648b4e672e5868ed8ab
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-13 15:14:46 +02:00
Ivan Solovev
5f7149e359 Do not export QFontVariableAxis wholesale
This is a non-polymorphic class, so explicitly export only the
out-of-line methods.

Amends cc128d802c6d9c87a1e00a8a88d5e6590a7195f4.

Found in Qt 6.9 API review.

Pick-to: 6.9
Change-Id: I30af1121bce1ba9c57cb326cffb1375ac3b22195
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-01-13 09:25:31 +01:00
Ivan Solovev
4a6ef7fc68 QThreadStorage: move includes to the top
The qthreadstorage.h header contains two implementations controlled by
the QT_CONFIG(thread) definition.

Commit 8553ffd8d147ecf6a713d12a360027b477dd59c8 changed the positions
of the namespace macros in the header, but didn't consider the fact
that we now include std and Qt headers inside QT_NAMESPACE in the
!QT_CONFIG(thread) case.

Fix it by moving all the includes to the top, and wrapping them in
the needed QT_CONFIG() checks. As a drive-by, drop the unused
type_traits include.

Found in Qt 6.9 API review, but picking down to 6.5, as that's what
the original commit did.

Note that 6.5 cherry-pick will require to replace <memory> with
QtCore/qscopedpointer.h because
6da1f72311b844b2232da3067ad6e1e24614e67c was never picked to that
branch.

Pick-to: 6.9 6.8 6.5
Change-Id: Ic9c5fe82df38a3bd64829c016de8dcbd9f060315
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-13 09:25:21 +01:00
Marc Mutz
c5a4e3f790 QDebugStateSaver: port from QScopedPointer to unique_ptr
In preparation of adding QT_NO_SCOPED_POINTER, which would be rather
pointless for users if public headers continued to mention the type.

Pick-to: 6.9 6.8
Task-number: QTBUG-132213
Change-Id: Ib5a40a1b8defe1cfe858218bb25c422f900dfe6b
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-13 00:43:30 +00:00
Marc Mutz
287234704b QSpan: don't detach Qt containers
When converting an implicitly-shared Qt container to QSpan, the QSpan
ctor would call .data(), which detaches said Qt container (if it's not
const). This is what must happen for mutable spans (QSpan<int>), but
is not necessary for non-mutable spans (QSpan<const int>).

Fix by copying the potential const from QSpan::element_type to the
Range object in the resp. QSpan ctor. This makes a QSpan over a const
element_type mark the range const before passing it to adl_data() (=
member-data()). For a non-const element_type, nothing changes.

[ChangeLog][QtCore][QSpan] No longer detaches implicitly-shared Qt
containers converted to QSpan<const T, N>. Note that std::span<const
T, N> will, however, detach such containers, so we recommend to use
std::as_const() with implcitly-shared Qt containers, as always.

Fixes: QTBUG-132133
Pick-to: 6.9
Change-Id: I9fdae20994d2c900bc5b45b44db3901d10f8838a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-13 01:43:30 +01:00
Giuseppe D'Angelo
793309693a QException: honor the RO5
QException has an out-of-line destructor in order to pin its vtable.
But like any std::exception subclass it's meant to be (and effectively
is) copy-constructible and copy-assignable (cf. [exception]/2).
Add the missing copy operations, and the default constructor.

One may argue that this class should use some other approach since it
also has a polymorphic clone() -- for instance disable assignments and
make copy constructions protected -- but that ship has sailed.

This prevents a Clang warning about the deprecated copies in the
presence of a user-declared destructor.

Change-Id: I4d8613ade265ea85a5a7e97255b75b7fcf3e5a27
Pick-to: 6.9 6.8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-12 21:50:21 +00:00
Giuseppe D'Angelo
b42651c749 QNetworkRequestFactoryPrivate: remove the destructor
It's unnecessary and just generates warnings due to the deprecated
copy operations.

Change-Id: I7aac7efc215dffb3298951972280f7a2ff6ef72c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-12 22:50:03 +01:00
Thiago Macieira
2f69a05bd0 QThread/Unix: move the pthread_key to a file-scope static
So that the pthread_key is destroyed much later than now, at QtCore
unload time instead of a bit earlier in exit(). That's important so it
runs later than the Q_DESTRUCTOR_FUNCTION for QLibraryStore
(qlibrary.cpp), which is what unloads plugins, whose unload-time
destructors may be attempting to quit() & wait() for their worker
threads.

I had to keep the destruction of the exiting thread's adopted thread
where it was: a function-local static's destructor. As noted in the
comment added by 1da7558bfd7626bcc40a214a90ae5027f32f6c7f, we need
QThreadData::cleanup() to run before the libraries start to unload
because we need to delete the event dispatcher.

Init priority 10 will place it after the QHash random seed and qsimd
initialization, on ELF systems and on Windows. On other systems (incl.
Apple ones), the order probably depends on the order of the files in the
CMakeLists.txt. I thought that would mean the destructor for thread/
would run before plugin/ but that apparently is not the case. But that's
fragile.

Amends 1da7558bfd7626bcc40a214a90ae5027f32f6c7f, which amended other
things...

Fixes: QTBUG-132697
Task-number: QTBUG-102984
Task-number: QTBUG-132381
Pick-to: 6.9 6.8
Change-Id: Id7263d6ffe7a5949cd84e35d942ad0e02df1b455
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-01-12 12:38:01 -03:00
Thiago Macieira
bfbd1a281d tst_Q*Application: add tests for unusual qApp creations and exits
This commit adds one unusual creation and three more unusual exits:
* creation of the Q*Application in a thread (QTBUG-130895)
* exits using ::exit() instead of returning from main():
  * from the main thread's event loop
  * from an auxiliary thread
  * from inside an auxiliary thread's event loop

All of these exercise the moment the QAdoptedThread & QThreadData for
the main thread is destroyed, which are, respectively:
* thread exit time, running thread-specific destructors
* inside exit(), running atexit()-like callbacks (qthread_*.cpp)
* [tst_static_q*application] inside exit(), running static destructors
  (added in commit 1da7558bfd7626bcc40a214a90ae5027f32f6c7f)

Unlike the tst_static_q*application tests, the calls to ::exit() cannot
be a regular QtTest because that would cause the log output to be
incomplete. The threaded Q*Application could be a test of its own, but
since I needed to add the helper anyway, I chose to add the test there.

For the majority of the tests, the failure mode is going to be a crash
on exit.

Task-number: QTBUG-12673
Task-number: QTBUG-132429
Pick-to: 6.8 6.9
Change-Id: I1062ef500356bd97dd0cfffda4aeeda9afa138e8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-01-12 12:38:01 -03:00
Nicolas Fella
74e57c5d9d XdgToplevelIcon: Reserve instead of resize list
resize() changes the size of the list, reserve() changes the capacity.

If we resize and then append we end up with too many items, some of
which are default-constructed (invalid) sizes.

Later we use the invalid size to get a pixmap, which will be empty.

In QWaylandShmBuffer we then try to mmap the empty pixmap, which fails
and we return early, never calling init() and setting mBuffer.

In QWaylandXdgToplevelIconV1 we then pass this null buffer
to add_buffer, which results in a protocol error

Fixes: QTBUG-132727
Pick-to: 6.9
Change-Id: I8f164c43423726367157fa9ce2e3af7a6fd3219c
Reviewed-by: David Redondo <qt@david-redondo.de>
2025-01-12 12:15:23 +01:00
Giuseppe D'Angelo
239474710d QCborContainerPrivate: honor the RO5
The class defines a destructor, but it's also meant to be copy/move
constructible (being a shared data for QCbor* classes). On the same
note, the class is not meant to be assignable, as doing so would corrupt
the refcounting, so delete those operations.

Change-Id: I7781773da86b26544f9389337bfc059d9483fef9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-12 11:48:45 +01:00
Giuseppe D'Angelo
09e40152f8 Q*PaintEngineState: use canonical signature for the copy constructor
I'm not sure why this code had copy constructors taking by non-const
reference. Add the missing const.

Change-Id: Ie6d1cb6eab7b829a59e21f1874b041a00a52d1e9
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2025-01-12 11:48:25 +01:00
Christian Ehrlicher
c64774eef7 QIcon: don't search for high-res svg icons
There is no need to search for high-res svg icons - a svg scalable by
design. Also the QSvgIconEngine does not support it.

Pick-to: 6.9 6.8
Change-Id: Ib76c887900ce77268e9c0253cb697b8de9e7f10e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-12 07:40:48 +01:00
Ahmad Samir
0e68115324 QList: overload data_ptr() for rvalue
Amends 343cc50c224655ba8da5cc02d263a9b70f10d529. Marc suggested
adding an rvalue overload for data_ptr().

Return by rvalue as the new overload empties `this`; also
`std::optional::value() &&` returns by rvalue so it's more idiomatic.

Change-Id: I4e2f2cdee2420059465b0592b84c8ade3444e88b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-11 18:40:57 +02:00
Tor Arne Vestbø
0e2067334d coin: Ignore exit code of LastTest.log copy if COIN_CTEST_IGNORE_EXIT_CODE
If COIN_CTEST_IGNORE_EXIT_CODE is in effect and ctest aborts for some
reason (for example due to the workitem being cancelled) the ctest exit
code will be ignored, as expected, but we will not have a LastTest.log
to copy, which will fail the workitem unexpectedly.

We now match the ignoreExitCode of the LastTest.log copy with the ctest
run.

Pick-to: 6.9
Change-Id: I9df0f863a42dd4cf25cee1694e85cb32058a4e5b
Reviewed-by: Toni Saario <toni.saario@qt.io>
2025-01-11 12:32:59 +01:00
Wang Bin
004a765d1f rhi: metal: support HDR10
Change-Id: I6a50657e96f6e41ef2907abdac937b5e491380f8
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-01-11 11:14:14 +08:00
Wang Bin
4f7e0f4519 macOS: prefer VK_EXT_metal_surface
fix vkDebug: vkCreateMacOSSurfaceMVK() is deprecated. Use vkCreateMetalSurfaceEXT() from the VK_EXT_metal_surface extension.

Change-Id: I8e2ef1acf9f9147b233c26bd3c550c44ffa149b1
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-01-11 11:13:48 +08:00
Marc Mutz
6397dac979 QSaveFile: mention that you need to setFileName() before open()
... in the descriptiong of the (QObject*) ctor.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I1b8a788eff1fbb50134b51de7d9ee8f7cb2af785
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-11 01:03:52 +01:00
Marc Mutz
97fe38ff0d tst_QSaveFile: QVERIFY the commit() return value in symlink() test
It's kinda is important to verify that commit() worked; all the
follow-up tests assume it, so wrap the calls in QVERIFY().

Amends 7e5e7eeaa1418d959906cdf9d717c984c9fc7a7e.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I01185d65a5ec06ed122e59c43d9cdcc3a7157259
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-11 01:03:51 +01:00
Marc Mutz
67a906b556 tst_QSaveFile: mark a QString const
To ensure we don't overwrite it in this quite long function.

Amends 7e5e7eeaa1418d959906cdf9d717c984c9fc7a7e.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: Ie5f81b50d2d66ba9e064810f8cbc1a7af298cc2b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-11 01:03:51 +01:00
Vlad Zahorodnii
25c23969cc tst_QKeySequence: Test qt_set_sequence_auto_mnemonic()
qt_set_sequence_auto_mnemonic() is documented in the public api but its
on/off effect is not covered by any test.

Change-Id: I682da014bcf04db3ef2508c09781ee32d297eb1f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-11 00:36:06 +02:00
Christian Ehrlicher
5bab8448fe QStandardItem: correctly set model during insertRows()
When calling insertRows(), the model of the child items was not
correctly updated. insertRow() is behaving correctly.

Pick-to: 6.9 6.8
Fixes: QTBUG-131372
Change-Id: I8b6aef7ab97887c6eb46eb21b992d76e4d59b3a0
Reviewed-by: David Faure <david.faure@kdab.com>
2025-01-10 20:40:46 +01:00
Alexandru Croitor
41a92bf6f1 CMake: Fix sbom git vars not being available in various scopes
Initially the git vars were assigned to the parent scope of the
_qt_internal_sbom_begin_project function, with the intent to set them
in the global scope. But the function was later wrapped in other
functions, so the variables stopped being accessible.

Instead of playing with recursive PARENT_SCOPEs, save the variables in
global properties like we do for other info, and use a new
_qt_internal_sbom_get_git_version_vars() function to query the vars in
the code that needs them.

This fixes generated purls to contain the git version and hashes.

Also add a new internal API wrapper macro called
qt_internal_sbom_get_git_version_vars to allow calling it
in other repos.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I061b34f418c1ecc1c66c8c01ef758d2f40611ede
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-01-10 18:42:23 +01:00
Alexandru Croitor
27d2b54b5d CMake: Split SBOM implementation into separate files
The SBOM implementation got somewhat large. Split the code into
several new QtPublicSbomFooHelpers.cmake files, to make it more
manageable.

No code or behavior was changed.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: Ia0ca1792eec21d12c4bb4cabe63279e1f5c07e3d
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-01-10 18:42:22 +01:00
Vlad Zahorodnii
d612dcd249 a11y: Port qt_accHotKey() to QKeySequence::mnemonic()
QKeySequence::mnemonic() contains additional input sanitization logic
and in combination with the toString() function, it provides a platform
agnostic way to get the shortcut text for the mnemonic.

tst_QAccessibility was adjusted because mnemonics don't work by
default on macOS. See qt_set_sequence_auto_mnemonic().

Change-Id: I96842a6c18140a559aeaeb8f687e32011e5e2e77
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-10 17:29:58 +02:00
Ivan Solovev
da799c20d7 QMetaEnum::valueToKeys: fix REMOVED_SINCE version
Should be 6.9. The entries in removed_api.cpp are already added to the
correct place, just the macro in the public header used wrong version.

Amends d41b87e06742b491c4e36aeae32e03f85b078d69.

Pick-to: 6.9
Change-Id: I88749dbeb070206c42feb4ffc504f260f8857823
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-10 15:17:14 +01:00
Alexandru Croitor
4c5d9a3ca3 CMake: Fix purl variant list iteration
The correct syntax is IN LISTS, not IN_LIST.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: Ibf64e48ffcf0b061887b7b015096d588b14bce57
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-01-10 10:54:03 +01:00
Alexandru Croitor
2affe46b25 CMake: Fix LINK_LIBRARIES not being properly processed for SBOM
There was a typo in the link_libraries variable name, where an upper
case 'L' was used instead of a lower case 'l'.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: I206a161107cf7510856ad8740dada88e12341e94
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-01-10 10:54:01 +01:00
Jules Bertholet
1a82056000 Support various action keys in shortcuts
This adds support for the Help, Open, Close,
Save, New, Cut, Copy, Paste, Undo, Redo, Back,
Forward, Refresh, ZoomIn, ZoomOut, Find,
Settings, Exit, and Cancel keys to the default
keyboard shortcuts.

These keys can be found on old and unusual
keyboards, but also in custom layouts for
standard keyboards.

Task-number: QTBUG-93269
Change-Id: Id349cad977800589ded14456e99c6b20a0263592
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2025-01-10 01:08:14 -05:00
Christian Ehrlicher
9d4b5fa017 QTreeView: fix Private::intersectedRect()
Don't try to update the left and right boundaries when no valid idxRect
was found.
Also fix the early exit check - we can exit when the idxRect is
completely below *or* completely above the current viewport.

This amends 2f9c72028d2481f587f378a256654d0a362e3d44.

Pick-to: 6.9 6.8
Fixes: QTBUG-132670
Task-number: QTBUG-124173
Change-Id: I51f9e12c66268318e597facfbe4df74367d1089a
Reviewed-by: David Faure <david.faure@kdab.com>
2025-01-09 21:36:46 +01:00
Volker Hilsheimer
9f10fd8374 JNI: Simplify type conversion for native functions, reuse existing code
The QJniObject::LocalFrame has all the logic for converting between Qt
types and corresponding JNI types. Instead of implementing the same
type mapping for native function calls, reuse LocalFrame, with the
special handling of cases where no conversion is necessary at all.

Change-Id: I4a94b22788669387330ec1b3e27bb06eb6d64b7b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Volker Krause <vkrause@kde.org>
2025-01-09 21:13:20 +01:00
Ivan Solovev
0d0b346322 Port QEventDispatcherWin32 to QAbstractEventDispatcherV2
The new APIs use Qt::TimerId to identify timers, and also use nanosecond
resolution for the timer interval.

However, as the underlying Windows APIs do not support nanosecond
resolution, and always use uint millisecods and int timer id, this patch
does not touch the internal WinTimerInfo struct definition, but only
adjusts to changes in the public QAbstractEventDispatcherV2 API.

Fixes: QTBUG-129170
Change-Id: Icc8d7b99affcf34e5677cd22502717f63a1d576c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-09 20:48:24 +01:00
Alexandru Croitor
242e293323 CMake: Fix file path in checksum computation to allow spaces
Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Change-Id: Ica5f830e6d7ca9d8acbc13ebec543ee3cf96b3fe
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-01-09 19:33:16 +01:00
Alexandru Croitor
82dc92cb1b CMake: Use the $<VERSION> placeholder in qt_attribution.json
For all CPE and PURL fields where it makes sense, to avoid
duplication.

Pick-to: 6.8 6.9
Task-number: QTBUG-132181
Change-Id: Icd1c5267e4e9b582eea28150ebd1b2cca3852229
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-09 19:33:15 +01:00
Alexandru Croitor
bc3bbb51b7 CMake: Replace placeholders in CPE and PURL strings in SBOMs
Replace instances of $<VERSION> in CPE and PURL strings read from
qt_attribution.json files with the version of the package being
processed.

This avoids duplicating the version in qt_attribution.json files in 3
different fields Version, CPE, and PURL.

Pick-to: 6.8 6.9
Task-number: QTBUG-132181
Change-Id: I91af17c82dbb936739f4811bf86043e00ee49a78
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-01-09 19:33:15 +01:00
Alexandru Croitor
97ac405313 CMake: Add internal functions to get various kinds of spdx ids
These can be useful when adding custom relationships to the generated
SBOM document.

Sample usages could be:

qt_internal_sbom_get_target_spdx_id(Svg svg_spdx_id)
qt_internal_sbom_get_project_spdx_id(project_spdx_id)
qt_internal_sbom_get_external_document_ref_spdx_id(
    "qt5compat" document_ref_spdx_id)

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Task-number: QTBUG-129901
Task-number: QTBUG-131377
Change-Id: Idbd5c8bffece50871f995805b619226e32957866
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-09 19:33:15 +01:00
Alexandru Croitor
b8f5e5f554 CMake: Add way to convert JSON SPDX to tag/value SPDX document
Add a new qt_internal_sbom_generate_tag_value_spdx_document function
that takes an input SPDX JSON file and generates a tag/value SPDX
file. This is needed by WebEngine to convert the Chromium JSON file to
a tag/value SPDX file so we can reference it as an external document.

To ensure the external document is found, we now always add the
current sbom build directories as install prefixes. This was
previously done only for top-level builds.

To ensure the converted external document is referenced only after it
is converted, it needs to be converted before any targets mention
packages from within it.

A sample usage might be:

qt_internal_sbom_generate_tag_value_spdx_document(
    OPERATION_ID qt5compat
    INPUT_JSON_FILE_PATH "${external_sbom_file_path}"
    OUT_VAR_OUTPUT_FILE_NAME external_output_file_name
    OUT_VAR_OUTPUT_ABSOLUTE_FILE_PATH external_output_file_path
)

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Task-number: QTBUG-129901
Task-number: QTBUG-131377
Change-Id: I5d5397f788c8c7960b6fc233c2868244e5816e0b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-09 19:33:15 +01:00
Alexandru Croitor
d079fdd76c CMake: Allow adding custom SBOM relationships to targets and projects
Add a new SBOM_RELATIONSHIPS option to qt_internal_extend_target and
friends that allows adding custom relationships to the current target.

Add a new function qt_internal_sbom_add_project_relationship that
allows adding custom relationships to the current project SBOM
document.

A sample usage might be:

qt_internal_sbom_get_project_spdx_id(project_spdx_id)
qt_internal_sbom_get_target_spdx_id(Svg svg_spdx_id)

qt_internal_extend_target(Svg
    SBOM_RELATIONSHIPS
        "${svg_spdx_id} DESCENDANT_OF ${project_spdx_id}"
)

qt_internal_sbom_add_project_relationship(
    RELATIONSHIPS
        "${svg_spdx_id} CONTAINS NOASSERTION"
        "${svg_spdx_id} DESCRIBES NOASSERTION"
        "${project_spdx_id} DESCRIBES NOASSERTION"
)

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Task-number: QTBUG-129901
Task-number: QTBUG-131377
Change-Id: Ie0119ca71b047c7515e1deaf84a5a67ea01b5274
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-09 19:33:15 +01:00
Alexandru Croitor
f086e72b7e CMake: Fix project spdx id used in implicit relationships
We shouldn't be using the direct project name in spdx relationships,
but rather the sanitized name which is prefixed with
'SPDXRef-Package-', to ensure sbom validation succeeds.

Also we should default PROJECT_FOR_SPDX_ID to
"Package-${arg_PROJECT}" if it's not set.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Task-number: QTBUG-129901
Task-number: QTBUG-131377
Change-Id: I354babcf4fea5f6efd9b32422dd8d3835ef50f15
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-01-09 19:33:14 +01:00
Alexandru Croitor
9a3998692c CMake: Add API to allow referencing external packages in the SPDX SBOM
This change modifies the existing implementation of the
external references API to have better named options and better
behavior.
It also adds comments and exposes an internal API wrapper around the
existing implementation.
It's meant to be used by qtwebengine to reference the
Chromium-generated SBOM.

As a drive-by, it removes the previously unused RENAME option.

A sample usage could be:

qt_internal_sbom_get_external_document_ref_spdx_id(
    "qt5compat" document_ref_spdx_id)
qt_internal_sbom_add_external_reference(
    EXTERNAL_DOCUMENT_FILE_PATH "/path/to/qt5compat-6.8.1.spdx.json"
    EXTERNAL_DOCUMENT_SPDX_ID "${document_ref_spdx_id}"
)

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Task-number: QTBUG-129901
Task-number: QTBUG-131377
Change-Id: I13d0fe4d803449bec42f8b454c8131e4d727669a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Moss Heim <moss.heim@qt.io>
2025-01-09 19:33:14 +01:00
Alexandru Croitor
8c754dcbb1 CMake: Add API to include custom cmake files during SBOM generation
Allow including custom cmake files at predefined steps of the sbom
generation using the new internal
qt_internal_sbom_add_cmake_include_step API.

This covers pre-existing steps like BEGIN, END, POST_GENERATION, and
VERIFY, as well as two new steps, BEFORE_CHECKSUM and AFTER_CHECKSUM.

A sample usage of the new API could be:

set(step_path "${CMAKE_CURRENT_BINARY_DIR}/run_some_cmake.cmake")
file(WRITE "${step_path}"
    "
    # This is a CMake script to run some CMake code.
    message(STATUS \"Running some CMake code...\")
    message(STATUS \"Done running some CMake code.\")
    "
)

foreach(step IN ITEMS BEGIN END BEFORE_CHECKSUM
                      AFTER_CHECKSUM POST_GENERATION VERIFY)
    qt_internal_sbom_add_cmake_include_step(
        STEP "${step}"
        INCLUDE_PATH "${step_path}"
    )
endforeach()

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Task-number: QTBUG-129901
Task-number: QTBUG-131377
Change-Id: I6f9512bf3a3bc3ebeb7d21426e5a3833280e42a5
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-09 19:33:14 +01:00
Alexandru Croitor
b085fe6ad9 CMake: Add SBOM support for translations, custom files and friends
This change introduces a new SBOM API to add info about various kinds
of files to a target SBOM package. The new function name is called
qt_internal_sbom_add_files().

The motivating case is including SBOM information for qt translation
files, resources (e.g. webengine data files) and any other kind of
custom files.

A sample call might look like:

qt_internal_sbom_add_files(Translations
    FILES "${qm_files}"
    SOURCE_FILES_ONE_PER_INPUT_FILE "${ts_files}"
    FILE_TYPE "QT_TRANSLATION"
    INSTALL_PATH "${INSTALL_TRANSLATIONSDIR}"
)

While the motivating case is Qt-specific, the function implementation
is being somewhat future proofed for the not-yet created public SBOM
API.

The new API supports adding files to any target that is backed by an
SBOM package, so all targets created by qt_internal_add_module()
and friends, as well as ones created by qt_internal_add_sbom().

It can be called multiple times for the same target, with a different
set of files, to e.g. assign a different license, or file type per
file set. Note that the file set doesn't have anything to do with
CMake's concept of file sets.
The function is also multi-config aware, and allows specifying
different install paths per config, as well as generator expressions
in file names. But the multi-config support is a bit wonky, and might
need some rethinking in the future.

Note that the custom files must be installed and available in the
specified qt install path, because the file contents will be
checksummed at install time and embedded into the sbom document.
Calling the new API does not do installation itself.

Implementation wise, the function call flow is
- project calls qt_internal_sbom_add_files() one or more times
- at finalization time, the _qt_internal_sbom_add_target finalizer is
  called for a target, which then calls
  _qt_internal_sbom_handle_target_custom_files()
- the latter calls _qt_internal_sbom_handle_target_custom_file_set()
  for each file set that was added to the target
- the latter calls _qt_internal_sbom_handle_multi_config_custom_file()
  for each input file in the file set, which ultimately calls
  _qt_internal_sbom_add_custom_file()

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Task-number: QTBUG-128320
Change-Id: Iafde26ebd68f4168b49e55fbc8ad1c251e98d4b0
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-01-09 19:33:14 +01:00
Alexandru Croitor
42a58d6619 CMake: Remove SBOM multi-config dead code
These variables were not used anywhere.

Pick-to: 6.8 6.9
Task-number: QTBUG-128893
Task-number: QTBUG-122899
Change-Id: If53b3fd8200971dcfde69cefa4df07b67d5669c5
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-01-09 19:33:14 +01:00
Alexandru Croitor
2fa815341c CMake: Move SBOM project ops setup to run at project begin time
Previously Python and other sbom tooling was looked up at SBOM
project end time.
This was fine for the use cases we had so far, but it prevents
introducing new API that wants call the spdx tools before the end of
the project. Such API will be introduced in a follow up change.

Move the python interpreter, python dependency lookup and other sbom
tooling setup to happen at project begin time.

Pick-to: 6.8 6.9
Task-number: QTBUG-122899
Task-number: QTBUG-129901
Task-number: QTBUG-131377
Change-Id: Ic8884e378c0ffd9720ede26b0c61f4122f3bb9d9
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-01-09 19:33:13 +01:00
Ivan Solovev
e2756158dc [docs] Fix a typo in the QColorSpace class name
That prevented qdoc from generating the docs for the fromPrimaries()
function.

Amends bde2292247bf4849852355c0dcc71f97c9daace9.

Found in Qt 6.9 API review.

Pick-to: 6.9
Change-Id: I2f5c57a4dc4a437798907c64fb657c9fda61e0df
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-09 18:34:13 +01:00
Jøger Hansegård
5dcdeeebbc Compare QUniqueHandles using comparesEqual and compareThreeWay
This fixes an issue where comparing pointers to object is only defined
if both pointers point into the same array.

Task-number: QTBUG-132507
Pick-to: 6.8 6.9
Change-Id: Ib7ccb30001add38ad25b62c848a01cd53566d8bf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-09 17:32:15 +01:00
Frédéric Lefebvre
2c0d46e180 Remove broken/bugged manual test setScreen
Remove the broken/bugged manual test setScreen.

To be determined if it should be fixed and kept or discarded.

Change-Id: I036725c4b17051c49b66e29649ab14c1c23a1cb5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-09 14:55:36 +00:00
Alexey Edelev
b0dc47aa44 Move qt_internal_sort_android_platforms to public android helpers
The function is used in semi-public API and should in
QtPublicAndroidHelpers.cmake.

Amends de40931eba2cf09a8c97c9a75c6d23c77748f44c

Pick-to: 6.9
Change-Id: I3946ecb091584ac5406b3eb4d2024210398f26a3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-09 14:08:18 +01:00
Isak Fyksen
caf22e481d Replace QPair/qMakePair with std::pair in qtbase/gui
Task-number: QTBUG-115841
Pick-to: 6.9
Change-Id: Iebd96760ff7b3d7674816553312ba8dc3229c86a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-09 12:32:34 +00:00
Isak Fyksen
71d114588d Replace all QPair/qMakePair with std::pair in qtbase/widgets
As a drive-by replace QList::append and operator<< with emplace_back,
to avoid repeating value_type.

Task-number: QTBUG-115841
Pick-to: 6.9 6.8
Change-Id: I6fb790f959b41b0feb49e3a0f0b6b3631e24a232
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-09 12:32:34 +00:00
Frédéric Lefebvre
78b6969f1b Remove tst_manual_toplevel manual test as irrelevant
Top level widget that can receive paint events. This manual test seems
irrelevant.

Shows an empty widget topLevel.

Remove tst_manual_topLevel manual test.

Change-Id: Id9b037067cf79ea516e5e7d18c281f9e1d2f14c2
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2025-01-09 10:07:52 +01:00
Topi Reinio
5c0b08a20d Doc: Modify \tabcontent..\endtabcontent macros
QDoc markup following the \tabcontent macro should start a new
paragraph. As HTML-specific macros are injected directly into
the output, QDoc's doc parser is not aware that the macro should
start a new paragraph.

Turn the macros into generic, non-format-specific macros,
expanding to \div and \enddiv commands that wrap the tab
content.

Pick-to: 6.9 6.8 6.5
Change-Id: Ie8313af391b1a38ef74592acac3198fef5b7b310
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
2025-01-09 02:34:50 +00:00
Marc Mutz
e7abbc7bf3 QTemporaryFile: fix incorrect info about duplicate placeholders
The docs said only the first placeholder would be considered; in fact,
it considers only the last.

Fix the docs and add a test (also for QTemporaryDir).

Amends b4bb4449aea7592afdb9b9134bb90c40fe29735a.

While 6.6 and earlier are unaffected by the incorrect documentation,
pick this to all active branches in order to verify the behavior is
the same everywhere.

Pick-to: 6.9 6.8 6.5 6.2 5.15
Fixes: QTBUG-132597
Change-Id: Ia7a37f714f834191b07420d31ca9024702b537cc
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-09 01:22:12 +00:00
Joerg Bornemann
2d38af3125 CMake: Simplify Qt6FooPrivate -> Qt6Foo package dependency setup
This amends commit fbbf4ace0188b9718b6d7808021c0b887fd52d9f.

Remove the EXTRA_PACKAGE_DEPENDENCIES argument that was added in
mentioned commit, and use the qt_register_target_dependencies function
instead to add the package dependency Qt6FooPrivate -> Qt6Foo.

Pick-to: 6.9
Task-number: QTBUG-87776
Change-Id: I08a48954576dc3c0b6fde809f90d2022201d7eb0
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-01-08 21:24:15 +01:00
Joerg Bornemann
e7816586b6 CMake: Don't export 3rdparty dependency find_package calls
...of private modules in public modules. This isn't necessary anymore
since the Qt6FooPrivateDependencies.cmake files contain these 3rdparty
dependencies proper.

This reverts commit dae078e521c3932c66436cbdbfaf5294a1842901.
This amends commit fbbf4ace0188b9718b6d7808021c0b887fd52d9f.

Pick-to: 6.9
Task-number: QTBUG-87776
Change-Id: I2c425d49fe7beb790abf9a94f089d43fde8b047e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-08 20:45:55 +01:00
Thiago Macieira
d589892352 QApplication: don't create app_fonts() on destruction
Minor optimization, will probably never be needed.

Change-Id: I14568dffcb5d09668753fffd24efd10a3fedb21b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-08 16:45:55 -03:00
Volker Hilsheimer
43acbf4779 JNI: move LocalFrame from QJniObject into Detail namespace
We need it in several places, so move it out of QJniObject. To minimize
the impact on QJniObject code, declare an alias within that class.
Remove the now unnecessary friend declaration of QJniArrayBase.

Change-Id: I64d55903038a6d8e21f3819b37a4d5ccd76cda2d
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-08 20:45:55 +01:00
Volker Hilsheimer
bf2491acc7 JNI: avoid detach attempt when populating an uninitialized QString
QString::data on a non-const string will needlessly try to detach.
Avoid that by accessing the raw data pointer.

Addresses header review comment.

Pick-to: 6.9
Change-Id: I89b4d3451cda517e5c5ca08173510b3529ce73aa
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-08 20:45:55 +01:00
Volker Hilsheimer
611914421d JNI: add missing qxptype_traits.h include to qjniobject.h
We use qxp::is_detected_v. Addresses header review comment.

Pick-to: 6.9
Change-Id: I57bb2bb2158d82e2cd5e6df5885cde8aedb63b4f
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-08 20:45:54 +01:00
Volker Hilsheimer
c5c3730400 JNI: Simplify Traits specialization for QJniArrayMutableValueRef<T>
Just inherit from Traits<T>. Addresses header review comment.

Pick-to: 6.9
Change-Id: If11df666a925a13e54e94b30e42316a6aa06bbc7
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-08 20:45:54 +01:00
Volker Hilsheimer
291c5ec433 JNI: fix declaration of QJniArray(Mutable)Iterator postfix operators
As per the standard at [1], the second parameter has to be int, while
difference_type is jint (which is also int, so no difference in
practice, esp for the already released QJniArrayIterator).

https://eel.is/c++draft/over.oper#over.inc-1.sentence-3

Addresses API review comment.

Pick-to: 6.9
Change-Id: Idea11f83048b9b65548ec1ac8abc2586c6e61a27
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-08 20:45:54 +01:00
Ivan Solovev
82f6938d8a [docs] Add description of other C++20 features to the overview
Task-number: QTBUG-128837
Pick-to: 6.9 6.8
Change-Id: I07731cd75c97c16eb008a76727b2ae831c029284
Reviewed-by: Jaishree Vyas <jaishree.vyas@qt.io>
2025-01-08 20:29:26 +01:00
Topi Reinio
1926df8d57 Third party code attribution: Change Id to lower case
Each 3rd party license attribution is identified by a
unique Id key, which should be all lower case and without
spaces. See QUIP-7 for more info. about the
qt_attribution.json file format:
https://contribute.qt-project.org/quips/7.

Pick-to: 6.9 6.8
Change-Id: Iaa233a0e6180945e014b9a407bbd61df591f1dea
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
2025-01-08 18:59:38 +00:00
Ahmad Samir
4073a75959 tst_Q{Chrono,}Timer: fix typo in CMakelists.txt
Spotted by Thiago in code review.

Amends bd764cc1ca578759f16fbe292fbe14a243b7d263 and
9cf47946fc872ed95f1b3a766658dd5076a5d473.

Pick-to: 6.8 6.9
Change-Id: I01b04d2c80c62158917e6f190418053edc0a0fe5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-08 18:57:04 +02:00
Giuseppe D'Angelo
9f03c64af7 QPageLayoutPrivate: remove declaration of the destructor
It's unnecessary (defaulted). The class is meant to be copiable and it
can be such as a RO0 class.

Change-Id: I179bf33f1b50e0c474c9b7938440e720f558b8fe
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-08 16:29:53 +01:00
Giuseppe D'Angelo
e73bb604d8 QPrinterInfoPrivate: code tidies
Make the constructor explicit, and remove the unncessary declaration
of the destructor (turning the type into a RO0 type).

Change-Id: I485d2c5f21d3a1972dbdb348ce3d7f3a15bd6275
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-08 16:29:52 +01:00
Alexey Edelev
80932ed80b Small _qt_internal_find_tool_dependencies optimization bit
Set __qt_${target}_find_package_args once per the
_qt_internal_find_tool_dependencies call. It doesn't make sense to call
set it in loop, since variable doesn't depend on loop parameters.

Pick-to: 6.5 6.8 6.9
Change-Id: Ia1024625b870364a1db8e07f61bf7ea6ab4e9f84
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-08 16:29:52 +01:00
Alexey Edelev
f881e06dd4 Split the tool dendencies lookup to Qt and 3rd party
Tool dependencies that are added using the
qt_record_extra_package_dependency function now are considered as
the third party dependencies. This allows using two different
approaches when looking for the dependencies of Qt tools.

All dependencies that are Qt tools now go to the path invented in
035fbd068b5a3fbc18b7868ecac9a6a6a2f6602c and use the
_qt_internal_find_tool_dependencies function which is designed to
look for Qt packages and uses CONFIG signature of find_package.

To look for the non-Qt modules we should use more generic find_package
signature and _qt_internal_find_third_party_dependencies fits perfecly
for these purpose.

Note that it's known issue that the
_qt_internal_find_third_party_dependencies command also may find
"target" tools when crosscompiling, but this commmit doesn't reinvent
it. We already have various places which make the scoped "host"
dependencies lookups to ensure that "host" tools look for the "host"
dependencies in build systems like yocto.

Ammends 035fbd068b5a3fbc18b7868ecac9a6a6a2f6602c

Task-number: QTBUG-132340
Fixes: QTBUG-132622
Fixes: QTBUG-132616
Pick-to: 6.5 6.8 6.9
Change-Id: I9effba3d405ceec720a8a2a332250619cd56f598
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-08 16:29:52 +01:00
Giuseppe D'Angelo
e1b681c712 QEasingCurve: doc tidies
Use \nullptr instead of "zero".

Change-Id: I653d4e9375b2b7002f7bb78a85c7a8f8e4e007dc
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-08 16:29:52 +01:00
Marc Mutz
4af8a20e8e QUuid: mark Version::UnixEpoch as since 6.9
... because it is.

Amends d89cef439f5c1a58aeff879a12d9a33292764b7f.

Pick-to: 6.9
Change-Id: I82cfb386c058a0dda873022377ec91368c71e026
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-08 15:19:34 +00:00
Tor Arne Vestbø
9bebdc97f1 macOS: Enable crash reporting for tests via Swift
Swift 5.9 includes built in crash reporting, printing stack traces,
libraries, and registers to stdout/err.

https://www.swift.org/blog/swift-5.9-backtraces/

As (Core)Foundation is written in Swift nowadays, we get this feature
for free even in our "C++" apps, as we always link to CoreFoundation.

To enable the feature the binary needs the com.apple.security.get-task-allow
entitlement, so we add it for all our tests automatically.

The final piece is to run the tests with SWIFT_BACKTRACE=enable=yes,
but we'll do this in our CI provisioning, as setting it from within
testlib doesn't seem to work.

Pick-to: 6.9 6.8
Change-Id: I31090efee06460f45522093e17f900e76590b282
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-08 15:46:37 +01:00
Alexandru Croitor
0711eb6071 Silence qcompare.h "zero as null pointer constant" warnings on macOS
When using qmake to build a user project on macOS, the Qt headers are
included with the -I option, rather than the -isystem option. This
means that the compiler will not silence warnings that are generated
while parsing Qt headers.

If the user project compiles their code with the
-Wzero-as-null-pointer-constant compiler option, this leads to
warnings like:

/QtCore.framework/Headers/qcompare.h:226:78:
 warning: zero as null pointer constant
     [-Wzero-as-null-pointer-constant]
  friend constexpr bool is_eq  (partial_ordering o) noexcept
  { return o == 0; }
                ^
                nullptr

Fixing qmake to use -isystem instead of -I is not trivial.
We already silence these warnings for gcc in the header file.
Do it for clang as well.

Amends bdd41f491c0f85ae0897a1c7372c5ecda62a5aab

Pick-to: 6.8 6.9
Fixes: QTBUG-132581
Change-Id: I7883248b7be548580a03333e76620ac10f57733a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-01-08 15:46:37 +01:00
Tor Arne Vestbø
50d5914f28 macOS: Completely disable lldb backtraces in QtTestLib on Apple Silicon
They result in lldb hanging, which was previously only a case when SIP
was enabled, but can now be reproduced on macOS 15 even with SIP disabled.

 https://github.com/llvm/llvm-project/issues/53254

Pick-to: 6.9 6.8
Change-Id: Ifa09f8cf22522b5a1028db1f250ebe9e1543cf9d
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2025-01-08 15:46:37 +01:00
Giuseppe D'Angelo
0ab44505c8 QDBusPendingReplyBase: add missing copy operations
QDBusPendingReplyBase declares its destructor (and defines it,
as defaulted, out-of-line). I'm not sure why that's the case, since
QDBusPendingReplyBase isn't polymorphic. This generates warnings when
QDBusPendingReplyBase objects are copied in the subclasses, since
the copy operations are deprecated due to the presence of the
destructor.
Add the missing copy operations, and mark destructor and copies
to be removed in Qt 7.

Change-Id: Iec2c98f5e512c3f19e5d28ab2ce2dba365c66175
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-08 15:46:37 +01:00
Giuseppe D'Angelo
71e53405a3 Tasktree: fix FTBFS due to unique_ptrs on forward-declared classes
Some classes have circular dependencies:

* RuntimeIteration depends on RuntimeTask
* RuntimeContainer depends on RuntimeIteration
* RuntimeTask depends on RuntimeContainer
* TaskTreePrivate depends on RuntimeTask
* RuntimeContainer depends on TaskTreePrivate

Although there are a few std::unique_ptr deployed, the code at the
moment does not fully solve the problem: the classes have an inline
destructor, and the dependency has only been forward declared, resulting
in a build error.

Make some destructors out-of-line, and define them (as defaulted) late
enough so that all the graph of classes has been seen, in order to fix
the build.

Pick-to: 6.9 6.8
Change-Id: If150b92154061e915ebac920806717d2288c0638
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2025-01-08 15:46:37 +01:00
Marc Mutz
33db27aeaf QWaylandShellIntegrationTemplate: swap order of base classes
The QObject must alwyas come first.

This is BiC, but it's a private header, so we don't care.

Amends a7bb7210ac76a397b4aec8d8f32d902dc932d855.

Pick-to: 6.9
Change-Id: I35edce36d1cc7f5d61f7c3457ca6541e827288a0
Reviewed-by: David Redondo <qt@david-redondo.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-08 12:52:21 +01:00
Marc Mutz
8fb0ceeb95 QWaylandShellIntegration: pin vtable to a single TU
Fixes -Wweak-vtables, at least on the base class; the implementation
is a template, so can't be fixed.

Pick-to: 6.9
Change-Id: Ic697614995042e3e0cf130bbaf1bc21a891b497b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-08 12:52:07 +01:00
Volker Hilsheimer
be9682d372 QFontIconEngine: implement actualSize correctly and fit pixmap to it
Some icon glyphs might not be square, and actualSize needs to return a
size that fits into, and maintains the aspect ratio of, the requested
size.

Compute the bounding rect of the text/glyph that would be rendered, and
scale it to fit into the requested size.

Use that to return a pixmap of the correct size.

As a drive-by, fix the cache-testing by comparing the
deviceIndependentSize of the stored pixmap with the size we want.

Pick-to: 6.9
Change-Id: Ic6fd0f0e260b3e3946d032941d9b677463d5c145
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-08 11:36:51 +01:00
Even Oscar Andersen
5c5844cedb Make QWasmScreen::allWindows return all (wasm) windows
It seems that findChildren does not return every window if called
at an inconvenient time.

This causes not all windows to be returned, and later the
QWasmCompositor will not detect a valid window to compose,
and therefor goes to disabled.

Fixes: QTBUG-132414
Pick-to: 6.9
Change-Id: I6c872071751d5a2fbdeea36fb8f4c7e9677fd7d0
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2025-01-08 10:20:47 +00:00
Wladimir Leuschner
23c16c611c QWindows11Style: Increase QComboBoxSize and align subline
Increase the size of QComboBoxSize and align the subline for editable
QComboBoxes with the begin end end of the rounded corners.

Task-number: QTBUG-132261
Pick-to: 6.9 6.8
Change-Id: I235ec1ceb94a5e87f373b007ac31d0d8a83cf600
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-01-08 08:14:27 +01:00
Wladimir Leuschner
3e9baca7d2 QWindows11Style: Decrease bottomline frame thickness for QToolButton
Decrease the bottom line frame thickness for QToolButton by using
fractional coordinates.

Task-number: QTBUG-132261
Pick-to: 6.9 6.8
Change-Id: I77a3acdd20c694dce38d809db9c3051949a98fa3
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-01-08 08:14:23 +01:00
Christian Ehrlicher
44edab7c84 Windows11Style: Misc cleanup for drawControl(CE_ItemViewItem)
Cleanup CE_ItemViewItem branch in drawControl():
 - use local rect instead rect, vopt->rect or option->rect for
   consistency
 - move out viewItemPosition comparisons into local booleans
 - fix coding style
 - merge two QPainter::drawLine() calls into one

Pick-to: 6.9 6.8
Task-number: QTBUG-131585
Change-Id: I7cd2f96a2a733a55d5e7fb5956c59bd043317cb2
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2025-01-08 04:05:22 +01:00
Giuseppe D'Angelo
f6567333aa QGtk3Interface: code tidies
The class is not meant to be copied. Therefore disable copy/moves.
This gets rid of a warning in QMetaType, since the class is also a
Q_GADGET.

Change-Id: Ie463ebd0c0dac9f2c37c4ffa88e1920ad313fd00
Reviewed-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl>
2025-01-08 04:05:22 +01:00
Giuseppe D'Angelo
7f7605c22f QBitmap: undeprecate the QBitmap(QSize) constructor
There is no reason why the QBitmap(int w,int h) constructor is not
deprecated, and the one taking a QSize is. Since there's no deprecation
marker in the source code, I'm assuming this is just a documentation
issue.

Amends 111115bf8862b7cd1197c2ef8a4b475c882776d4.

Change-Id: I700de1821ab23ce85e793734c7048d1b2031ce9d
Pick-to: 6.9 6.8 6.5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-08 04:05:22 +01:00
Axel Spoerl
31e1a79120 QtGuiTest namespace: Export symbols
Export functions in the namespace explicitly, to enable usage outside
Qt.

Pick-to: 6.9
Change-Id: I1d3ea8f043b83cc38a9c6f4ff372e7bb37f2b0cc
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-08 04:05:22 +01:00
Volker Hilsheimer
e91a17873e JNI: replace va_arg helper with variadic template
Android 15 (at least) seems to have changed how float arguments are
passed to native functions, breaking our (conceptually correct) code for
processing the va_arg list into a list of static argument types of the
function implementation.

To fix this, we have to move away from using a va_arg function, and
register a function with statically typed arguments instead.

Use a template function that we instantiate with variadic arguments
deduced from the actual function, using a factory-helper that generates
a JNINativeMethod struct with that template instantiation as the
function pointer. Move all of that into a struct where we can also
declare the signature string as compile-time constant without cluttering
the namespace with static objects.

We can now remove the helpers that took care of type promotion in va_arg
functions, and of the tuple-construction from a va_list.

As a drive-by, don't cast function pointers to void *; it's strictly
speaking undefined behavior in C and should have generated a compiler
warning, if not a hard error [1]. We must initialize the
JNINativeMethod::fnPtr member with the address of the function pointer
instead.

[1] https://port70.net/~nsz/c/c11/n1570.html#6.3.2.3p8

Also, declare the native method as the JNICALL calling convention. That
is only defined on Windows, so makes no difference in practice, but it's
the correct thing to do anyway.

Fixes: QTBUG-132410
Pick-to: 6.9 6.8
Change-Id: I190b95fcbcd07cf99c6765fa426c3c351f91994a
Reviewed-by: Volker Krause <vkrause@kde.org>
2025-01-08 04:05:22 +01:00
Volker Krause
749367da8c Expand tst_qjniobject to cover float arguments in JNI native methods
Demonstrates the problem described in the bug report on Android
15/x86_64. QEXPECT_FAIL the relevant test cases until the next
commit fixes the problem.

Task-number: QTBUG-132410
Pick-to: 6.9 6.8
Change-Id: I065fd29282ef42ed75a2ed8177ded183c92aa6e3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-08 03:05:21 +00:00
Volker Hilsheimer
fe6222b756 JNI: fix JNI warning from local reference mixup
When making an object array, we use a LocalFrame to get access to the
conversion routine, but manage the frame of local references manually in
chunks of 100 objects. If any of the conversion routines uses the
LocalFrame's implicit frame management, then we push and pop frames out
of order.

Disable the frame's implicit frame management, and only use our chunk
management.

Amends 37638c84efaf2810ad49da0b987f19287d8c4ad6.

Pick-to: 6.9 6.8
Change-Id: I93be77ffc8750bb90fd7daed8c273169b03a29e4
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-08 04:05:21 +01:00
Thiago Macieira
403a47cfd5 QStandardPaths: use qTokenizer
Avoids allocating memory for the array.

Pick-to: 6.9
Change-Id: I425235b948609e5f0ffcfffd0f93375a224e5bcb
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-07 18:34:30 -03:00
Thiago Macieira
4fa44a70bc qErrnoWarning: disable when QT_NO_WARNING_OUTPUT is set
Change-Id: Ife98ce915b4bd3edd017fffd18c8bb775381e6f4
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-07 18:34:27 -03:00
Thiago Macieira
e04f109456 QMessagePattern: "precompile" the default pattern
So we don't have to parse it on first use if it isn't set. This should
be a small performance gain for everyone who uses the default, which is
usually the majority of people.

Pick-to: 6.9
Change-Id: I10c471715457dcfa3a1dfffd2768ce605e4f7e30
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-07 18:34:27 -03:00
Thiago Macieira
f4ff7c4058 tst_QSaveFile: add a test for attempting to overwrite a dir
This is not the same as the 'directory' test below, which tests that we
can't open() a QSaveFile on something that already is a directory. For
this one, the target file did not exist when we open()ed, but has become
a directory since then.

Pick-to: 6.9
Change-Id: I92d13f103693d375e742fffdd74053dd1b86d81f
Reviewed-by: David Faure <david.faure@kdab.com>
2025-01-07 18:34:22 -03:00
Shawn Rutledge
9d6614d74c doc: Fix description of QSizeF::fromCGSize
Change-Id: I22c3c5a50d624dc1f6a46aa5f1630c08267c4925
Pick-to: 5.15 6.5 6.8 6.9
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2025-01-07 21:30:34 +00:00
Cristian Le
9f805b5bf7 Fixup: Add *_check build targets for auto cmake tests
- `PARSE_ARGV` should have been 1.
- `module_includes` target needs to be unique
  See gerrit comment of previous change, and
https://gitlab.kitware.com/cmake/cmake/-/issues/26580

Amends: 8f2f4ad4688df4963982c489c80b84e115cda29d

Pick-to: 6.8 6.9
Task-number: QTBUG-98640
Change-Id: I82b85813f282ba1d5b4c938e59558e32647d4d86
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-07 18:44:19 +01:00
Assam Boudjelthia
1fb369211e Android: add android test runner docs to the build
Amends 5735d7ac861fe99a71d8044977e5f487c401ca12.

Pick-to: 6.9 6.8
Task-number: QTBUG-84330
Change-Id: Ie78f88cf84376c08e44d887b09d116845882788b
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2025-01-07 17:26:38 +00:00
Assam Boudjelthia
f342f27a0c Android: fix warnings about Class raw type usage
Using Class<?> fixes the warning.

Pick-to: 6.9 6.8
Change-Id: Ia65aa78509c41d041970631dc21c8dd72459e674
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2025-01-07 19:26:28 +02:00
Assam Boudjelthia
d7860d445d Android: pass safe area margins to relevant windows only
Instead of passing the safe area margins to all windows
or top windows, we can instead call the listener for
setOnApplyWindowInsetsListener() on specific QtWindow
and have it pass the windowId with the callback to C++.
What was missing before was that the listner was not reset
after removing the window and also, we don't need to
necessarily require a window matching the id to be found,
so that if no window is found we can assume that the callback
is not valid.

Task-number: QTBUG-131519
Pick-to: 6.9
Change-Id: Idd411e407ac8f5992aa6684ece70329198de1bc2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-07 19:26:24 +02:00
Jøger Hansegård
30ae70a110 Implement QUniqueHandle move assignment using MOVE_AND_SWAP macro
This removes boilerplate and the extra complication of std::addressof.

Task-number: QTBUG-132507
Pick-to: 6.8 6.9
Change-Id: I07091ec0ac526975cf55361a9811fad77eb152c2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-07 18:23:01 +01:00
Jøger Hansegård
49f1877bbb Require that the handle type used with QUniqueHandle is quite noexcept
QUniqueHandle is intended for handle types or opaque pointers that are
no-throw constructible, copyable, and assignable, and has nothrow
comparison and relation operators. This patch ensures that this holds
true, and makes most of the QUniqueHandle noexcept specifiers valid.

This will make it easier to implement the comparison and relation
operators in terms of the Qt comparison framework.

Task-number: QTBUG-132507
Pick-to: 6.8 6.9
Change-Id: Id9fc3fac72a2337541e49c3b4613b8fd082796af
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-07 18:22:59 +01:00
Mårten Nordheim
57f44d6d88 QHttp2Connection: Fix handling of MAX_HEADER_TABLE_SIZE setting
We need to, following the RFC, send a Dynamic Table Size Update using
HPack once we have acknowledged the setting as long as the new size is
smaller, or if we decide to use the new, larger size.

It's further complicated by the fact that we need to send this update on
the next 'field block' (anything with headers in it), and we may have
multiple SETTING frames come in, and we need to then acknowledge the
_smallest_ one as well as the _final_ one. This is so the decoder on the
peer's side can know that we have set the smallest size, and trimmed our
tables thusly, before going to the larger size.

This could, for example, be used to clear the table.

Task-number: QTBUG-132277
Pick-to: 6.9 6.8
Change-Id: I2b886e125f2c197bc3d42aa0b2bbd308ed2a687c
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2025-01-07 18:16:59 +01:00
Nicolas Fella
1b05fba9ac QWSI: Use floating point number for tablet tilt
On some platforms (like Wayland and X11) we get non-integer values,
and the QTabletEvent API also exposes it as qreal.

However the QWSI API uses int, resulting in potential loss of
information

Task-number: QTBUG-8059
Change-Id: I9d2856a053091415c6f9e886fdd87ed71254fdd2
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-07 17:08:48 +00:00
Thiago Macieira
1da7558bfd QThread/Unix: revert to pthread destruction instead of thread_local
Amends 65093a84c2b94b1543fd4593bc45d491951d28d4, which changed how we
destroyed the main thread's QThreadData. This merges the call to
destroy_current_thread_data() for both types of Unix systems: those with
broken thread_local destructors and those with working ones. It turns
out that the function got called too early for us in those working
systems (see updated comment).

The clean up of the QThreadData is split into two different mechanisms:
 * for any auxiliary thread, when it exits, PThread will call back to
   destroy_current_thread_data()
 * for the thread that called ::exit(), PThread won't, but ::exit() will
   invoke set_thread_data()::TlsKey's destructor

This is different from the situation that existed prior to commit
65093a84c2b94b1543fd4593bc45d491951d28d4: first, there's no code in
qcoreapplication.cpp for this (all in qthread_unix.cpp). Second one may
call ::exit() from any thread, whether that is the thread that called
main(), the thread Qt thinks is theMainThread, or any other.

This commit moves the tst_QCoreApplication check for no extant objects
to a new test. I've chosen to add a new test instead of running a helper
binary via QProcess because we do have a couple of !QT_CONFIG(process)
platforms in the CI, and this is too important.

Credit to OSS-Fuzz for finding this, though it is not itself a fuzzying
problem (all tests of a given structure were crashing on exit).

Fixes: QTBUG-132381
Task-number: QTBUG-130895
Task-number: QTBUG-129927
Task-number: QTBUG-129846
Task-number: QTBUG-130341
Task-number: QTBUG-117996
Pick-to: 6.9 6.8
Change-Id: Ie294dce7263b4189f89ffffd9155ec71d31b89d9
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2025-01-06 17:48:27 -03:00
Thiago Macieira
357351b7ab Revert "Add categorized logging of delete later machinery"
This reverts commit c3a2b9f35a9a12ff3c6f5f0d11844de161b47c2a.

Unfortunately, some of the log messages happen WAY too late at process
exit time, when QtCore is unloading. In particular, the worst offender
is the one in QThreadPrivate::finish(), which is called after the last
QObject in the thread that called ::exit() was getting destroyed. This
implies we have Static (De)Initialization Order Fiascos happening (the
logging recurses into qlocale.cpp and the defaultLocalePrivate global
static has already been destroyed).

I need to revert this commit in order to fix QThreadData destruction.
The functionality is welcome back in QtCore once the fixes are in, so
long as whoever does it fixes the issues we're seeing in the CI (and I
can't reproduce on my development machine). I've created QTBUG-132429 to
track the reversal and see if the functionality can be brought back in.

Task-number: QTBUG-120124
Task-number: QTBUG-132429
Pick-to: 6.9 6.8
Change-Id: Iecf8f14529c7a2bb2185fffdfd328066098826b1
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-06 17:48:27 -03:00
Christian Ehrlicher
314a5b9726 Windows11 style: fix drawing horizontal progressbar in rtl mode
The progressbar content calculation assumes that
subElementRect(SE_ProgressBarContents) returns a rect at 0/0 which is
not the case for progressbars in rtl mode. Fix it by moving the topLeft
edge to 0/0 and translating the painter accordingly

Pick-to: 6.9 6.8
Task-number: QTBUG-132459
Change-Id: I614589c9094b0da3c02867b45570d4dfdca61a18
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2025-01-06 20:38:38 +01:00
Christian Ehrlicher
85333b3d8c Windows11Style: enable mouse tracking for QTableView
Mouse tracking is needed for windows 11 style since it is using
QStyle::State_MouseOver to draw the cells.

Pick-to: 6.9 6.8
Fixes: QTBUG-129242
Change-Id: Ib79ac5a8c14ac8c70365e87120f80b4e4ee4c5b9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2025-01-06 20:38:38 +01:00
Volker Hilsheimer
db6a9834d2 JNI: don't access null jobject
When Java calls a native function that expects a QString with a null
String object, then we get a nullptr jstring. We must not try to convert
that to a QString.

Add the necessary checks at the call-site of the toQString helper, and
an assert to the helper itself. Add test case.

Pick-to: 6.9
Change-Id: If5c55c702bdb3f89ac45fdf3912af2ac295f5e5c
Reviewed-by: Volker Krause <vkrause@kde.org>
2025-01-06 20:38:38 +01:00
David Faure
0e2656f937 Fix wrong value for 'noon' in tst_bench_qdatetime
12 hours corresponds to 43,200 seconds, not 43,200 milliseconds.
Amends commit 3febcd6286a3cd22db4f294e7f31a94c07c51fb0

Pick-to: 6.9 6.8 6.5
Change-Id: I2eb3abcab18cd87d51ae70b5fbaeac71a8fcd0a8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-01-06 19:33:10 +00:00
Tor Arne Vestbø
d74079873b Add change-notification signal to QInputDevice::capabilities property
On some platforms the capabilities of a device can change at runtime,
and we don't want to model this as a "new device" appearing in place
of the old one.

We already made the capabilities property non-CONSTANT, but let's add
a NOTIFY as well for completeness.

I considered making the capabilities member protected, but
QXcbConnection's xi2 handling relies on modifying the caps
as part of creating the device.

Fixes: QTBUG-132281
Pick-to: 6.9
Change-Id: Ic345475b179f4562cdd39ecf51c7d6738ad47a74
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2025-01-06 20:33:10 +01:00
Marc Mutz
9dadca4d4e CompactContinuation: make type member const
Because it can be.

Helps readers understand that the type of a continuation doesn't
change once constructed.

Amends 699162c6fa6121cc496338f1d8d6e1b4287f7760.

Pick-to: 6.9
Change-Id: I43848204cfd8584e6e55d7fbca1b22d30b391e50
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-01-06 19:41:03 +01:00
Marc Mutz
21811161c9 CompactContinuation: make sure what is being deleted by runObj
A lambda creates a struct with a function-call operator. So use of
'this' in a lambda body is always a bit ambiguous (the outer object?
Or the lambda itself? even though C++ defines it unabiguously to the
former).

Use a named capture variable instead of 'this' to make it obvious what
is being deleted.

Amends 699162c6fa6121cc496338f1d8d6e1b4287f7760.

Pick-to: 6.9
Change-Id: I48d82d788d495bac43c6adb114dfdd95a8dd0d1f
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2025-01-06 19:41:03 +01:00
Mårten Nordheim
f7c3acd27f tst_Http2: Test SETTINGS_HEADER_TABLE_SIZE handling
This somewhat duplicates some other tests, namely the QHttp2Connection
one, but tst_http2 is our only coverage of the HTTP/2 code prior to 6.8.

This change adds a test where the server sets the
SETTINGS_HEADER_TABLE_SIZE to 0, effectively disabling the dynamic
table. We, in an earlier patch, makes the HPack table error out if
a new header entry is about to be added if the table has not been
resized below a changed 'max'. So, we take advantage of that here and
set the new 'max' capacity without resizing the table, or updating
dynamic capacity causing it to fail if the client doesn't send the
expected Dynamic Table Size Update.

Task-number: QTBUG-132277
Pick-to: 6.9 6.8 6.5
Change-Id: I1ca8ca7828d5b83606e7adbcfc13c154fa1e3cab
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2025-01-06 19:41:03 +01:00
Mårten Nordheim
be477819ac HPack: test and fix Dynamic Table Size Update
Expose some new API to make it easier to test too.
Will be used in follow-up patches for a http2 bugfix.

The setMaxDynamicTableSize() method no longer sets capacity or evicts
entries. This can then be used to set the new maximum size which we will
accept later when we receive a Dynamic Table Size Update.

This flow makes sense with both encoder and decoder. The decoder would
usually be set by us when we send our SETTINGS frame, and then the
Dynamic Table Size Update would be sent by the peer.
For the encoder we would set the maximum size when we receive the
SETTINGS frame, and then we must defer the actual resizing until we
can send the Dynamic Table Size Update ourselves, usually along with the
next HEADERS frame.

Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-132277
Change-Id: I959f5006eb09427d130735efe136da8c04453fa2
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2025-01-06 18:56:19 +01:00
Friedemann Kleint
8778a49360 Mime type browser example: Add translator loader code
Enable testing translations.

Task-number: QTBUG-127004
Pick-to: 6.9 6.8
Change-Id: Ie83092b4db5bcf516834cf0b5b564a67d7ab6227
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-06 18:56:19 +01:00
Mate Barany
e316276b76 Update CLDR to v46
New languages added with v46
- Kara-Kalpak
- Swampy Cree

Several new Chinese-language locales have been added, including one
using Latin script, which invalidated some prior QLocale tests, which
have been adjusted to fit.

Some obsolete time-zone identifiers are now treated as deprecated
aliases. These have lost their AnyTerritory association, implying
changes to QTimeZone tests.

Many redundant likely sub-tag rules for unspecified language have been
dropped, in favor of simpler rules.

[ChangeLog][Third-Party Code] Updated CLDR data, used by QLocale, to
v46.

Task-number: QTBUG-130877
Pick-to: 6.9 6.8
Change-Id: I92cf210422c7759dd829a7ca2f845d20e263d25b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2025-01-06 18:56:19 +01:00
Frédéric Lefebvre
dca3467993 Remove tst_manual_qsslsocket manual test as irrelevant
Tests several sockets, similar tests are done in the auto-test
tst_qsslsocket.

Behaves like an auto-test. Irrelevant to be kept as an individual
manual test.

Change-Id: I53b32463da2f2f8a8a0a13be542420a528a6895a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2025-01-06 17:58:59 +01:00
Marc Mutz
9bb48c315c QWaylandClientExtensionTemplate: reflow qWarning() in bind()
As suggested in 6.9 API-review, reflow the long line and put the
interface.name onto a separate line in the log output.

Amends 8784a01787f72bfea7124ecb2b896ebf644d1824.

Pick-to: 6.9
Change-Id: I12f00b65d7b22ac9330b25faca28edaa7a159a3a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2025-01-06 15:43:14 +01:00
Jan Moeller
279c891ddf Check for valid QAccessibleInterface before invoking action
To avoid illegal access, the change ensures that the QAccessibleInterface
is non-null and valid before accessing its QAccessibleActionInterface.

The check for the validity was also added to existing code which
previously only checked for the QAccessibleInterface not being null.

Fixes: QTBUG-132059
Pick-to: 6.8 6.9
Change-Id: I69fc4f9bb052ded8f188032d324666d0c00b9c3c
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-by: Lars Schmertmann <lars.schmertmann@governikus.de>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-06 15:33:04 +01:00
Richard Moe Gustavsen
42f29da7a5 iOS: remove registered undo/redo actions upon qiostextresponder dealloc
QIOSTextResponder add actions to its own NSUndoManager. But
we need to remove those actions again when the responder is
deallocated, otherwise it can lead to a crash in UIKit when
swiping between apps.

Fixes: QTBUG-123843
Pick-to: 6.9 6.8 6.5 6.2
Change-Id: I404751bc50692a960e568ff2eb0f1754da0cec31
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-06 15:33:04 +01:00
Morteza Jamshidi
fd7bc16e9f Draw icon overlay manually instead of relying on the api
Even with SHGSI_LINKOVERLAY flag set, loaded Icon with
SHDefExtractIcon doesn't have any overlay, so we draw
it manually.

Pick-to: 6.9 6.8
Fixes: QTBUG-131843
Change-Id: Iae4c2da12104a361b9a8cf05c78adcdb698f1f82
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2025-01-06 15:33:04 +01:00
Cristian Le
8f2f4ad468 Add *_check build targets for auto cmake tests
Similar `*_check` targets are created in `qt_internal_add_test`.
This change extends that implementation to auto cmake tests.

Note: These generated targets do not have additional dependencies, on
the build targets, unlike those generated by `qt_internal_add_test`.
You would need to (re-)run the build first separately and then run the
`*_check` target.

Fixes: QTBUG-98640
Pick-to: 6.8 6.9
Change-Id: I387f09570b6a4a345756133870c2eb9ef1cf3cf8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-06 15:25:15 +01:00
Morteza Jamshidi
4d9f99c4ea Windows: Add Key_Backtab as possible key combination for Shift+Tab
In windows Backtab key event always comes as "Shift+Backtab".
So in order for Backtab key to be recognized as a shortcut sequence,
we also consider Backtab without shift modifier a possibility.

Fixes: QTBUG-94890
Change-Id: I20a7b404b57d8df5bea23765257a178f2e098ed0
Pick-to: 6.8
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2025-01-06 14:25:15 +00:00
Alexandru Croitor
f2ce68d8f3 CMake: Handle DESTDIR for SBOM doc references in top-level builds
When installing a top-level build using the DESTDIR env var mechanism,
the SBOM generation process could not find the qtbase sbom document,
while generating the qtshadertools document.

Make sure to prepend the DESTDIR env var to the install-time install
prefix, when looking for external SBOM documents.

Pick-to: 6.8 6.9
Fixes: QTBUG-132188
Change-Id: I1cdb75842fc552b43d982f05444b5ddc1fe58595
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-01-06 10:49:07 +01:00
Ivan Solovev
f73765682e QtConcurrent: fix support for callables with deduced return type
Commit 6ebe3d0f0806069f906522dfe9b81baa3f3478de introduced extra
SFINAE checks on the template conditions.
However, it broke the case of using callables with deduced return
type, because SFINAE does not work for such conditions and treated
as a hard error instead.

Fix by explicitly providing all template parameters, so that compiler
could figure a better overload on its own.

Only QtConcurrent::blockingMapped() seems to be affected, but add
unit-tests to check all other methods as well.

Fixes: QTBUG-130766
Pick-to: 6.9 6.8 6.5
Change-Id: I1ddbe712d8ce04ac96ba13841cb569d728cfb943
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
2025-01-06 10:48:34 +01:00
Jøger Hansegård
a80d1bf271 Add missing noexcept specifiers for QUniqueHandle handle traits
Handle traits should be simple, and not require exceptions. Note that
we should not make calls to fclose() or close() noexcept, because these
are POSIX cancellation points.

Pick-to: 6.8 6.9
Change-Id: I8bbf573b1346eafd52c6080dbb024f8b3bc89359
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-06 10:47:32 +01:00
Kaloyan Chehlarski
652250295c Fixup minimum MSVC version check when configuring Qt
The message displayed to the user says they need "at least Visual Studio
2019", but in reality the minimum is now 2022.

Amends 9a409295c7cfe74b4fb6b1892f4ff86d4f3c23f3

Pick-to: 6.9 6.8
Change-Id: Idaedd72d114b994fddd2ba7574fb7a45ca0a3e85
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-06 09:28:41 +00:00
Juha Vuolle
f9376703c9 Rename Gui test utility's factor() to scaleFactor()
This makes it more clear which 'factor' the function is about.
The function internally calls a pre-existing 'factor()' function,
but since that is a static method of QHighDpiScaling, there the
meaning of 'factor' is more clear from the call context:
QHighDpiScaling::factor(window).

Resulted from API review.

Amends: 5ac4f04325a56d47812f528fe31ceb0d4932f664

Pick-to: 6.9
Task-number: QTBUG-132090
Change-Id: I869bc05116d334b53b23a46aa2bb788432f250de
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2025-01-05 15:16:46 +02:00
Jøger Hansegård
3c57c73574 Add missing noexcept specifiers for QUniqueHandle handle traits
Handle traits should be simple, and not require exceptions. This patch
will allow us to improve the noexcept correctness of QUniqueHandle.

Pick-to: 6.8 6.9
Change-Id: I84d92818a2fcea5b98e09c0b7dc08b251751396c
Reviewed-by: Tim Blechmann <tim.blechmann@qt.io>
2025-01-04 19:46:39 +01:00
Jøger Hansegård
03bd949149 Test that reset() and move assignment handles self-assignment
Calling reset() with the owned handle should maintain ownership and not
leak resources. Move assignment should also handle self-assignment
without leaks. The new tests verifies that this holds true.

Task-number: QTBUG-132507
Pick-to: 6.8 6.9
Change-Id: Icdfa4d67b06b71a74e810593e57449b51982c98c
Reviewed-by: Tim Blechmann <tim.blechmann@qt.io>
2025-01-04 18:52:59 +01:00
Lars Schmertmann
9903242eca Android: Fix freeze on start when the activity was destroyed before
This can be tested by enabling "Don't keep activities" in the developer
options. With this option Android will immediately destroy the activity
when it is moved to the background. In this case registerBackends will
be called the first time before the BackendRegister was created. Because
m_backendsRegistered was set to true even if it failed, the final call has
no effect. So we need to ensure to set m_backendsRegistered only if a
BackendRegister is available.

Fixes: QTBUG-132085
Pick-to: 6.9 6.8
Change-Id: I2ea1c0e0737c982594ceb06cbaf540399c45e3f4
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2025-01-04 15:47:29 +01:00
Ahmad Samir
3928d53003 tst_QQuaternion: compile with QT_NO_FOREACH
The size of the container is fixed, so use std::array.

QQuaternion is basically four floats, so make the range-for var a value
rather than a reference.

Task-number: QTBUG-115839
Change-Id: I50b5aaa7daa6a4f10ff55c55ae54259c9aea03e9
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-03 21:48:50 +02:00
Alexandru Croitor
a13bfec63d CMake: Error out when xcode / SDK version check fail in Qt 6.8+
Starting with Qt 6.8+ we should error out if the minimum sdk / Xcode
version requirements are not met.

An opt out is added for cmake build tests, otherwise all the tests
that use private cmake api will fail to configure when run on older
Xcode or SDK versions in the CI.
We do this by checking for a new QT_INTERNAL_IS_CMAKE_BUILD_TEST
variable.
We do the check inside
_qt_internal_check_apple_sdk_and_xcode_versions
instead of passing
a QT_FORCE_WARN_APPLE_SDK_AND_XCODE_CHECK variable to the test
configuration, because not all cmake build tests use private api, so
this way the list of projects that get the opt out is more
constrained.

Pick-to: 6.8 6.9
Task-number: QTBUG-119490
Change-Id: I1284616c91341848a9cf6406fbf35750707d1227
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-01-03 17:05:37 +01:00
Jøger Hansegård
ec0c62385e Implement QUniqueHandle::release() using std::exchange
This does not change the behavior of release() but gives more
compact code.

Task-number: QTBUG-132507
Pick-to: 6.8 6.9
Change-Id: I5b34c80409ca0e9e9a5e9aee9ef7bc80017610af
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-03 16:05:37 +00:00
Jøger Hansegård
248ac4128f Make QUniqueHandle::reset() default to invalid handle
Having a defaulted argument to QUniqueHandle::reset() gives a convenient
way of releasing ownership without assigning a new handle, and makes
the QUniqueHandle API more similar to std::unique_ptr.

Task-number: QTBUG-132507
Pick-to: 6.8 6.9
Change-Id: I842d4545d7cc2da8fe2df08280d0d816ed4be7fd
Reviewed-by: Tim Blechmann <tim.blechmann@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-03 17:05:37 +01:00
Alexey Edelev
035fbd068b Adopt the Qt dependencies lookup mechanism for tools dependencies
The existing lookup mechanism doesn't consider Qt path when looking for
the Qt Tool package dependencies. In good scenario this leads to the
missing Qt Tool package, in worst case scenario the Tool package could
be found by alternative search path and attempt using the invalid
tools.

Use the lookup functionality we have for Qt modules when looking for
dependencies of the Qt tools. This will look the tools in Qt search
paths first and only then attempt looking elsewhere, considering the
QT_HOST_PATH.

Pick-to: 6.5 6.8 6.9
Fixes: QTBUG-132340
Change-Id: I570c03037f2a92922d2546a4f5fde1bc17a7f812
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-03 16:59:19 +01:00
Alexey Edelev
96bb0db5af Unset the temporary variables in Dependencies scripts
Unset the temporary variables to avoid littering the scope.

Pick-to: 6.8 6.9
Change-Id: Ibd6b2896113a9fcd9eae7bc202dc0dc8c7a9f9bd
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-03 16:59:19 +01:00
Alexey Edelev
1360824179 Assume that the Qt Plugin package is FOUND by default
Set the <package>_FOUND variable to TRUE by default, so the follow
logic that need to change the flag only need to take care about
setting it to FALSE if something exceptional occurred.

Amends 8d0283ad2cae3d8fbd4b1b7ee5c6454f7fcc079c

Pick-to: 6.5 6.8 6.9
Change-Id: Idd4407ea77e81703b5fa8cc5efa8c52b53d401ae
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-03 16:59:19 +01:00
Alexey Edelev
10a3859809 Use the 'call' command when generating the command scripts
cmd.exe has a huge problem when running the batch scripts locating
by paths contaning spaces and more the one set of quotes in arguments.
This can be worked around by using the 'call' command as the test
command runner.

Fixes: QTBUG-132258
Pick-to: 6.5 6.8 6.9
Change-Id: I9b6fb0f8bccf44456e4cb9b79f3c6bd3f9fe4678
Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-03 16:59:19 +01:00
Marc Mutz
be8391e56d QRhiWidget: mark (Private&, parent, flags) ctor explicit
Found in API-review.

Amends 8386dfee05d35057836f93d182ef96674a6fd11e.

Pick-to: 6.9
Change-Id: I5ad063b17356f75084655f1af353ba34a5deb4bf
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-03 15:15:57 +01:00
Ahmad Samir
fc6339e4bb tst_QArrayData: compile with QT_NO_FOREACH
The container is a member of Deallocator class, it's iterated over in
the destructor to free allocated resources, and it's not being changed
during iteration >>> ranged-for and std::as_const.

Task-number: QTBUG-115839
Change-Id: I54eb115013805284c77691f1bd0a8d6085a4c867
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-03 14:55:06 +03:00
Ahmad Samir
5d336dad4b GTK3 platformtheme: port from Q_FOREACH to ranged-for
setNameFilters(): the container parameter referes to a local const
conatiner at the call site.

The other two loops are straightforward ports, iterating over local
const containers.

Task-number: QTBUG-115796
Change-Id: I42a89af311b75e98c75f955f9a706a4b29cad5e3
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-03 14:55:06 +03:00
Ahmad Samir
78119026c0 tst_Gestures: port Q_FOREACH to ranged-for
Straightforward ports, the loops were iterating over temporaries, so
store the container in a const auto variable.

Task-number: QTBUG-115839
Change-Id: I2960a566987bf553a4d57a73d6804ea019b41860
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-03 13:57:24 +03:00
Ahmad Samir
25fcb413cf tst_QTextLayout: compile with QT_NO_FOREACH
The container is local, and it's not changed in the loop body; port to
ranged-for and use std::as_const.

Task-number: QTBUG-115839
Change-Id: If4d46f55e7aae8c87f6d7b3c4e78da7e51e128c0
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-03 13:57:23 +03:00
Ahmad Samir
56d2a65a33 tst_QFont: compile with QT_NO_FOREACH
Loops are iterating over newly-made const containers.

msgNotAcceptableFont(): the container to which the const& parameter
refers is also const.

Port to ranged-for.

Task-number: QTBUG-115839
Change-Id: Idc319026900b77075d7d4afd7184665c734f4c9e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-03 10:57:23 +00:00
Ahmad Samir
688905fc9d tst_QLockFile: compile with QT_NO_FOREACH
The loop was iterating over a temporary, so it couldn't have changed it.
Hold it in a const auto variable and port to ranged-for.

Task-number: QTBUG-115839
Change-Id: I03123d2601af87155daef2590dbcb29c8aa0dc7b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-03 13:57:23 +03:00
Ahmad Samir
a1a8e0bb38 tst_QtBench: compile with QT_NO_FOREACH
The container is a member of the unittest, it's not changed by the loop
body or during iteration, so use a ranged-for and std::as_const.

Task-number: QTBUG-115839
Change-Id: I1be75d17ff305bc542cf7b058cc59d70cedc77ad
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-03 13:57:23 +03:00
Ahmad Samir
b5e4657307 tst_bench_qpainter: compile with QT_NO_FOREACH
Use C arrays for data known at compile time.

Drive-by change: verify the two containers that are iterated in tandem
have the same size.

Task-number: QTBUG-115839
Change-Id: I457ddca8aa98e2f15a833a40ff45bd208701bf6b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-03 13:57:23 +03:00
Alexei Cazacov
ae3d9aa081 Fix the module documentation structure for Qt Wayland Client
Fixes: QTBUG-132274
Pick-to: 6.9
Change-Id: Ibaa47274757a6bc22260f703becc69c4c0d5b702
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2025-01-03 11:34:07 +02:00
Marc Mutz
7bd47fb708 qpropertytesthelper_p.h: port from QScopedPointer to std::optional
It's more efficient (doesn't need to allocate the QSignalSpies on the
heap) and makes the header fit for the upcoming QT_NO_SCOPED_POINTER.

VxWorks seems to have a problem with its std::optional implementation,
though:

   QWARN  : tst_QAbstractAnimation::stateBinding() Trying to construct an instance of an invalid type, type id: -2125884168
   QWARN  : tst_QAbstractAnimation::stateBinding() Trying to construct an instance of an invalid type, type id: -2125884172
   QWARN  : tst_QAbstractAnimation::stateBinding() Trying to construct an instance of an invalid type, type id: -2125884024
   Received signal 11 (SIGSEGV), code 2, for address 0x0000000d

So write a small optional-like wrapper around std::unique_ptr for that
platform.

Amends 930e59b798d9e3d08e17440980d33a08fb411cbe.

Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-132213
Change-Id: Icf85678d616bc96c7d74b982d0b919ea3f13265a
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-03 08:26:22 +01:00
Alexey Edelev
ccbec262c2 Fix restoring of CMake environment in _qt_internal_execute_proccess_in_qt_env
Use the correct variable name when restoring the environment.

Amends e388c1caeb1ccdb88b9a9801be9cd6328d8a7987

Task-number: QTBUG-128420
Pick-to: 6.5 6.8 6.9
Change-Id: I03ee3481a4638969edd75ce6ad233e8a94d5c563
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-02 22:25:47 +01:00
Thiago Macieira
e18b005933 QLogging: switch the systemd/journald sink to unformatted mode
The extra information is already stored in the journal metadata anyway,
so there's no need to duplicate it. This matches the Apple Unified
Logger output now.

For most people, the visible difference will be that the category name
is not included in the plain "journalctl" output.

 Aug 22 21:25:43 tjmaciei-mobl5 akonadi_imap_resource[4948]: org.kde.pim.kimap: Connection to server lost  QAbstractSocket::HostNotFoundError
 Aug 22 21:27:17 tjmaciei-mobl5 kwin_x11[3376]: kwin_core: XCB error: 3 (BadWindow), sequence: 41165, resource id: 29363347, major code: 129 (SHAPE), minor code:>

journalctl does not make it easy to show extra fields, but it's there
and can be retrieved with -o verbose.

[ChangeLog][QtCore][Logging] The Qt logging framework (qDebug/qWarning/etc)
will now only send the plain, unformatted message to systemd's journald,
if this backend is enabled. The category and other fields are sent via
metadata to journald, so they can be filtered on and retrieved using
journalctl. This matches what Qt does for the Apple Logging support and
does not apply when Qt is using syslog or stderr to communicate with
journald.

Change-Id: Ifa1111900d6945ea8e05fffd177de8f47d74ba60
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2025-01-02 17:23:31 -03:00
Shawn Rutledge
48b1af941c Fix QTransform::quadToQuad() to work with QRectF
A typical usage for mapping a 4-point polygon to a rectangle might be

  QTransform transform;
  bool ok = QTransform::quadToQuad(polygon, polygon->boundingRect(),
                                   transform);

It works because the QPolygonF(QRectF) ctor is implicitly called on
the second argument; but that ctor turns it into a 5-point polygon.
So it should be legal for QTransform functions to work with 5-point
closed paths.

Fixes: QTBUG-21329
Change-Id: Iae249012e14b8a3e8d3b0dfa35da8f9759359832
Pick-to: 5.15 6.5 6.8 6.9
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-01-02 20:39:06 +01:00
Alexandru Croitor
dcd057a31b Revert "CMake: Temporarily allow using any version in Qt's CI"
We updated the minimum CMake version used in CI for Qt 6.9+ to 3.22.
Enforce the minimum CMake version in CI to avoid regressions.

This reverts commit 5803af38aab09b7e47230a494e14654031d024e7.

Pick-to: 6.9
Task-number: QTBUG-131169
Change-Id: Ifc91644dd26e465be44bfa7cfe6f99e295a174a9
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-01-02 19:12:51 +01:00
Aurélien Brooke
73405890b8 rhi: vulkan: fix crash when making readbacks in consecutive frames
When requesting a readback every frame, the readback activeFrameSlot
alternates between 0 and 1. Suppose we are in currentFrame 1, and
process a list of readbacks of slots [1, 0]. First, we skip the readback
of slot 0 since it does not match the currentFrame 1. The list thus
remains [1, 0]. Then, we process the readback of slot 1, and call
activeTextureReadbacks.removeLast(). This removes the readback of slot
0, while in reality we processed the readback of slot 1. The
activeTextureReadbacks is now [1], containing a readback for which we
called vmaDestroyBuffer(), leading to a crash ("double-free" attempt) in
Vulkan on the next function call.

To fix this, remove the readback that is actually processed (index i)
instead of the last one. Since we iterate backwards, indices remain
valid.

Pick-to: 6.8 6.9
Change-Id: Idd4296de45167edd0a9da345dcc1c3b6ac71a6d6
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-01-02 19:12:51 +01:00
Ulf Hermann
2f5b46731d Revert "Make dumpObjectTree() and dumpObjectInfo() invokable from QML"
This reverts commit 7de17a91bcc812a64bb3b42570ed9356e759bd5a.

The methods were made invokable to make them accessible from QML.
However, the act of introducing revisions into the root of the class
hierarchy creates undue overhead for QML since now every module that
registers types has to account for the possibility of different
revisions of QObject being exposed by different modules. Therefore,
every module that registers types derived from QObject has to register
their own anonymous revisions of QObject and all intermediate classes.
This is clearly not acceptable for functionality only meant to help with
debugging.

Fixes: QTBUG-132387
Change-Id: I8de0b41f384f3ed8f5ef00c8a76c8ad80b36e98f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-02 18:51:10 +01:00
Michał Łoś
fbd7c7c45a VxWorks: Enable video device discovery
Video devices should be discovered by VxWorks properly.

Pick-to: 6.8 6.9
Task-number: QTBUG-115777
Change-Id: Ib6719fc9480827aed296343e0b91286ae8408c8a
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2025-01-02 18:51:10 +01:00
Marc Mutz
6da1f72311 QThreadStorage: replace QScoped- with std::unique_ptr
This only affects the !QT_CONFIG(thread) case and requires the rewrite
of the old-style static cleanup() deleter protocol into the modern
operator()() one.

As a drive-by, mark the deleter noexcept, like destructors are
supposed to be.

Pick-to: 6.9 6.8
Task-number: QTBUG-132213
Change-Id: I8839865880647d76b77eb9a3f2858067db86234e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-02 18:39:49 +01:00
Marc Mutz
f9163ae7a8 Remove QT_NO_CAST_FROM_ASCII from QT_ENABLE_STRICT_MODE_UP_TO
QT_NO_CAST_FROM_ASCII is a policy setting, not a strictness
setting. The other components of QT_ENABLE_STRICT_MODE_UP_TO all deal
with clearly undesirable APIs, which QString(const char*) cannot be
said to be.

Keeping it in QT_ENABLE_STRICT_MODE_UP_TO would seriously impede the
use of strict mode in Qt itself (cf. QTBUG-132327).

Amends 3a6c8e02b6d1b0574da52b0087092d0c74aa92c1.

[ChangeLog][QtCore][QT_ENABLE_STRICT_MODE_UP_TO] No longer includes
QT_NO_CAST_FROM_ASCII. If you wish to continue using
QT_NO_CAST_FROM_ASCII, you need to define it in addition to
QT_ENABLE_STRICT_MODE_UP_TO. The reason for this change is that, while
everything else in strict mode should eventually become the default,
we're not proposing to remove the ability to construct a QString from
a const char*. QT_NO_CAST_FROM_BYTEARRAY and QT_NO_CAST_TO_ASCII
remain enabled in strict mode, though.

Task-number: QTBUG-132327
Pick-to: 6.9 6.8
Change-Id: I36b850833b1de79a47de975ca28d3591a0a0e089
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-02 15:22:56 +00:00
Giuseppe D'Angelo
08e8446461 Build the manual lance test
It had been excluded from the manual tests with a strange comment in the
CMakeLists.txt -- e0fb295aad0063410aca3b2a109a7cda15628bda already
ported the code away from QGL and to QOpenGL* classes.

Fix a couple of discarded QFile::open usages.

Change-Id: I248dabd706f34305b7120d3aaf36120040afc08c
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2025-01-02 16:22:56 +01:00
Ivan Solovev
5feca3da72 macdeployqt: port to QSaveFile
... to avoid loosing file content in case of write errors.

Change-Id: If3f7af1e7260e3b9c3df201ed869988b0bd6df2a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2025-01-02 15:45:37 +01:00
Tatiana Borisova
5525779b2e QTextStream: use new operator bool() around the code
- After adding the QTextStream::operator bool(), it is not required to
check the QTextStream::status(). It is enough to use the reference
of stream in the statement, which returns true if stream status is OK.
New operator usage makes code more convenient.

Task-number: QTBUG-52189
Change-Id: Id9ecaa8a5c9cf1931dbeefa85f9d948d15379a82
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2025-01-02 15:01:45 +01:00
Ahmad Samir
343cc50c22 QList: add data_ptr() methods like the ones in QString/QBA
It will be used in a suqsequent commit (adding QString::{to,from}Utf32).

Change-Id: Ie113a47f0ff0e9a7b26a6d0f47e17d24a4a88465
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-02 16:00:36 +02:00
Ivan Solovev
8aef5b0d8f Fix QtFuture::when{All,Any}() overload resolution
Both whenAll() and whenAny() have two overloads:
* an overload taking two input iterators, e.g.
  whenAll(IntpuIt begin, InputIt end)
* an overload taking an arbitrary number of future objects, e.g.
  whenAll(Futures &&... futures)

The public APIs are properly constrained, but internally they call
QtPrivate::when*Impl() template functions, that have the same two
overloads, but do not have any constraints.

As a result, passing exactly two QFuture<T>{} objects was leading to
the compiler picking the Impl overload that takes a pair of iterators.

Fix it by applying a subset of constraints from the public API to
the private implementation as well.

Amends 102f7d31c469a546f52c930a047bd294fb198186 which was introduced
for Qt 6.3, so picking down to Qt 6.5.

Fixes: QTBUG-131959
Pick-to: 6.9 6.8 6.5
Change-Id: Ide29ac9a494d07870e92957c40c1f614e56825f8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-01-02 14:58:17 +01:00
Ivan Solovev
3cb87d891b Do not duplicate JsonFormat enum
The enum already exists in QJsonDocument, so there is no reason to
introduce a new one in QJsonValue.

Instead, use the fact that we only need to forward-declare QJsonValue
in QJsonDocument's header, include the latter into qjsonvalue.h, and
use a type alias.

For Qt 7, pre-program moving of the enum into QJsonValue and using
an alias in QJsonDocument.

Amends ac73079dee5f0260528a5c217a82cb0beafb0a56.

Found in Qt 6.9 API review.

[ChangeLog][QtCore][Potentially Source-Incompatible Changes] The
QJsonDocument header no longer includes QJsonValue.
The backward-compatible fix is to include all needed headers
explicitly and to not rely on the transitive includes.

Pick-to: 6.9
Change-Id: I7c5219a239149e4a87d4780c4277d111983ad0f4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-02 13:07:21 +01:00
Joerg Bornemann
fecae6ab1b CMake: Yield error if VCPKG_ROOT variable is missing
...and vcpkg usage was requested.

The user got no further feedback why vcpkg wasn't used despite passing
the -vcpkg configure argument.

Pick-to: 6.8 6.9
Change-Id: Ib43c2045f093c3887a63406e37f37bdd681341cd
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-01-02 11:25:11 +01:00
Marc Mutz
19564e033c sqlbrowser example: use = default on empty dtors
Idiomatic C++11 code.

Amends 2690822428deec4f0c08f4d118d69a7c6036369e, which, however,
inherited the issue from older code.

Pick-to: 6.9 6.8
Change-Id: Iba1fb9874bd93b4a560c33e3ecf62ecaa96d8bda
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-02 07:51:18 +01:00
Marc Mutz
15524d1623 sqlbrowser example: fix ugly margin around ConnectionWidget
When a layout is used to arrange the children of a non-top-level
custom widget, the layout's contentsMargins need to be manually set to
zero to avoid extra empty space around the widgets, misaligning it
w.r.t. its siblings.

Add the necessary call.

Amends 2690822428deec4f0c08f4d118d69a7c6036369e, which, however,
inherited the missing margin adjustment from older code.

Pick-to: 6.9 6.8
Change-Id: Icd1945a4f2b1635f031e50758ec2f1ec9313ae27
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-02 07:51:11 +01:00
Marc Mutz
e0e9a56273 sqlbrowser example: use explicit / override
Examples should show idiomatic use of Qt and C++, so mark the custom
widget constructors in this example as explicit and their destructors
are override.

Amends 2690822428deec4f0c08f4d118d69a7c6036369e, which, however,
inherited the missing explicit from older code.

Pick-to: 6.9 6.8
Change-Id: I5b5b49f69330c6f139345bed7264c85a36c36e9b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-02 06:51:03 +00:00
Marc Mutz
0da2c2c4ef sqlbrowser example: use unique_ptr to hold m_ui
The old code used manual memory mangement (raw new/delete) to
(de)allocate the Ui struct. This is so 80s.

Use an owning smart pointer to manage the memory. Ordinarily, this
would have been QScopedPointer, but seeing as that doesn't have a
create() method to hide the raw new, use std::unique_ptr and
std::make_unique() instead.

Amends 2690822428deec4f0c08f4d118d69a7c6036369e.

Pick-to: 6.9 6.8
Change-Id: Icabb9154eb38630855e14094b958af0214516f6b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-02 07:50:57 +01:00
Marc Mutz
9c099ef942 sqlbrowser example: use idiomatic Qt [3/3]: use form-layout
The old code used a grid layout inside the QGroupBox, but the design
with labels in the first and edit-widgets in the second column lends
itself to a QFormLayout, which adapts the alignment of the widgets to
the platform style, so use that.

Amends 2690822428deec4f0c08f4d118d69a7c6036369e, which, however,
inherited all of the above from even older code.

Pick-to: 6.9 6.8
Change-Id: I528f0ce9d8cb7a997fbfabcdca887c059f571b38
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-02 07:50:50 +01:00
Marc Mutz
3419c29936 sqlbrowser example: use idiomatic Qt [2/3]: use button-box / override accept()
- The old code used two QPushButtons in a QHBoxLayout to provide
  Ok/Cancel buttons. This hard-codes the positions and text (and
  icons) of these buttons, instead of adapting to the platform style.

  The new code simply uses QDialogButtonBox, which is designed for
  this purpose.

- Also, the old code connected the Ok button's clicked() signal to a
  custom slot that then called QDialog::accept(). This means that the
  code in the custom slot is not executed when the dialog is accepted
  by other means (e.g. return press in one of the line edits
  ("auto-default"), though I'm not sure here).

  The new code uses the idiomatic Qt way of overriding
  QDialog::accept() instead, and connects the button-box's accepted()
  signal to it. This is done in the .ui file, so it already works in
  Designer preview.

- Finally, the old code made a manual connection from the Cancel
  button to QDialog::reject().

  The new code uses the Qt idiom of connecting in the .ui file
  directly, using QDialogButtonBox::rejected() as the signal.

Amends 2690822428deec4f0c08f4d118d69a7c6036369e, which, however,
inherited all of the above from even older code.

Pick-to: 6.9 6.8
Change-Id: I83afd6156a0811e0c0f99f2480625ea6b69ff78b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-02 07:50:45 +01:00
Marc Mutz
53826d1cde sqlbrowser example: use idiomatic Qt [1/3]: disabling group-box
The old code connected to the wrong signal and therefore had to write
a custom slot to perform the disabling of the group-box.

The new code simply connects the QCheckBox::toggled(bool) signal to
the directly-compatible QWidget::setDisabled(bool) slot, removing the
need for a custom slot.

Also move the connection into the .ui file, so it works already when
checking the form in QtDesigner.

Amends 2690822428deec4f0c08f4d118d69a7c6036369e, which, however, only
inherited the issues from older code.

Pick-to: 6.9 6.8
Change-Id: Ia834f92de270bb7b18981273188f6e5b6cd457a2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-02 07:50:38 +01:00
Thiago Macieira
db34e27f7f Replace qgetenv() calls converted to QString with qEnvironmentVariable()
It's slightly more efficient.

Pick-to: 6.9
Change-Id: Id5ac04fc27eee108c8e5fffd786c3d5f793a0a9d
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2025-01-01 14:23:05 -03:00
Thiago Macieira
ce95c26034 qEnvironmentVariable: avoid a temporary QByteArray
Because we don't need one. I guess I was just lazy.

Amends b12fd1fa9d0b64e3cb66fa68c85392dbde8e175b ("Long live
qEnvironmentVariable()").

Pick-to: 6.9 6.8
Change-Id: I5b9141c5a32f9d784e0bfffdc3e4d742790aebdd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-01 11:09:10 -03:00
Ahmad Samir
c41aa89610 QTranslator: refactor loading translation files
QTranslator::load() used to:
- call find_translation(), which finds the file, ensures it's readable,
  and returns file name
- pass the file name to do_load() which would proceed to open the
  file

During the time between calling find_translation()/is_readable_file()
and calling do_load(), the underlying filesystem could have changed.

Solve the issue by making find_translation() call do_load() itself (as
suggested in the bug report). Also rename the method to
load_translation() and make it a member method so that it can call
do_load().

Remove the now redundant is_readable_file() static helper, since
QFile::open() in do_load() will do the necessary checks.

Note that there is a slight behavior change:
- with this commit we call do_load() on a variant of the translation
  file name, if that fails we call it again on the next variant ...etc
- before this, if the file was readable, the code called do_load() once,
  if it failed, it didn't try again.
This was suggested by Volker in code review as a good/welcome
side-effect.

Task-number: QTBUG-129777
Change-Id: Ie5fada60dd6267e67cda4272530db69a44f3ee55
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-01 03:04:55 +02:00
Ahmad Samir
3bb4c4949f moc: fix GCC -Wextra-semi colon after member function definitions
As pointed out by Thiago the QT_DECLARE_METATYPE calls are redundant, so
remove them.

Task-number: QTBUG-132101
Pick-to: 6.9 6.8
Change-Id: I73800e70d3f270fb87941d4e053aa7ac5ed1841c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-01-01 01:59:13 +02:00
Ahmad Samir
b83e825fab QCryptographicHash: hashInto(): check the buffer size earlier
We can use hashLengthInternal() to check if the buffer is big enough.
This matches what the QCH::hash() method does, it also has an assert
that `result.size() == ba.size()`, so we can assume this works with
OpenSSL's EVP_MD_get_size() in EVP::finalizeUnchecked().

Amends c70c81b371993ca865d523bb5f37eac4eb8a972b.

Pick-to: 6.9 6.8
Change-Id: I64935f3d590ab243b361a0b764f011c388820e32
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2024-12-31 20:40:32 +00:00
Ahmad Samir
cfa7d41db0 qtdeprecationmarkers: add deprecation macros for 6.14
Will be used in a subsequent commit in QString.

Change-Id: I3f2a15c2b15c6558b61e2365a2cabc9a989b0940
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-31 22:40:30 +02:00
Ahmad Samir
997abb0520 src/plugins/*: fix GCC -Wextra-semi colon after member func definition
Pick-to: 6.9 6.8
Task-number: QTBUG-132101
Change-Id: I947fdb66df9b6d86c60139046166395e4ae42127
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-31 22:39:45 +02:00
Marc Mutz
cf6ae9a901 tst_QImage: fix discarded QFile::open() results
Wrap them in QVERIFY(), as usual.

Found by QFile::open()-turned-nodiscard-come-6.10.

Amends e673e5a257569eaa816c6acd31dd754efd9f8c75 and
25c96d547b4563cbfedcec6093d68116148d8599.

Pick-to: 6.9 6.8
Change-Id: Id39e5d9e500b524af8443cb57916a12f98bd7c23
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-31 17:06:24 +01:00
Thiago Macieira
4400f09c97 Bootstrap: disable QCborValue's use of QCborStreamWriter
We do use QCborValue and QCborStreamWriter in the bootstrap lib, but we
don't need QCborValue's serialization functionality. In fact, we only
need QCborValue because it is used as a backend to QJsonValue.

Drive-by mark the one out-streaming QDataStream method as depending on
QT_CONFIG(cborstreamreader) (which indicates no one is disabling that
feature).

Change-Id: I3e3a3baa0ce28b744adafffdf7dbf0ffe2911208
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-12-31 10:31:59 -03:00
Peter Kling
714ae22b84 CMake: fix absolute paths w/o suffix in pri/prl files
In the update from 6.7.2 to 6.7.3, commit `ea0f00d5d` changed how linker
flags like `ws2_32` are treated when generating pri/prl files.
Specifically, before the commit a flag like `ws2_32` was left
untouched. The above commit changed it such that such flags are
converted to `-lws2_32` (seemingly in order to better support FFmpeg,
according to the commit message). However, this change also affects
absolute paths if the file has no extension. That is, after the above
mentioned commit, an absolute path linker flag to, say, a dylib on macOS
without a suffix will result in prepending the `-l` flag. This will
result in errors during link time.

An example where this caused problems can be found in the nixpkgs PR
draft #367206 (https://github.com/NixOS/nixpkgs/pull/367206).

This adds a small check to ensure that `-l` is not prepended if the
linker flag is an absolute path without a suffix.

Change-Id: I2c7ce3aac6624e1a27c59af233e3da2c1ae7ba60
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2024-12-31 13:34:50 +01:00
Marc Mutz
e57113feac QLibraryInfo: de-pessimize prefixFromAppDirHelper()
The local appDir variable was only used to hold the return value of
another function call. But hardly any compiler will be able to look
through the QString atomic ref-counting to turn the non-Darwin code
paths into the tail-calls that they ought to be.

Remove the variable and return the result immediately. This removes
the move-assignment and dtor calls in the two changed lines and lets
RVO kick in, turning these calls into tail-calls on non-Darwin
platforms.

Amends 4ac872639ed0dd3ae6627e05bdda821f7d128500.

Pick-to: 6.9 6.8 6.5
Change-Id: Ieeefbd52fc983ab7aebcff6419965b206f374935
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-12-31 08:27:36 +01:00
Marc Mutz
8bf5438531 tst_Q(Gui)EventLoop: Unbreak UBSan build
The tests peek into QEventLoopPrivate, which means that a UBSan build
needs access to QEventLoopPrivate's type_info, for which we need to
export the class.

Amends 3af20bd8eb8c75017c5d6d138d7c42914ee5bee3, which fixed the weak
vtable that, presumably, made this test work before.

Pick-to: 6.9 6.8
Change-Id: I4104ba95093fa240c5ef7d9d5bf287c1652333f0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2024-12-31 08:27:14 +01:00
Marc Mutz
63f1c6fcba Port QtCore from QScoped- to std::unique_ptr [1/2]: private uses
This patch series is in preparation of enabling QT_NO_SCOPED_POINTER
when building QtCore, a prerequisite for enabling this opt-out in leaf
modules.

This first part of the patch series ports objects whose use cannot
"leak" into other modules, e.g. because they are in .cpp files or are
private members and is thus SC (and, as demonstrated by various static
assertions we put into the source code over the years, BC).

The second patch will deal with objects in protected and public APIs,
and thus might be QUIP-6 SiC Type A.

Pick-to: 6.9
Task-number: QTBUG-132213
Change-Id: If4967f6e563a4e7d74550fad4c6d354fad1beef5
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-12-31 08:27:00 +01:00
Thiago Macieira
c7f64d84fb Bootstrap: remove QUuid and QCryptographicHash: they're now unused
The previous commit removed the one use of QUuid and, through it,
QCryptographicHash in one of the three bootstrapped tools.

Change-Id: I31b7f9f6aa402709bad7fffd3a65e86be7f6d882
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-12-30 19:45:58 -03:00
Thiago Macieira
002f12bf05 tracegen: Remove the use of QUuid and therefore QCryptographicHash
By bypassing the two completely and just using the SHA1 algorithm
directly. This removes the only use of either class in bootstrapped
tools.

The use of the null UUID as a namespace is non-standard, so I've
scheduled it for removal in Qt 7, which will also simplify the code. It
will be closer to Microsoft's suggestion in [1]. Until then, this keeps
the exact same algorithm as Qt 6.8's tracegen so the two versions
generate the same IDs.

[1] https://learn.microsoft.com/en-us/windows/win32/api/traceloggingprovider/nf-traceloggingprovider-tracelogging_define_provider#provider-name-and-id

Change-Id: I5056b93971c9b03d7d82fffd53bf27228074d9f4
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-12-30 19:45:56 -03:00
Thibaut Cuvelier
8b82bdb01f Documentation: fix a use of \inlineimage with \caption
The author most likely meant to use \image, based on the HTML render at
https://doc.qt.io/qt-6/qml-qt5compat-graphicaleffects-gaussianblur.html.
Also, this case generated invalid DocBook output.

Change-Id: Ibcd562b3847effe97945117a7a67fda33b00af90
Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
2024-12-30 21:08:14 +01:00
Thiago Macieira
affae47400 Remove .lgtm.yml
lgtm.com is part of GitHub and the original service has shut down.

Change-Id: I03f109408cd408811c60fffdaac42eaeb8c9a84c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
2024-12-30 09:15:33 -03:00
Toni Saario
918cbe7601 Coin: Tweak VxWorks testrunner
Add crash handling to avoid waiting until 10min timeout on each crash.
Force restart on each crash by killing emulator.

Make health check more robust to allow it to work even when emulator is
down. This is done via wait in separate process which cannot be done
with normal timeout command, as input to pipe that is not being read
by emulator will block forever.

Pick-to: 6.9
Change-Id: I86c3c86f936cc96d57b38983da48d1d73162399d
Reviewed-by: Simo Fält <simo.falt@qt.io>
2024-12-30 12:22:23 +02:00
Samuli Piippo
c3bbbb22b8 egldevice: allow DRM device path to be overridden
The backend-provided DRM device might not be the right one,
so allow kms config to override it.

Pick-to: 6.9 6.8
Task-number: QTBUG-131887
Change-Id: Ied744ae7015eae64f4556f1528e0dbe8ae69d206
Reviewed-by: Pasi Petäjäjärvi <pasi.petajajarvi@qt.io>
2024-12-30 07:49:52 +02:00
Friedemann Kleint
11d6200d8a uic: Generate fully qualified enumerations for QFormLayout
This is required for Python.

Pick-to: 6.9
Task-number: PYSIDE-1735
Change-Id: I92108009dd23565adaa2ee77300059cb197a89c5
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
2024-12-30 01:11:29 +01:00
Marc Mutz
6103977654 QWaylandShmBuffer: use make_unique / unique_ptr
This keeps the QFile/QTemporaryFile objects inside a RAII wrapper at
any time, which is safer.

Since QScopedPointer doesn't have a similar function (and because of
upcoming QT_NO_SCOPED_POINTER), also port to std::unique_ptr.

Amends 32daa1a5b9ac06ae89d3aab5b4638139e72814e2.

Pick-to: 6.9 6.8
Change-Id: If67a3a3bdb4fa2a06ecafd1c3dcb90e1121159b0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-29 22:13:16 +01:00
Marc Mutz
138c43a321 QWaylandShmBuffer: don't ignore the result of Q(Temporary)File::open()
The code checked isOpen() afterwards, so everything was ok, but the
compiler still complained with QFile::open()-turned-nodiscard-in-6.10.

Use a boolean to store the result of open() and use it in lieu of
isOpen().

Amends 32daa1a5b9ac06ae89d3aab5b4638139e72814e2.

Pick-to: 6.9 6.8
Change-Id: Ia7db2505e939e4f4614cfc8319e779812dd17353
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-29 22:12:27 +01:00
Marc Mutz
a6059d4371 Fix C++20 deprecated capture of *this in [=]
The exec() function is synchronous, so we can just replace [=] with
[&], cf. d8f03969619f3f23528f7771eb963698a84d84a9.

Amends 0b82d95632e37ed790db303a580cd39320378434.

Pick-to: 6.9 6.8
Change-Id: I6d3a531287dbf3c8c9be7103b5d936325627ca7e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-29 22:11:30 +01:00
Marc Mutz
ec0f58f5cf Fix -Wunused-result warnings in tests
Existing ones, as well as the newly-popping up ones from QFile::open().

Pick-to: 6.9 6.8
Change-Id: I580f3a022c18bc9026e47df10da8cc7b78296366
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-29 22:10:58 +01:00
Ahmad Samir
fff217824b tst_QCryptographicHash: split 4GiB tests to a separate unit test
With those tests split, tst_QCryptographicHash takes about 4ms.
When FEATURE_openssl_hash is enabled those tests take about 15s on
their own, but when openssl_hash is disabled they take about 2 minutes.
That makes running the tests locally a bit of a hassle when hacking
code ... test ... hack ... test.

This is with a debug build, GCC, `-O0 -g` flags.

Pick-to: 6.9
Change-Id: I8b8f5d1954feb1f9eb8115e27635610a41b42f47
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-29 22:20:28 +02:00
Christian Ehrlicher
785fb89e0a QCommandLinkButton: fix drawing high-dpi icons
QCommandLinkButton was using QIcon::pixmap() without specifying the
current device pixel ratio. Switch to QIcon::paint() to not have to
fiddle around with the dpr at all here.
As a drive-by remove a useless QPainter::save/restore call.

Pick-to: 6.9 6.8
Change-Id: I7e2492a09b28cb8a4f4cc60454733e0054fe1e9b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-29 18:03:37 +01:00
Marc Mutz
aa1f206480 QLibraryInfo: port from manual memory management to unique_ptr
It's safer and clearer.

Also standardize on unique_ptr instead of QScopedPointer, because the
latter is not supposed to be movable, so the assignment in
QLibrarySettings::load() would not compile.

As a drive-by, scope a variable tighter (in an if condition).

Task-number: QTBUG-132213
Pick-to: 6.9 6.8
Change-Id: Iecdd910af4d06dbd03d2daf3ccf99dd4822f04ac
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-29 08:44:07 +01:00
Christian Ehrlicher
b2cc8824ec QStyleSheetStyle: Honor box settings for QSpinBox
The previous patch to not modify the CT_SpinBox by QStyleSheet when
nothing was added for QStylesheet also removed the additional margins &
paddings handling for the size calculation. This patch re-adds this.

This amends 96adebed606cdbc73c73778917d777dc04c6e93e.

Pick-to: 6.9 6.8
Task-number: QTBUG-130642
Fixes: QTBUG-132431
Change-Id: Iff1f0febeca90d3154e61fd80e4b359bc7766b84
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-12-28 23:52:05 +00:00
Christian Ehrlicher
efc318e05a Widgets: pass dpr to QIcon::pixmap()
Change the remaining calls to QIcon::pixmap() to pass a valid
devicePixelRatio parameter.

Pick-to: 6.9
Change-Id: I0e71e20c8109e296446e9e13cddba31d53c05df9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-29 00:52:00 +01:00
Christian Ehrlicher
d4c518b210 QCommandLinkButton: reload icon on style change
Different styles provide different icons for SP_CommandLink so reload
the icon on every style change.

Pick-to: 6.9 6.8
Change-Id: I2d8bd706d4c1bca89b91c90f1bb90a796b38e0d3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-29 00:51:58 +01:00
Volker Hilsheimer
1b84970b90 JNI: don't pass jobject by reference
And definitely not by non-const reference.

Discovered during upcoming fixes for native function registration.

Task-number: QTBUG-132410
Pick-to: 6.9 6.8
Change-Id: I0ce8519f5a1f9f3caffefc53e6d93b52509bc439
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-28 18:18:32 +01:00
Tatiana Borisova
cfd3c84184 [QTextStream] Add operator bool() to QTextStream class
- Add operator bool() that checks whether the associated stream has
  no error status. This operator makes it possible to use streams
  and functions that return references to streams as loop conditions:
    `while (stream >> text)`.
- Add testcase for testing the new operator.
- Update existing testcases that use or can use the status of stream
  operations.

[ChangeLog][QtCore][QTextStream] Added implicit conversion to bool,
returning `status() == Ok`.

Task-number: QTBUG-52189
Change-Id: I21cbe02ec194078304bcfe606a6f2f572dd09c84
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2024-12-27 15:55:53 +00:00
Tero Heikkinen
6e8274a227 Ubuntu 24.04 x64 - Blacklist tst_qgesturerecognizer touchReply
Task-number: QTBUG-129754
Change-Id: I1077529ca01128fa7213891a52cfb7fa3225c2b2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-27 12:26:18 +02:00
Lars Schmertmann
46dddcb213 Avoid unused variable warning in qfilesystemmodel.cpp
2135:5: warning: unused variable 'q' [-Wunused-variable]
    2135 |     Q_Q(QFileSystemModel);
         |     ^~~~~~~~~~~~~~~~~~~~~

The variable is only required for the feature filesystemwatcher.

Pick-to: 6.9 6.8
Change-Id: I5da48f94118179ec20fec7da7169b7f22cec17fe
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-12-26 17:35:00 +01:00
Thiago Macieira
92373d353c QSaveFile: make it so flush() errors imply commit() failed
QSaveFile records past write errors in writeData(), but often the
QFileDevice::writeData() calls it places will succeed because the data
is only being buffered. Instead, the failures are noticed only by
flush(), whose actions do not affect QSaveFilePrivate::writeError.

[ChangeLog][QtCore][QSaveFile] Fixed a bug that caused commit() to
return true and overwrite its intended target file even though it failed
to flush buffered data to the storage, which could cause data loss. This
issue can be worked around by calling flush() first and only calling
commit() if that returns success.

[ChangeLog][QtCore][QSaveFile] Fixed a bug that caused commit() to
return true even after a cancelWriting() call had been placed, if
writing directly to the target file (that is, only with
setDirectWriteFallback() set to true). Note that the state of the file
does not change under those conditions, only the value returned by the
function.

Drive-by clarify a comment from 6bf1674f1e51fd8b08783035cda7493ecd63b44
(Qt 4.6 "Don't drop errors from flush on QFile::close") which had me
chasing the wrong lead.

Fixes: QTBUG-132332
Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I427df6fd02132d02be91fffd175579c35b9c06cc
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2024-12-26 12:53:13 -03:00
Thiago Macieira
b884fbf102 3rdparty: patch BLAKE2 sources to not export anything in static builds
This could cause conflicts with other users of these algorithms, notably
libb2 itself. Though if you're using libb2, you shouldn't be using the
un-optimized copy inside QtCore...

I've updated the SHA1 of the last commit in the repository, but there
were no changes to our sources.

[ChangeLog][Third-Party Code] Fixed a bug that caused the BLAKE2 symbols
to be visible from QtCore in a static build. If you need to use the
BLAKE2 hashing algorithm in your own code, either use QCryptographicHash
or import libb2 into your build environment. Using libb2 remains the
recommended solution for all systems, especially those for which it has
optimized (vectorized) implementations.

Fixes: QTBUG-132347
Pick-to: 6.9 6.8
Change-Id: I48003b58cef0d8bcc720fffdd89b0f151fd102e3
Reviewed-by: Linus Jahn <lnj@kaidan.im>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2024-12-26 08:34:39 -03:00
Thiago Macieira
b8f84fd1e2 Replace qTerminate() with std::terminate() and mark it for removal
It was used by the QT_TERMINATE_ON_EXCEPTION macro, introduced in 2012,
to support pre-C++11 noexcept semantics. That macro was removed for Qt
6.8 in commit 9b2ae564a59656d9cf49b141e70f5958b4fb79a4. This commit
amends that removing the definition of qTerminate() immediately in Qt
6.9 (it was an \internal function).

Pick-to: 6.9
Change-Id: I9682121c04fafb3676b0fffd9f5ac999e7603c84
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-12-26 08:34:38 -03:00
Marc Mutz
d9264ee65d QTest::toString(QCbor-type): port from const char* to unique_ptr<char[]>
This is more robust and lessens the impedance mismatch as seen by the
old code using std::unique_ptr<char[]>(expr).get().

The new code isn't impedance-mismatch-free, either
(UP{qstrdup(qba.data())}), but short of writing a small string class
whose internal buffer can be release()ed to comply with the archaic
QTest::toString() new[]'ed const char* return value, there's not much
we can do about it atm.

Also separate the internal from the "public" stuff in
QCborValueFormatter by adding private: and public: sections.

Pick-to: 6.9 6.8
Change-Id: I09a2ad1a75bb9eab3d01f2b5b60afc2d762da384
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-26 08:07:20 +00:00
Marc Mutz
1a9f8cc0df Fix a performance regression in QDataStream
Commit e176dd78fd2f253eb2625585b2bd90b5713e5984 replaced a `new
char[n]` with a std::make_unique<char[]>(n), probably on this author's
insistence.

But the two are not equivalent: make_unique() value-initializes, even
arrays, even of built-in type, which means that each buffer resize
writes each byte twice: first nulling out the whole buffer as part of
value-initialization, then in the memcpy() and any following read()s.

For buffers of several MiB, or even GiB in size, this is very costly.

Fix by adding and using a backport of C++20
make_unique_for_overwrite(), which performs the equivalent of the old
code (ie. default-, not value-initialization).

Also add q20::is_(un)bounded_array, which are needed for the
implementation of q20::make_unique_for_overwrite().

Amends e176dd78fd2f253eb2625585b2bd90b5713e5984.

Pick-to: 6.9 6.8 6.5
Change-Id: I8865c7369e522ec475df122e3d00d6aba3b24561
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-24 23:41:58 +00:00
Marc Mutz
05b9a4b2de tst_QSpan: check QList<int> -> QSpan<const int> doesn't detach the former
It does.

While std::span, does, too, and so users should be using
std::as_const(), it's quite simple to avoid for QSpan, so we'll fix it
in QSpan. This patch adds the reproducer.

Task-number: QTBUG-132133
Pick-to: 6.9 6.8
Change-Id: I2e416fb7344830cd5e0d945cce61491cd6f4a7a5
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-24 20:58:28 +01:00
Mike Chen
457580936d QFactoryLoader: load extraSearchPath first
Since `QT_QPA_PLATFORM_PLUGIN_PATH` or `-platformpluginpath`
 specifies the path to platform plugins, `extraSearchPath`
 should be loaded first.

Pick-to: 6.8 6.9
Change-Id: I2e62fbf2021250ca864c669a7bbd7d56acd67d1e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-23 09:16:17 +08:00
Marc Mutz
7a7804d4b4 QDecompressHelper: fix compilation with GCC 9
GCC 9 doesn't accept [[unlikely]] between the (condition) and the
compound-statement of an if, in both C++17 and C++20 modes:

  qdecompresshelper.cpp: In member function ‘qsizetype QDecompressHelper::readZLib(char*, qsizetype)’:
  qcompilerdetection.h:1048:31: error: attributes at the beginning of statement are ignored [-Werror=attributes]
   1048 | #    define Q_UNLIKELY_BRANCH [[unlikely]]
        |                               ^~~~~~~~~~~~
  qdecompresshelper.cpp:597:54: note: in expansion of macro ‘Q_UNLIKELY_BRANCH’
    597 |         if (ret == Z_DATA_ERROR && !triedRawDeflate) Q_UNLIKELY_BRANCH {
        |                                                      ^~~~~~~~~~~~~~~~~

See also https://stackoverflow.com/questions/51797959/how-to-use-c20s-likely-unlikely-attribute-in-if-else-statement

Put it into the compound-statement instead, then GCC 9 accepts it. The
two are equivalent, because [[likely]] marks a path, and there is no
selection statement between the two positions.

Amends 5ae84d0afbd3690a2c003d06d920566a5d56dc8c.

Pick-to: 6.9
Change-Id: Iac1970219c98a1c26e450dfe6bad6583e4d32c29
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-22 16:28:41 +00:00
Marc Mutz
40501ffbb4 q23type_traits.h: use is_scoped_enum_v from std
We don't like surprises in qNN, so use the real is_scoped_enum_v from
std instead of adding the _v version outselves, even in C++20.

Amends 03a7be37806a32e9a8ac963b309812d6b8f125f6 and
63a8f657c2236829f16016602d9c0098b089d35e.

Pick-to: 6.9
Change-Id: I7f9149678b95f7a59643152abf5a627e226cc058
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-22 12:19:03 +01:00
Wladimir Leuschner
a53e095882 QWindows11Style: Align QSpinBox rect to match QLineEdits rect
The content rects for QSpinBoxes were smaller than QLineEdits rects for
UI elements that should have the same size. This patch increases the
content rect for QSpinBoxes.

Task-number: QTBUG-132261
Pick-to: 6.9 6.8
Change-Id: I59e752b719399c5845ab3ef81c6e271deda16273
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2024-12-21 15:17:45 +00:00
Wladimir Leuschner
5e656b9ea3 QWindows11Style: Adjust Subline for QLineEdit to fit rounded corners
Reduce the size of the subline for QLineEdit to fit the begin and end of
the rounded frame corner.

Task-number: QTBUG-132261
Pick-to: 6.9 6.8
Change-Id: I879f30c2bdc6601fef4738aeec71d7ab7bcee22c
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2024-12-21 16:17:45 +01:00
Ilya Fedin
c1a18d3edf QWaylandXdgSurface: Always clean up xdg_activation_token in more places
If the token arrives after the surface has already been destroyed,
the lambda containing the deleteLater would never be called.

Amends 638c9bd2595704606b53ba319c67568b479f9fc0

Pick-to: 6.9 6.8
Change-Id: Ibebeb441d9c115b0203703b8042a58e986ccff47
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Reviewed-by: Kai Uwe Broulik <kde@privat.broulik.de>
2024-12-21 18:28:24 +04:00
Christian Ehrlicher
204df603ef QDrawUtil: use QPainterStateGuard
Replace the internal PainterStateGuard class with the now public
QPainterStateGuard.

Pick-to: 6.9
Change-Id: I9c072ce6e45ddfe2d0a8aba789311193788dee5a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-21 13:05:45 +01:00
Christian Ehrlicher
7690b6260e QCommonStyle: use QPainterStateGuard
Replace the internal QPainterStateSaver class with the now public
QPainterStateGuard.

Pick-to: 6.9
Change-Id: I56285cb469cec43071320e87ac378674fd99c06b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-21 13:05:42 +01:00
Giuseppe D'Angelo
6844c70ae9 QEdidParser: optimize the hardcoded EDID vendor table
Instead of using an array of fixed-length strings for the vendor names,
use qOffsetStringArray instead. This removes the need of using the
longest vendor name length as the size of the fixed-length strings,
which results in a massive waste of space. This saves 150KB of
(readonly) data.

Details: there are 2555 entries, each one hardcoded to be 78 byte long,
for a total of 199290 bytes. However the vendor names themselves amount
only to 50658 bytes.

Making all this data optional on desktop Linux (where the vendor data is
present anyhow on the system, in /usr/share/) is left for a future
change.

Change-Id: I17007865e741e3dab15dd2ab2feffbce4664fb37
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-21 00:03:36 +01:00
Alexey Edelev
8d0283ad2c Avoid creating Plugin targets if the dependencies are missing
The plugin lookup mechanism doesn't handle the situation, when the
plugin is available but it's private dependency(static plugin case)
is missing. In this case we currently silently bypass the dependency
lookup and create targets. So users see the confusing message about
missing linked target, like:

   Qt6QSQLiteDriverPluginTargets.cmake:61 (set_target_properties):
   The link interface of target "Qt6::QSQLiteDriverPlugin" contains:
     SQLite::SQLite3
   but the target was not found.  Possible reasons include:
     * There is a typo in the target name.
     * A find_package call is missing for an IMPORTED target.
     * An ALIAS target is missing.

This indeed should be handled properly and we should omit creating
targets especially if users don't really use the plugin directly.

Also if dependencies are not satisfied it looks logically to set
the <plugin>_FOUND to false as this will be yet another indicator
for user that the plugin is not found.

Task-number: QTBUG-132244
Pick-to: 6.8 6.9 6.5
Change-Id: I8685163df0dee3a728c724901f69780569ffcad5
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-12-20 21:49:02 +01:00
Eskil Abrahamsen Blomfeldt
c08a92307d Don't include bearing of mid-string characters in max width
When calculating the maximum width of a text layout, we
would add the text width of each substring *after* we had
added the negative right bearing of the last character to it.
But the bearing of the last character in a wrapped substring
does not actually add to the maximum width unless it is the
last character of the *whole* string.

Prior to 250117086ff15bba79df8f0e15ee66192edc9ea9 this was
not noticed, because the last glyph in the substring would
typically be a space and the space does not have any
bearings (when doing wrapping on individual characters it
could still happen). After the change, the previous glyph
for which we get the right bearing will be the last
non-whitespace glyph. If this happened to have a negative
right bearing, we would add this to the max width and
end up with a larger max width than we should.

This caused a test failure in tst_qquicktext.

This test prefers the text width without the bearing (i.e.
the *advance* of the substring) unless the line is manually
wrapped or it is the last line of the layout.

Pick-to: 6.8 6.9
Change-Id: Iba1a5ad48d575683672400f0572dfa683a0f2d9c
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
2024-12-20 18:03:38 +01:00
Piotr Wierciński
bc521b68a6 wasm tests: Update window class in Selenium test
Rename qt-window to qt-decorated-window to follow changes introduced by:
2ab07b4558ce074fcd6cac699ea71df31fc324f5.

Change-Id: I41f84cc201821d620be11b67939aa94664a8d208
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2024-12-20 15:38:31 +00:00
Mårten Nordheim
6e7a15f5c5 tst_QHttp2Connection: make settings exchange wait for acknowledgement
Is needed when sending more SETTINGS frames during the test later

Task-number: QTBUG-132277
Pick-to: 6.9 6.8
Change-Id: I24b2a5d1b2e7aecd8687db5b24f37233df3b91dd
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2024-12-20 15:48:41 +01:00
Tor Arne Vestbø
9f392c09a1 Apple: Use automatic rendering mode for icon engine
When requesting symbol icons the OS automatically chooses a rendering
mode per icon. Most icons use the monochrome rendering mode by default,
but some of them use the hierarchical.

We don't want to override this choice by always using hierarchical,
as that doesn't match the look of most icons in the system and may
be surprising to the user.

We still want to support tinted icons, based on the QPalette. For
iOS this is easy via [UIImage withTintColor:] but for macOS we
have to do an extra render pass. Unfortunately we can't use
configurationWithPaletteColors with a single color, as for the
hierarchical icons this will produce a different looking icon
than if we tint the entire icon.

[ChangeLog][macOS/iOS] The Apple icon engine, used for theme
icons on macOS and iOS, will now use the default rendering
mode for icons, typically monochrome, instead of always
using hierarchical icons.

Pick-to: 6.9 6.8
Change-Id: I9e66d848222e8ed0f7f20897454f27446bf0fd81
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-20 14:48:41 +00:00
Toni Saario
75d87caef7 Increase VxWorks stack size
Increases to around 16MB with the format change.
Required by some tests.

Pick-to: 6.9
Change-Id: Ia41436b4269220f84271b614ea6f2b96ca605c32
Reviewed-by: Simo Fält <simo.falt@qt.io>
2024-12-20 16:48:41 +02:00
Juha Vuolle
0aa07ce772 Change QImage::mirrored() deprecation from Qt 6.10 to Qt 6.13
The deprecations aren't urgent, and allowing more time for users to
adapt is appropriate. In addition, also suppress the deprecation
warnings when compiling the related autotest.

Resulted from API-review.

Amends: 577946c1f05aaaa2a3f9682001aeb4144386b26b

Pick-to: 6.9
Task-number: QTBUG-132090
Change-Id: Ia0c07ab510a9a9c8722892fcd94f58f6ec287059
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2024-12-20 16:48:41 +02:00
Christian Ehrlicher
6e29a94b54 QWindows11Style: Adjust position of MDI subwindow icon
The y position for the MDI subwindow icon was not calculated correctly
so the icon was not painted vertically centered.

Pick-to: 6.9 6.8
Task-number: QTBUG-130673
Change-Id: I5f9023820a4e4b4288017869ac4088fe2669ce50
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-20 14:15:59 +01:00
Christian Ehrlicher
2c85e5d222 QWindows11Style: adjust text rect for CC_TitleBar
The adjustment for the textrect was wrong - the bottomRight point must
be moved by -1/-1, not 1/1.

Pick-to: 6.9 6.8
Task-number: QTBUG-130673
Change-Id: I6c099fdd9a03188e7a5c7852b1912ed9b2801f7a
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-20 14:15:58 +01:00
Marc Mutz
f405925829 qtesttostring.h: standardize on unique_ptr<[]>
... instead of QScopedArrayPointer.

Less Qt code (which we're supposed to test with this library) and more
consistent with the tuple implementation.

Also makes the header clean w.r.t. upcoming QT_NO_SCOPED_POINTER.

Pick-to: 6.9 6.8
Task-number: QTBUG-132213
Change-Id: I3705b8db89e909e3f1e37ad6a31aaba6f9af899a
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-20 14:15:58 +01:00
Christian Ehrlicher
1fb86f1f84 QDrawUtil: Cleanup qDrawPlainRoundedRect/qDrawPlainRect
Fix the style and use PainterStateGuard instead own save/restore
functionality because PainterStateGuard is already available and used in
those functions.

Pick-to: 6.9 6.8
Task-number: QTBUG-132187
Change-Id: Ie454b6cffe03444d88f13d15adb19a7e7783a493
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-20 14:15:58 +01:00
Volker Hilsheimer
b957dfc6e0 QTestLib: Remove logging category declaration from public header
The lcQtGuiTest category is only used in qtestsupport_gui.cpp, so
declare it there as a static logging category.

Addresses header-review comment, amends
5ac4f04325a56d47812f528fe31ceb0d4932f664.

Pick-to: 6.9
Task-number: QTBUG-132090
Change-Id: I5b2a93822a698f55c52c1be87ebf8a689f49e2a3
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2024-12-20 10:42:45 +01:00
Christian Ehrlicher
1bd883dbc1 QSqlQueryModel: add new function to refresh the model data
This function re-executes the query used by QSqlQueryModel and refreshes
the data from the database. The query must not use bound values as these
values are not preserved.

[ChangeLog][QtSql][QSqlQueryModel] Added refresh() to refresh the model
data from the database.

Pick-to: 6.9
Task-number: QTBUG-123603
Change-Id: I3f1d779e07b88565abe825c31cfc4d7d1b2312c4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-20 03:46:13 +01:00
Christian Ehrlicher
5b07e3de3f QSqlDriver: return the connection name of the assoicated QSqlDatabase
A QSqlDriver instance is directly bound to a QSqlDatabase object. But
there was no way to get the QSqlDatabase out of a QSqlQuery/QSqlDriver.
Fix it by storing the connection name also in the driver during
creation and add a getter for it.

[ChangeLog][QtSql][QSqlDriver] Added connectionName() which returns the
connection name of the associated QSqlDatabase instance.

Pick-to: 6.9
Task-number: QTBUG-123603
Change-Id: If78b85413cf6ca965ff6bf9f3600cb54169b5569
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-20 03:46:08 +01:00
Volker Hilsheimer
ec3a5f4994 QPainterStateGuard: make movable, add test coverage
There's no real reason not to be able to move a state guard.

Since a moved-from QPainterStateGuard must not have a restore-
level count, we have to implement the move-constructor explicily.
Add a test case, which verifies that we don't end up with an
un-balanced save/restore count, and that verifies that we would
trigger the Q_ASSERT if we do.

Address comment from header review,
amends 9ecf47a8a8d11227ecf192246d7df7c2c4dc9105.

Task-number: QTBUG-132090
Pick-to: 6.9
Change-Id: I1db135bf48c0fa0a7bac4fdae7b7263c356b5eb6
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2024-12-19 22:30:53 +00:00
Thiago Macieira
8928b0fbb9 QCommandLineParser: include the positional arguments' sizes in --help
We were mostly ignoring them because it looks like most people's options
were longer than their positional arguments. The rest must have just
accepted the enforced wrapping.

But if you have very short options like single-letter only ones or none
at all, the positional argument wrapping is unnecessarily short.

[ChangeLog][QtCore][QCommandLineParser] Made it so the positional
argument descriptions are taken into account in the aligning of text for
helpText().

Pick-to: 6.8 6.9
Fixes: QTBUG-131716
Change-Id: Ib1eee62c7cf4462f6a26fffdec233ba849ebf158
Reviewed-by: David Faure <david.faure@kdab.com>
2024-12-19 20:42:42 +00:00
Assam Boudjelthia
5735d7ac86 Android: document androidtestrunner tool
Add documentation and usage of androidtestrunner tool.

Pick-to: 6.9 6.8
Fixes: QTBUG-84330
Change-Id: I03aa67ebf0ba807f20595547f2598d905080a878
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2024-12-19 21:09:54 +02:00
Tim Blechmann
6f41c1652f gui: link with OpenGL framework
qopengl.h pulls in headers from the OpenGL framework on macos when
opengl is enabled. We should therefore also link the OpenGL framework.

fixes linker error in libqcocoa:
Undefined symbols for architecture x86_64:
  "_glGetIntegerv", referenced from:
QCocoaGLContext::updateSurfaceFormat() in
libqcocoa.a(qcocoaglcontext.mm.o)
  "_glGetString", referenced from:
QCocoaGLContext::updateSurfaceFormat() in
libqcocoa.a(qcocoaglcontext.mm.o)

Change-Id: I02d2c80e2652da0cf16eaca7ab161cf711599dc2
Pick-to: 6.9 6.8 6.5
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2024-12-20 02:51:57 +08:00
Ahmad Samir
d983a402a5 QDecompressHelper: add comment for translators in readBrotli()
Spotted by Friedemann Kleint in code review.

Amends 763c47e055376bf6dbd4cd8fe1603b88aa3b72f0.

Pick-to: 6.9
Change-Id: I3092c51964c167da30b6d1400ab2ba1e2f4df829
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-12-19 20:26:36 +02:00
Tor Arne Vestbø
1ce019815b Extend blacklisting of tst_QWidget::showMinimizedKeepsFocus to macOS 15
It's flaky on all version.

Pick-to: 6.8 6.9
Change-Id: I01b2f0877efc100578c55d69e9f9ed65c02b2aab
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-19 19:26:36 +01:00
Eskil Abrahamsen Blomfeldt
f646c1b30b Avoid calling handleScreenRemoved() recursively
In some cases where a nested event loop is run as a result
of a screen being removed (for instance if it's called from
primaryScreenChanged() or similar signals) and multiple
screens were added to the system, then we could end
up calling handleScreenRemoved() for the placeholder screen
recursively. This  would cause a crash if anyone actually
used the QScreen pointer passed through the screenRemoved()
signal.

This makes sure we set the placeholder screen to null before
calling handleScreenRemoved() so that we don't call it again
if we happen to end up in the same function in a nested
event loop.

Pick-to: 6.5 6.8 6.9
Change-Id: I237946851ed4dce03fd53093baba102c9686be46
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-12-19 16:19:39 +01:00
Eirik Aavitsland
1a5afe625b Update bundled libjpeg-turbo to version 3.1.0
[ChangeLog][Third-Party Code] libjpeg-turbo was updated to version 3.1.0

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I321ae095b4ed826ceb940cbf13a63ec1a836acb3
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-12-19 15:18:40 +01:00
Joerg Bornemann
1cdf813e22 Rename qscopedpointer.cpp -> qscopedpointer.qdoc
It only contains qdoc blocks and wasn't even listed in SOURCES.

Also changed the license to be in line with QUIP-18.

Pick-to: 6.9 6.8 6.5
Change-Id: I2c90300ddfd47c3f693dc84cb86f326fa185dd84
Reviewed-by: Lucie Gerard <lucie.gerard@qt.io>
2024-12-19 13:54:27 +01:00
Joerg Bornemann
fbbf4ace01 CMake: Split off private module config packages
[ChangeLog][CMake] Private Qt modules have been split off into separate
Qt6FooPrivate CMake config packages. A call to find_package(Qt6Foo) will
now implicitly find_package(Qt6FooPrivate). It's not an error if
Qt6FooPrivate isn't available as it may be the case on certain Linux
distros that split their Qt module packages into private and public
parts.

For every public module Qt6Foo that has an associated Qt6FooPrivate
module, create a separate Qt6FooPrivate CMake config package.

Let Qt6FooPrivate find Qt6Foo. This is a required dependency.

Let Qt6Foo find Qt6FooPrivate if it's available. A message of log level
VERBOSE is issued if Qt6FooPrivate is not found.

Implementation notes: In QtModuleConfig.cmake.in, we pull in the private
module. This is not part of the *Dependencies.cmake file, because

1. The Qt6FooPrivate package references the Qt6::Foo target, therefore
it must be available. And Qt6FooDependencies.cmake is loaded before
creating targets.

2. The dependency needs to be optional, and we don't have facilities for
optional dependencies in Qt6FooDependencies yet.

3. We'd have to avoid recursion, because of the Qt6FooPrivate -> Qt6Foo
dependency.

Fixes: QTBUG-87776
Pick-to: 6.9
Change-Id: I8f23f07da7ca76486f87b759e197174c11e13534
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2024-12-19 12:11:30 +01:00
Marc Mutz
44366d07dc QXmlStreamReader: use QOffsetStringArray::viewAt()
This auto-computes the string's length without a NUL-byte scan, and
also fixes a GCC 14 unity-build C++23 warning:

  In function ‘constexpr qsizetype QtPrivate::lengthHelperPointer(const Char*) [with Char = char]’,
    inlined from ‘constexpr qsizetype QtPrivate::lengthHelperPointer(const Char*) [with Char = char]’ at qbytearrayview.h:69:28,
    inlined from ‘constexpr QLatin1String::QLatin1String(const char*)’ at qlatin1stringview.h:52:62,
    inlined from ‘constexpr QLatin1StringView contextString(QXmlStreamReaderPrivate::XmlContext)’ at qxmlstream.cpp:814:90,
    inlined from ‘void QXmlStreamReaderPrivate::checkToken()’ at qxmlstream.cpp:4018:85:
  qbytearrayview.h:77:16: warning: ‘strlen’ argument missing terminating nul [-Wstringop-overread]
     77 |     while (data[i] != Char(0))
        |            ~~~~^
  In file included from unity_0_cxx.cxx:412:
  qxmlstream.cpp: In member function ‘void QXmlStreamReaderPrivate::checkToken()’:
  qxmlstream.cpp:769:23: note: referenced argument declared here
    769 | static constexpr auto QXmlStreamReader_XmlContextString = qOffsetStringArray(
        |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Amends c4301be7d5f94852e1b17f2c2989d5ca807855d4, which was picked to
5.15, but didn't use QOffsetStringArray there (and unity-builds exist
only since 6.5), so only picking to 6.5.

Pick-to: 6.9 6.8 6.5
Change-Id: Ib50369aed6e8248fb88f43c7569c8a435c2b152e
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-19 11:11:30 +00:00
Marc Mutz
752de4a0aa Protect QT_ENABLE_STRICT_MODE_UP_TO against predefined individual opt-outs [6.9]
Since some of the Qt opt-outs are defined project-wide by the
buildsystem these days (e.g. QT_NO_QSNPRINF, ...), a module that
attempts to use QT_ENABLE_STRICT_MODE_UP_TO will hit warnings
regarding re-definition of these macros (definition on the compiler
command line, redefinition by qtconfigmacros.h).

To fix, guard the #define QT_NO_FOO's with #ifndef QT_NO_FOO.

Amends bd7d54249e3f2b6a9dd6b759c892d7c97d26c0aa (which was also picked
to 6.8).

Pick-to: 6.9 6.8
Change-Id: I88276c9ed01edde1495105cf5bd1e07b1fd244f4
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-12-19 08:37:37 +01:00
Marc Mutz
0f416cbaab Protect QT_ENABLE_STRICT_MODE_UP_TO against predefined individual opt-outs [6.8]
Since some of the Qt opt-outs are defined project-wide by the
buildsystem these days (e.g. QT_NO_FOREACH, QT_NO_JAVA_STYLE_ITERATOR,
...), a module that attempts to use QT_ENABLE_STRICT_MODE_UP_TO will
hit warnings regarding re-definition of these macros (definition on
the compiler command line, redefinition by qtconfigmacros.h).

To fix, guard the #define QT_NO_FOO's with #ifndef QT_NO_FOO.

Amends 3a6c8e02b6d1b0574da52b0087092d0c74aa92c1.

Pick-to: 6.9 6.8
Change-Id: I457457d1e60dbd9362b987157ba089adc67d1d6b
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-12-19 08:37:06 +01:00
Marc Mutz
b815c6f7fd QTextStream: port from QScopedPointer to unique_ptr
In preparation of adding QT_NO_SCOPED_PONTER, which would be rather
pointless for users if public headers continued to mention the type.

Pick-to: 6.9 6.8
Task-number: QTBUG-132213
Change-Id: I6539e83158ab34e4fa4bd22b6d0ac5629a3b6db9
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-19 08:36:04 +01:00
Giuseppe D'Angelo
38c51dcfc4 associative_erase_if: use type_dependent_false
Avoid a sizeof(X) == 0, which is IFNDR, in favor of the dedicated
feature (type_dependent_false).

Change-Id: I38441cfe3d5c18800bf61bcdd11268cb97d40ec6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-19 04:31:42 +00:00
Thiago Macieira
8f958a6e2d QDebug: constrain the new Standard Library op<<
So they be SFINAE-ruled out when either the key or (for associative
containers) value types don't provide their debug-streaming operators
either.

Amends 850d4895be565931d18c92e5e2f9a33b7f26de6d,
0c96528e8d43ad4309bdca14b179a5045984655a,
a9fe57fefaac0cb047e4c02e0b8c8f8327e0a58c.

Fixes: QTBUG-132104
Task-number: QTBUG-130290
Pick-to: 6.9
Change-Id: I1d6703b1fdf6cfd03799fffd33191d8028ecc123
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-12-18 23:19:56 -03:00
Robert Löhning
efd0b6de12 QRadialGradient: Distinguish shadowed variables
Change-Id: I4a16f949fe78b7b130af274288b27c4297cc81a6
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2024-12-18 23:08:08 +01:00
Robert Löhning
42bd879e2b QRadialGradient: Fix crash on huge x values
Credit to OSS-Fuzz

Fixes: QTBUG-130992
Pick-to: 6.9 6.8
Change-Id: Iefaa6964966f6828bc23a603f085d283189f1a3b
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2024-12-18 21:44:32 +01:00
Christian Ehrlicher
02920ef05a Windows11Style: Fix horizontal scrollbar arrows in rtl mode
The arrows for horizontal scrollbars must be swapped in rtl mode.

Pick-to: 6.9 6.8
Change-Id: I517fcea19837a6438edc261e066930218b71ce28
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-18 20:36:46 +01:00
Nodir Temirkhodjaev
dc57a3137d QFusionStyle: Use QFontMetricsF instead of QFontMetrics
- CT_MenuItem: Use qCeil()
- CE_MenuItem: Add 0.5 to width for elidedText(), because of qRound() in the QFontMetrics::horizontalAdvance()

Fixes: QTBUG-132102
Change-Id: Iaced11905357abb496d4ad3c20be0babb17cf121
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2024-12-19 00:36:46 +05:00
Christian Ehrlicher
f4e197d920 SQL/PSQL: add full support for uuid column type
Add full support for uuid column type by decoding a uuid column directly
into a QUuid. Storing a QUuid in a database was already supported for a
longer time.

Task-number: QTBUG-130389
Change-Id: I1b86749e2317c619b3aa8a4f9292c83c33fdcaad
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-18 21:36:46 +02:00
Christian Ehrlicher
0f9062ec71 QBoxLayout: don't crash on passing invalid index
Passing an invalid index gives an assertion in debug mode and crashes in
release mode due to an out-of-bounds access. Fix it by appending the
given widget (same as passing a negative index which is documented).

Pick-to: 6.9 6.8 6.5 6.2
Fixes: QTBUG-130275
Change-Id: Id0c245e185acc36e5d07cea1d22619bb0e9eee07
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-12-18 19:36:46 +00:00
Mårten Nordheim
1efcc0df6a Schannel: chop off garbage bytes if encryption fails
Because they would break communication (or loop infinitely) otherwise
since we use the presence of bytes in the returned buffer to know if
there is still something we need to transmit.

Amends 4e60a6b556d91ab797aebb7422666a685a726755

Pick-to: 6.9
Change-Id: If72c1a142d4567f69d78177250b0218c5ca999fd
Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2024-12-18 20:27:51 +01:00
Volker Hilsheimer
63db1082cb Regenerate the QCssScanner implementation
Using the lexgen tool after making it work with Qt 6 again. A lot of
changes in the resulting file, presumably because the hash implementation
is quite different in Qt 6 than it was in Qt 5, when the scanner was
generated last time.

Task-number: QTBUG-131842
Change-Id: I6e3633005f9cc0787abe3bab32790337fb7bdedb
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-18 20:27:51 +01:00
Topi Reinio
4051ec3356 Doc: Fix usage instructions for the \youtube macro
The example configuration included a space character that caused a
syntax error parsing the .qdocconf.

Replace the hardcoded qhp `QtDoc` project name with a placeholder.

Pick-to: 6.9 6.8
Change-Id: Iadf3a50e030f02182016ed9832f4f59d29f82c57
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2024-12-18 18:27:04 +00:00
Shawn Rutledge
70c61b12ef Always send QContextMenuEvent after the contextMenuEventType event
Both widgets and Qt Quick Controls are unable to avoid accepting the
right-click events (press and/or release) in at least some cases.
In the Windows UI pattern of allowing the user to select something by
pressing (and maybe dragging) with the right button and then getting
a QContextMenuEvent afterwards, it's sensible for the code that does
the selection to accept the mouse events, because that code is only
concerned with selection, not the context menu. And in Controls,
Pane is accepting all mouse events just to prevent propagation to
other controls underneath. (That might not be so great, but we don't
have a better way yet.) In legacy Qt Quick, accepting the event results
in an exclusive grab; so in fact, Pane gets the grab, so we can't use
that either, as a way to distinguish "stop propagation" from "this item
is handling it completely, nothing more needs to be done". So it
doesn't make sense for QWindowPrivate::maybeSynthesizeContextMenuEvent
to check the grabber either.

Amends 357c64a99607456133bfabf86d6b67162717cb29 and
84a5f50c7766c99f62b22bb4388137e0aa8dd13d

Pick-to: 6.9
Task-number: QTBUG-67331
Task-number: QTBUG-93486
Task-number: QTBUG-132066
Fixes: QTBUG-132073
Change-Id: I822cada05cfef27afe6a44faf170585f027061f7
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2024-12-18 17:15:25 +00:00
Lars Schmertmann
ab2a0438ef Avoid linter warning "AndroidGradlePluginVersion"
This is a Qt dependency that the user cannot influence.
We did this in  cfefce57a4ff446305cd1f839e7c5203bac7a6c5
with "GradleDependency"  before. It is a Qt dependency
that the user cannot influence.

Pick-to: 6.9 6.8 6.5
Change-Id: I01ef84eab7ab743d5ea9eb15208ef9c567dd2a43
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2024-12-18 16:40:39 +01:00
Mårten Nordheim
bbcf47a07d QThread: Link to QThreadPool::(set)serviceLevel
QThreadPool's functions already links to the QThread ones, but they didn't
link back.

From the API review.

Pick-to: 6.9
Change-Id: I02853d8110806f735b748d022a1cfaea5a72d603
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-18 12:26:09 +01:00
Mårten Nordheim
2c71fdf043 Http2: Ignore RST frames on already-closed streams
Some http servers like to send RST frames whenever they send their response.
The stream is already closed at that point so it's a little weird, but the
RFC doesn't disallow it, so we'll just ignore the frames.

Pick-to: 6.9
Fixes: QTBUG-132124
Change-Id: Ic26e249437b739830935e2f3feec572687579b21
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2024-12-18 12:26:01 +01:00
Alexey Edelev
6443528902 Remove _qt_internal_find_dependencies
Clean up the dead code according to TODO statement.

Pick-to: 6.8 6.9
Change-Id: I9bdf10067d3a1324d584cebc51cf4555f00f717a
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-12-18 12:12:23 +01:00
Marc Mutz
08320bfe2b QDebug: make std::optional stream operator SCARY
Piggy-back on the recently-added, type-erased, std::tuple stream
operator to handle std::optional the same way.

While std::optional doesn't support the Tuple Protocol, and we
therefore can't use putTuple() directly, we can still use
putTupleImplImpl() if we set up its arguments manually.

[ChangeLog][Potentially Source-Incompatible Changes][QDebug] The
std::optional streaming operator is now a member of QDebug, not a free
function. This breaks users that rely on the exact definition of the
operator (e.g. `operator<<(d, opt)`). A backwards-compatible fix is to
call the operator with infix notation (d << opt) only, and to avoid
const QDebug objects.

Pick-to: 6.9
Change-Id: Ib040d65953ca9d3892aee5bdb597d6d30a9694b1
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-12-18 07:12:02 +00:00
Volker Hilsheimer
ec011141b8 QPainterStateGuard: make InitialState enum scoped
Address comment from header review,
amends 9ecf47a8a8d11227ecf192246d7df7c2c4dc9105.

Task-number: QTBUG-132090
Pick-to: 6.9
Change-Id: Idddca104b93ee23f4bac8621f1087a0ae7a1fe24
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2024-12-17 20:45:09 +01:00
Friedemann Kleint
1dc15c11db Use QPainterStateGuard in examples
Complements 9ecf47a8a8d11227ecf192246d7df7c2c4dc9105.

Pick-to: 6.9
Change-Id: I65456f8fd34bf9d316b72c4286e1b15789309f7c
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2024-12-17 19:59:01 +01:00
Christian Ehrlicher
5731fe051e QStyleSheetStyle: Fix resetting fonts for subwidgets
When a compound widget is styled with a font through a property and the
default styling has no font settings, the font was not reset to the
parent font but left it the styled state.
Fix it by not resolving the current font when the style rule has no font
settings - use the parent font directly instead.

Fixes: QTBUG-131685
Pick-to: 6.9 6.8
Change-Id: I8e79423cfeff24143cd051b282503c4565125b4d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-17 19:59:00 +01:00
Volker Hilsheimer
8ae4e3efdf QPainterStateGuard: document that restore() asserts when already at 0
Address comment from header review, amends
9ecf47a8a8d11227ecf192246d7df7c2c4dc9105.

Task-number: QTBUG-132090
Pick-to: 6.9
Change-Id: Ie6eed6f83fcdde0f90514b6016a65905505073e0
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2024-12-17 16:44:14 +01:00
Wladimir Leuschner
438aa1524e WindowsQPA: Draw custom titlebar with QPainter
- Draw custom titlebars that are requested by setting the
  Qt::ExpandedClientAreaHint with QPainter instead of GdiPlus.
- Draw the application icon, in case it was set, for the custom titlebar
- Add DPI awareness to the custom titlebar

Pick-to: 6.9
Change-Id: I276e7d8948e5a436f1835d96b59756b7237f63d2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2024-12-17 16:14:00 +01:00
Timur Pocheptsov
7740ac36d2 Revert "qnsview_drag: only ignore key modifier while dragging 'within the application'"
This reverts commit 4332cb313469de1525afe3cddd792d7bc7e08a14.
The original idea of distinguishing between context (outside/within application)
is not working anymore - it's always outside (except the moment when
a mouse pressed inside the window, which is immediately followed by
'outside application' context). So in fact we never ignore key
modifiers.

Fixes: QTBUG-132091
Pick-to: 6.9 6.8
Change-Id: I560a48ccf8f8ee1a55f812be6af18b1dd7e25c78
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2024-12-17 15:12:30 +01:00
Bartlomiej Moskal
e59308c511 Android: Fix for multi-ABI build in androiddeployqt
7499fd0229d63f969bf6ca58d3b764b96395bed2 commit cleans up the localLibs
to not add dependencies to the libs.xml file as they will not be
satisfied.

Mentioned change created a regression with multi-ABI build. It happens
because in qtDependencies[ARCH] container, some libs just have different
atchitecture prefix.

This commit remove architecture prefix when checking libs in
qtDependencies container.

Fixes: QTBUG-131707
Pick-to: 6.8 6.9
Change-Id: Iae54779bfa4bd143ec35353604724d8ec4e35ef2
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2024-12-17 13:36:40 +00:00
Ivan Solovev
56114f4d1e Change QCommandLineParser::showMessageAndExit() argument order
Looking at other similar Qt APIs, the type argument usually comes first.
The typical related examples can be QMessageBox() constructor taking
QIcon as a first parameter, and qFormatLogMessage() function, taking
message type as a first parameter.

This patch changes the order of arguments, so that MessageType enum
comes as a first argument.

Amends bad618606d64e943e3fa78e7d1dbc8e1fab55480.

Found in Qt 6.9 API review.

Pick-to: 6.9
Change-Id: Ibbdef755a8676a2c556fe7f1c95009ad51320b98
Reviewed-by: David Faure <david.faure@kdab.com>
2024-12-17 14:36:40 +01:00
Ivan Solovev
6692beace9 Add docs to the new QCommandLineParser::MessageType enum
As a drive-by: move the \since command in the showMessageAndExit() docs
to the right place.

Amends bad618606d64e943e3fa78e7d1dbc8e1fab55480.

Pick-to: 6.9
Change-Id: I4e6e6d63929029879867624e4007941edfca9cd9
Reviewed-by: David Faure <david.faure@kdab.com>
2024-12-17 14:36:40 +01:00
Ivan Solovev
14cc2591ac Specify an underlying type for QCommandLineParser::MessageType
And also add a trailing comma to the last element of the enum to
minimize future diffs.

Amends bad618606d64e943e3fa78e7d1dbc8e1fab55480.

Found in Qt 6.9 API review.

Pick-to: 6.9
Change-Id: I1a30c344967005c9abc73e59980e56626e09cd7c
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-17 14:36:40 +01:00
Tor Arne Vestbø
2e80e74f37 QCocoaDrag: Only update m_lastView when it actually changes
The underlying QObjCWeakPointer used to track the view requires
a bit of bookkeeping, so avoid updating its value unless the
view actually changes.

Pick-to: 6.8 6.9
Change-Id: I6a1aeaf0e6e0eb221d55de00c8f30259832e58fa
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-17 13:45:36 +01:00
Tor Arne Vestbø
92012333d1 QObjCWeakPointer: Clear existing associated object on assignment
If the existing m_object is the same as the incoming object the
call to objc_setAssociatedObject in trackObjectLifetime will
release the existing WeakPointerLifetimeTracker after assigning
a new one, which means we'd clear the QObjCWeakPointer's object.

We now reset the state up front.

Fixes: QTBUG-132256
Pick-to: 6.8 6.9
Change-Id: If2c08840d465ae6d190c87a4720a537fe9caa8dc
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2024-12-17 13:45:36 +01:00
Robert Löhning
a56a6ba22d QRadialGradient: Don't initialize focal radius twice
Change-Id: I532c1097604a3c59747d05c88a64d7ed97f9addd
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
2024-12-17 13:04:37 +01:00
Marc Mutz
8553ffd8d1 qthreadstorage.h: fix position of namespace macros
The file contains two implementations of the class template, one for
QT_CONFIG(thread) and one for without. Both are in the QT_NAMESPACE,
but each provided their own QT_{BEGIN,END}_NAMESPACE macro pair.

This is unneeded and may throw off scripts which use the macros as
insertion positions (like includemocs, which, however, operates on
.cpp files, not headers).

To fix, move the namespace macro pair to be around the #if
QT_CONFIG(thread) block.

Pick-to: 6.9 6.8 6.5
Change-Id: I56c1f9a4ef7df0fba54c72d8a213fa92573b826c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-17 11:08:35 +01:00
Yuhang Zhao
f6af3a5816 Windows: Fix title bar size calculation
The title bar calculation is terribly wrong and was
missed during review.

Pick-to: 6.9
Change-Id: I0c7a860e747465e6a5e4d8aa5415a9701cf170fd
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2024-12-17 07:58:37 +00:00
Dheerendra Purohit
f76c9bf823 Copy const attribute of method in QMetaObjectBuilder::addMethod()
const attribute of prototype object method in
QMetaObjectBuilder::addMethod() is not copied. auto test failed due to
this missing functionality.

Copy const attribute of method in QMetaObjectBuilder::addMethod() from prototype object.

Task-number: QTBUG-126849
Change-Id: Iaa4042c2ac50c57eacb6b9821163488d82f7a0be
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-17 09:45:59 +05:30
Dheerendra Purohit
7de17a91bc Make dumpObjectTree() and dumpObjectInfo() invokable from QML
[ChangeLog][QtCore][QObject] QObject::dumpObjectTree() and
QObject::dumpObjectInfo() are now invokable, allowing them to be used
from QML.

Fixes: QTBUG-126849
Change-Id: I98df0f57013eaf8e873e8901a4ada527e5ec605f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-17 04:15:57 +00:00
Christian Ehrlicher
15a1ae90f5 QAbstractItemView: use 'int' as datatype for updateThreshold
... to sync it with the rest of the api.
This amends ff339819925ab550c48b53d9baaba43e5adebfaa.

Pick-to: 6.9
Task-number: QTBUG-124173
Change-Id: I0ed4681bf7d3717f84a7e888affb0c8cae877c35
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-16 21:29:23 +01:00
Volker Hilsheimer
af760da541 QSqlQueryModel test: don't copy a QSqlQuery
Move the query into the model, and use a local scope to make sure that
we don't use the moved-from query later.

Pick-to: 6.9
Change-Id: I9d216e770733af8b0771280276dba0775209a802
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Dheerendra Purohit <dheerendra@pthinks.com>
2024-12-16 21:18:02 +01:00
Tor Arne Vestbø
d884abaf8b Document that QPlatformTheme::standardPixmap should always be a 1x pixmap
This reverts 59bbfb17db563d7e62b9f3158dab3cc6e7e68acd and
c853054910552f5fef04797222dde0d29a0c340d, as that approach
was causing issues for QCommonStyle::iconFromWindowsTheme,
for example in situations where the system has a 1x and 2.5x
screen, and the user requests a 16x16 pixmap or icon via
QStyle::standardPixmap or QStyle::standardIcon. In that
situation our smallest pixmap is 40x40, and we need to
downscale, causing blurred results on a 1x screen.

Pick-to: 6.9
Change-Id: Ifa6e15d37d15954df689253c32eaa779885c567b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-16 21:13:17 +01:00
Christian Ehrlicher
66d42b62b6 Windows11Style: adjust subline color in editable widgets in dark mode
The color of the subline in editable widgets was black in light and dark
mode. Fix it to use white in dark mode to make it visible. Move it out
into own helper function since it's used in at least three places.

Pick-to: 6.9 6.8
Task-nubmer: QTBUG-131585
Fixes: QTBUG-131586
Change-Id: Icca2b142a1ce0c3d7f722baa6d3635bae5950e1c
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-12-16 21:13:17 +01:00
Eskil Abrahamsen Blomfeldt
d5cef74d8d Fix DirectWrite subpixel antialiasing on BGR screens
On monitors where the subpixel arrangement is blue, green, red,
our DirectWrite rendering would give the wrong subppixel
antialiasing, causing color fringes on text.

Like we do with Freetype, we determine subpixel arrangement of the
primary screen and use this as the default.

Pick-to: 6.8 6.9
Change-Id: I9ce7025449106a2376bd0ed02ce07b59c79438bd
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2024-12-16 20:37:42 +01:00
Christian Ehrlicher
a90d9f4823 QStyleOptionViewItem: document 'widget' and 'locale' member
These two members were added during Qt4 times but never documented.

Pick-to: 6.9 6.8 6.5
Change-Id: Ife4abfc6d8883f4c26ce5b95d5c0cfd3adcbd6bf
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
2024-12-16 20:37:42 +01:00
Eskil Abrahamsen Blomfeldt
aaf7437db3 Support variation selector when emoji segmenter is disabled
This amends cb2633468413d8c2a9e28d4c4a10b25e90dd3116.

The patch excluded the ad hoc parsing of variation selector
except when Qt was built without the emoji segmenter. The
reasoning being that the emoji parsing handles this correctly
now.

However, when setting the QT_DISABLE_EMOJI_SEGMENTER variable
in the environment, this is supposed to work as a fail safe
which gives you the original behavior, in case there are
regressions. Therefore, the variation selector handling needs
to be run also when this environment variable is set.

Pick-to: 6.9
Change-Id: I2669d29016a552775461aad13e50459baecdc26f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-16 19:37:41 +00:00
Frédéric Lefebvre
c316712fb8 Split auto test palettePropagation2()
palettePropagation was a fairly long test function and was testing more
than one thing at once.

Split palettePropagation2() in two, creating the new auto test
palettePropagation3() that verify if the text color propagation is
correctly being ignored when setting a new palette for buttons. This was
previously tested in palettePropagation2().

palettePropagation2() now only tests if colors are propagated correctly.

Both function are now shorter, easier to understand and maintain.

Change-Id: Icdad272d4cdc437595c0a31ab231d134cb3b5d86
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-12-16 18:31:58 +00:00
Marc Mutz
54d47f8390 QByteArrayView: add a ctor for arrays of unknown bounds
This appears to not have worked, ever, so add it as a new feature, for
view API symmetry, not as a bug-fix.

The new constructor is available for all compatible byte types,
because it is more like the (ptr) constructor (which is available for
all compatible byte types) than the known-size-array constructor
(which is only available for char).

This does not affect QB/QBV overload sets, since they could exist
ambiguity-free only if one of them is a Q_WEAK_OVERLOAD.

The GHS compiler doesn't like the CanConvert static_asserts, so
comment them out for it. The functionality itself is tested by
the fromArrayWithUnknownSize test.

[ChangeLog][QtCore][QByteArrayView] Made construction from arrays of
unknown size compile. Such arrays will use the const Byte*
constructor, determining the size of the array at runtime.

Task-number: QTBUG-112746
Pick-to: 6.9
Change-Id: I201033656f123b09644e5de447cd5d7b038e5154
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-12-16 18:50:06 +01:00
Eskil Abrahamsen Blomfeldt
9a6036dea2 doc: Clarify usage of QFontMetricsF instead of QFontMetrics
A common source of issues is that people do not consider that
fonts can have fractional metrics and use QFontMetrics for UI
purposes, causing bounds and eliding to be inaccurate.

This is not very surprising, since the class name sounds very
much like what you should prefer by default and the docs
didn't even contain links to the QFontMetricsF class.

It might make sense to deprecate the class, since it really
does not serve any useful purpose, but for now we at least
document the issue up-front so that users can easily find
the alternative.

Pick-to: 6.5 6.8 6.9
Task-number: QTBUG-132102
Change-Id: I69756c561e5dee448a9d0a7d85af1a9b15ff1ae3
Reviewed-by: Nodir Temirkhodjaev <nodir.temir@gmail.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-16 18:50:06 +01:00
Joerg Bornemann
1ab1070f21 CMake: Remove unused _import_prefix variable from config packages
The usage of this variable was removed in the past, and there's no
reason to keep it around.

Change-Id: I786acc52ed903b20d4eb14bc057b45bff72ceffe
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2024-12-16 18:50:06 +01:00
Marc Mutz
a0e6539848 QStringView: refuse construction from QStringRef
When QStringRef was moved out of QtCore, it was also incorrectly
removed from the if_compatible_container constraint, causing
QStringView{sr} to still match the general container QStringView ctor
overload, which doesn't preserve null'ness if data() doesn't return
null. By refusing to provide a constructor from QStringRef, we force
the compiler to use QStringRef's implicit conversion operators
instead.

This transitively affects QAnyStringView in the same way.

The tests can, naturally, only be in qt5compat, so define a macro to
communicate to tst_QStringRef whether it compiles against a fixed
QtCore or not.

Fixes: QTBUG-122797
Fixes: QTBUG-122798
Pick-to: 6.9 6.8 6.5
Change-Id: I64b75a8e421d2b6185615e3288ce3ad7fd8f15f9
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-12-16 09:19:16 +00:00
Evgen Pervenenko
1299aaa231 QNCM[Mac]: Update from SCNetworkReachability to Network framework
Since SCNetworkReachability is deprecated,
the implementation is now updated to use the Network framework.

[ChangeLog][QNetworkInformation] Replace deprecated
SCNetworkReachability implementation with Network framework (iOS, macOS)

Fixes: QTBUG-132103
Change-Id: Iff4a667fd07002451b7d49cc8fd069945d426aab
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Vladimir Belyavsky <belyavskyv@gmail.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
2024-12-14 15:37:54 +03:00
Andy Shaw
311ac55f11 SQLite: Fix attrition file to have right version number
Pick-to: 5.15 6.5 6.8 6.9
Change-Id: I9fea5c8d19209c44b16916645e600735de929d80
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2024-12-13 20:02:34 +01:00
Assam Boudjelthia
60f7821237 Android: handle quotes in hard-coded namespace in build.gradle
Remove quotes from the namespace values if they're set
directly to build.gradle.

Fixes: QTBUG-132150
Pick-to: 6.9 6.8
Change-Id: I7f5e132c2600bf5079850c99dc500b1dff7e6a96
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-12-13 18:28:52 +00:00
David Redondo
11518e92c2 Provide D-Bus de-/marshalling operators for std::tuple
Currently Qt provides only generic operators for pairs which can be used
generically for structs with two elements. A tuple is the natural fit
for dealing generically with structs that have more elements.
This can be helpful when wanting to make a one-of calls to APIs that
take or return such types or deferring to tuple marshalling without
having to write custom operators.

[ChangeLog][QtDBus][QDBusArgument] Added generic support for
marshalling and demarshalling D-Bus STRUCTs from/to std::tuple.

Change-Id: Id5cf49063c9b43ed68ad7821111376f6fa887a73
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-13 19:04:27 +01:00
Magdalena Stojek
95f02adf75 Output both global and local data tags in benchmark result header
Modified QPlainTestLogger::printBenchmarkResultsHeader() to
concatenate and display both global and local data tags, in
the benchmark result header, in the format `global:local`.
If only one tag is available, it is printed alone.

Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-127522
Change-Id: Ic9f3c712ef3f6858aad2546b80d8867ce860b644
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
2024-12-13 19:04:27 +01:00
Mårten Nordheim
1318232c05 tst_QBuffer: fix warning about overflow
The constexpr in the if is ignored here, use #if instead

Change-Id: I9a81955e53e9da72e2302e128bf86b03eaf846e7
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2024-12-13 18:20:00 +01:00
Michael Weghorn
ca4334bc96 QMenu: Accept accelerators typed on keypad
Add Qt::KeypadModifier (and the combination with Qt::AltModifier) to the
modifiers that may be set in a key event in order to trigger a menu
action via its accelerator.

Otherwise, an action that has a number set as the accelerator (e.g.
using text "&1 Exit"), cannot be triggered by typing the corresponding
number on the keypad.

Fixes: QTBUG-73390
Pick-to: 6.9 6.8
Change-Id: I0fa63b0c5f23823c61e159fcc72f7245215f8aae
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-12-13 17:20:00 +00:00
Christian Ehrlicher
aa341ecca8 Style: pass widget to styleHint() where appropriate
QStyle::styleHint() take the QWidget as optional third parameter. Add
this to calls to styleHint() where appropriate.

Fixes: QTBUG-2501
Pick-to: 6.9 6.8
Change-Id: Id4e4158cc889236064f2f618495608736607d457
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-13 16:46:16 +00:00
Thiago Macieira
176baa955a tst_QMetaType: remove defined() test
This was testing implementation details that aren't that important any
more and are about to be removed.

Change-Id: I222a463f7fff9ff2de2cfffd77d8cec77510a57e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-12-13 07:53:10 -08:00
Thiago Macieira
438b2f2d60 Q*Application: move the compressEvent() virtual to the Private class
One of the parameters is the QPostEventList, which is declared in
qthread_p.h:
   class QPostEventList : public QList<QPostEvent>
and is thus private API anyway. This also requires the ELFVERSION: token
in qthread_p.h to avoid marking every class derived from Q*Application
as needing private Qt ABI.

We can't remove the virtual in Qt 6, so we keep the fallback
implementations to just forward to the Private::compressEvent() call.

I've elected to mark the QApplication's override as final.

Change-Id: I49a46f42e62bcaf7db69fffd12a664d8720bbe46
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-13 07:53:10 -08:00
Thiago Macieira
902058e750 QSharedMemorySystemV: fix shm vs sem typo
Fixes: QTBUG-132053
Pick-to: 6.8 6.9
Change-Id: Ia4f2bdc8edff91020f13fffd79261a9feaf2f496
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-12-13 09:53:10 -06:00
Thiago Macieira
c1bc98da02 QMutex/FreeBSD: mark the functions as noexcept as it always has futex
See qfutex_freebsd_p.h.

Pick-to: 6.8 6.9
Change-Id: I7e7bbb8387ae2e7b0c39fffd65c7b03e3a65a853
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2024-12-13 15:53:09 +00:00
Thiago Macieira
e48fe10e54 QMetaType: remove the temporary QMetaTypeTypeFlags compatibility
Amends 44876fb45e702c2554fca98ed19af57feb1c0511.

Pick-to: 6.9
Change-Id: I5ea354bcb6847e996081fffd012130562999d5c4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-12-13 12:53:09 -03:00
Fabian Kosmale
47be32b761 moc: Always indentify as moc
External tools might rely on the output of "moc --version" to identify
moc, and, depending on how robust their parsing is, could break if the
reported name does not equal "moc".

Explicitly set the application name to moc, so that even if the moc
binary gets renamed and invoked via a symlink, it will still correctly
identify itself.

This might help with both binaries from the Qt Company's installer, as
well as with distros which rename moc to moc6.

Pick-to: 6.9 6.8 6.5
Task-number: QLS-1605
Change-Id: Id85e2ffa17d445213da0b37e7bd038d7b68e2c2a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2024-12-13 16:53:09 +01:00
Jani Heikkinen
5b805f54c2 Bump version to 6.10.0
Change-Id: Iad7b22da970e4e95816aaa0643206ecf502e23af
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2024-12-13 14:54:23 +00:00
Ivan Solovev
083ebfa1a5 [docs] Add QSpan details to overview of C++20 features
Document that QSpan exists because we cannot use std::span, and
explicitly point to the differences between QSpan and std::span.

Task-number: QTBUG-128837
Pick-to: 6.9 6.8
Change-Id: I54f406e3306ee1da136107323887f0c87f94ff9b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-12-13 14:14:00 +00:00
Eirik Aavitsland
0ace5ba035 Fix in-place conversion of certain QImage formats
In the copying/transcription of the generic converter to the generic
in-place converter, a test for Format_RGB32 destination format was
mistakenly replaced with test of source format. The result was that a
suboptimal pixel store function was selected, and the resulting image
data could end up with non-0xff in the unused alpha field.

Task-number: QTBUG-132051
Pick-to: 6.9 6.8
Change-Id: If3ebf5fdd7ab6e377c8ad479ea38ce665f922b7c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2024-12-13 14:13:59 +00:00
Edward Welbourne
2c0d87149c Remove an unused constant defined in tst_QDate
Change-Id: If00abed2aec9bf8f1d88ff4915c60a3e6e9dc74e
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Magdalena Stojek <magdalena.stojek@qt.io>
2024-12-13 14:47:44 +01:00
Edward Welbourne
98ddef287c Adjust unknown year to leap if it helps get a valid date
Where QDateTimeParser doesn't know the year and the day of month is
out of range for the known month and uncertain year, try adjusting to
a leap year to see if that solves the problem.

Change-Id: Ic1c126fba9f0901447503fda46c9830834c30038
Reviewed-by: Magdalena Stojek <magdalena.stojek@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-13 14:47:44 +01:00
Edward Welbourne
72519aeb23 Fix assertion failure on parsing Feb 29 in a non-leap year
If there's no way to resolve an actual date with the data parsed, then
the date-text given is invalid, so don't try to fix it up.

Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-132115
Change-Id: Ic6821bd01394d4dba1be1d25806c372800f8176b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-12-13 13:47:44 +00:00
Edward Welbourne
5d5c8d277a Fix typos in qstring.cpp (noticed while reviewing other changes)
Pick-to: 6.8 6.9
Change-Id: Ief8a9c429b5cdf424e0c3a57d15b1fcb4fdc963c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-13 14:46:12 +01:00
Mårten Nordheim
6c8b6acc89 QHash: fix small performance regression when detaching with resize
There are two QHashPrivate::Data constructors (and two overloads of
::detached()). Initially the Data ctor that takes a new size always
assumed a resize was happening, and any place where there _may_ be a
resize we would usually detach then rehash.

In an effort to avoid the detach+rehash and instead call detach(d, size)
without the performance overhead of rehashing the call to
reallocationHelper() in this overload of the ctor was changed to verify
that a rehash was actually needed. This had the unfortunate side-effect
of making the compiler no longer inline the reallocationHelper()
function, and it no longer expanded the if-expression with the constant
so it was doing a tight copy-loop with a potential branch in the middle.

In this patch we revert that and make the bool a template argument to
highlight that it should be a constant for better performance (but also
leaving a comment.) Also mark it Q_ALWAYS_INLINE, it has two uses and
they both take advantage of the inlining + expanding the expression.

In theory this might have had an impact on QHash::reserve() calls,
though this code is only relevant when reserve() would cause growth so
the performance regression would hopefully be small compared to all the
other work that would also be needed.

Reverts 45c137d797a85c694897e8b1c5099abacc16e2f5

Pick-to: 6.9 6.8
Change-Id: I0d2076a9ded8ca816c54d6ce42d472a23bcbc9fd
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-13 14:46:12 +01:00
Mårten Nordheim
ac2b0b958e QHash: call the different detached() overloads depending on resize
Instead of using just the detached() overload taking a new size, call
the two un-sized one when not resizing. The unsized overload is faster
because it is inlining the reallocationHelper() function and expanding
a branch by way of a constant.

And drop the call to rehash in the !isDetached case, if we enter this
branch we willfully 'attach' the detach guard to keep the key and values
alive.

Follow-up change will fix the sized detach() to use a constant again.

Amends d9ad2251d9fff85a18ce5afc62bcb1230cd2820d

Pick-to: 6.9
Change-Id: Ia1640766b898610d12b5df20d83cefe5ca2d4c36
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-13 14:46:12 +01:00
Marc Mutz
2d2ee56942 QLatin1StringView: put qstringfwd.h in control of Q_L1S_VIEW_IS_PRIMARY
Less duplication, matches what we do for q_no_char8_t namespaces, too.

Amends 94addad4dd1c89df9c6820d34b9a90424456c492.

Pick-to: 6.9 6.8 6.5
Change-Id: I5d98babcb66d1196d3aed31c33289a1b11212a3d
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-12-13 11:27:28 +00:00
Marc Mutz
8404c21152 QStringView: use qstringfwd.h
... instead of fwd-declaring a bunch of stuff manually.

Also move the fake QDoc decalaration of a "class QUtf8StringView"
over.

Pick-to: 6.9 6.8 6.5
Change-Id: I80bc3240d69f69602c127fc0e8fe694dd46765f1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-12-13 12:27:28 +01:00
Marc Mutz
5def8ff180 qstringfwd.h: don't include qglobal.h
qstringfwd.h is supposed to be a lean header, dragging in all of
qglobal.h perverts the purpose.

This also helps with certain circular-dependency issues that
appeared when attempting to use this header in other low-level
headers.

Amends abe3b4c9b947de5e55085b37840e0d1d6f3aae42.

[ChangeLog][Potentially Source-Incompatible Changes][QtCore] The
qstringfwd.h header no longer includes qglobal.h. A
backwards-compatible fix is to include qglobal.h yourself instead of
relying on the transitive include.

Pick-to: 6.9 6.8 6.5
Change-Id: I1726fccfd13b3a058abaf800c1bbf02c320143a4
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-12-13 12:27:28 +01:00
Ulf Hermann
e0ef713a2c Android: Fix some warnings
Use a static logging category where possible, and check the return value
of QFile::open.

Pick-to: 6.9
Change-Id: Ieda9f7874d1b88d9bfeb593243eb867d0c274e9f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2024-12-13 11:27:27 +00:00
Michael Weghorn
0f521a0337 Drop now unused lambda capture
tokenProvider is unused inside the lambda since
638c9bd2595704606b53ba319c67568b479f9fc0,
triggering

        .../qt5/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp:574:32: error: lambda capture 'tokenProvider' is not used [-Werror,-Wunused-lambda-capture]
          574 |                         [this, tokenProvider](const QString &token) {

in a local clang 19 build.

Pick-to: 6.9 6.8
Change-Id: I69f7884afee46859c66a46edce3e7a8001c60e22
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-12-13 11:42:21 +01:00
Kai Köhne
d3dad28a51 Doc: Fix links to QIODeviceBase:: flags
Pick-to: 6.8 6.9
Task-number: QTBUG-131484
Change-Id: Iee545986d4fb4765086fecce6532092d4b691ae8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-13 09:10:15 +00:00
Kai Köhne
adaf1fb107 Doc: Improve QTemporaryFile::open() descriptions
Explain the behavior of open() in detail, including the edge
cases (reopening a file). Fix links to QIODeviceBase::OpenMode
flags. Use explicit links to make linking more robust. Use
the same parameter name 'mode' as in the base class.

Pick-to: 6.8 6.9
Task-number: QTBUG-131484
Change-Id: I5d01b3bb48a7a439b93c144e6d38482607de8d33
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-13 09:10:15 +00:00
Kai Köhne
4e85a4f401 Doc: Improve QProcess setStandardOutputFile description
Fix links to OpenMode flags. While at it, make links explicit so
that future changes breaking implicit linking will cause errors.

Pick-to: 6.8 6.9
Task-number: QTBUG-131484
Change-Id: I20b80014eadcbcba6ebebab1ff4db4c345dd434a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-13 09:10:15 +00:00
Kai Köhne
647bee6715 Doc: Improve QFile::open description
Force the mentioned QIODeviceBase flags to be links. Use fully
qualified name for the first flag mentioned, but use the short form for
the rest to improve readability.

Mark true and false to be written in code style.

Task-number: QTBUG-131484
Pick-to: 6.8 6.9
Change-Id: Iebb0f9c6df382327bc5980e9e06c11deb6658291
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-13 09:10:14 +00:00
Kai Köhne
334460407b Doc: Improve QBuffer::open description
Explain the method, instead of just linking to the base method.

Call the argument 'mode' instead of 'flags', like it is done in
the base class.

Force the mentioned QIODeviceBase flags to be links. Use fully
qualified name for the first flag mentioned, but use the short form
for the rest to improve readability.

Pick-to: 6.8 6.9
Task-number: QTBUG-131484
Change-Id: I8e9668ffc095ec261e2be54a2dcf16a32e4cb441
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-13 09:10:14 +00:00
Tim Blechmann
f84ce2ae42 qshareddata.h: remove unused header
<functional> was added for std::less, but it's not required anymore and
can be removed (found by clangd)

Change-Id: Iadceacaf75786ba97a55ddd3694ab7e6550e9c0b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-13 12:49:20 +08:00
Marc Mutz
bc4105c843 qstringfwd.h: add missing QString fwd decl
qstringfwd.h should probably fwd declare QString, too :o

Amends abe3b4c9b947de5e55085b37840e0d1d6f3aae42.

Pick-to: 6.9 6.8 6.5
Change-Id: I80558c92d1144ead0aade410a8b1810713fed701
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-12 21:07:00 +01:00
Marc Mutz
e64fd05fec tst_QString: extend arg() tests with enums w/o explicit underlying_type
The QtDeclarative code causing QTBUG-131906 hits UB, because it tries
to store -666 in an enum {A, B}, which has a valid range of [0,1],
therefore its underlying_type is uint, yet, as per [conv.prom]/3¹,
integer-promotes to _int_ instead, so in Qt 6.8 would cause the
arg(int) overload to be called, outputting -666, while in Qt 6.9, it's
treated (correctly) as an unsigned value, outputting -666's two's
complement, a positive value.

Add a version of the scenario that does not cause UB.

¹ Thanks to Ahmad Samir for digging up the pertinent legalese.

Task-number: QTBUG-131906
Pick-to: 6.9 6.8 6.5
Change-Id: Iba1a04de523a0b4cd1c87deea40c643cf16df14f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-12-12 21:06:59 +01:00
Marc Mutz
a38cebfe23 qsocketnotifier.cpp: un-break -unity-build
qsocketnotifier.cpp is using a #define to activate a second overload
of QSocketNotifier's activated() signal.

In unity-builds, this overload becomes visible to other TUs and breaks
new-style connect()s¹. In PCH builds, the define comes too late (the
qsocketnotifier.h header was already included by the pch header,
without the define).

Fix by adding qsocketnotifier.cpp to NO_PCH_SOURCES (thereby to
NO_UNITY_BUILD_SOURCES, too).

¹ and the signal's use of QPrivateSignal makes disambiguation by
  qOverload(), or assignment to a function pointer, impossible.

Amends 487dd80bce9c6006f349ccb09222e1c308200f0a(!).

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I40ca3b90f7ecc3116ae78dc952583efa299bcedb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2024-12-12 21:06:59 +01:00
Marc Mutz
057defe283 qsettings.cpp: really un-break -unity-build
The use of Space was still ambiguous. Says GCC 14:

  qsettings.cpp: In static member function ‘static bool QConfFileSettingsPrivate::readIniLine(QByteArrayView, qsizetype&, qsizetype&, qsizetype&, qsizetype&)’:
  qsettings.cpp:1564:82: error: reference to ‘Space’ is ambiguous
   1564 |     while (lineStart < dataLen && (charTraits[uint(uchar(data.at(lineStart)))] & Space))
        |                                                                                  ^~~~~
  In file included from unity_0_cxx.cxx:277:
  qjsonparser.cpp:217:5: note: candidates are: ‘<unnamed enum> Space’
    217 |     Space = 0x20,
        |     ^~~~~
  qsettings.cpp:1523:8: note:                 ‘SettingsImpl::<unnamed enum> SettingsImpl::Space’
   1523 | enum { Space = 0x1, Special = 0x2 };
        |        ^~~~~
  qsettings.cpp:1605:71: error: reference to ‘Space’ is ambiguous
   1605 |                 while (i < dataLen && charTraits[uchar(data.at(i))] & Space)
        |                                                                       ^~~~~
  qjsonparser.cpp:217:5: note: candidates are: ‘<unnamed enum> Space’
    217 |     Space = 0x20,
        |     ^~~~~
  qsettings.cpp:1523:8: note:                 ‘SettingsImpl::<unnamed enum> SettingsImpl::Space’
   1523 | enum { Space = 0x1, Special = 0x2 };
        |        ^~~~~

Fix by making Space and Special local aliases (contexpr variables)
instead of importing the whole SettingsImpl namespace.

Amends 4ff65f0e5615b1132ec13c6eeba3647162d8dd0f.

Pick-to: 6.9 6.8 6.5
Change-Id: I9e8f2422885121fb02938261fbae6231e62ae46d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2024-12-12 21:06:59 +01:00
Marc Mutz
57fab6a1c2 qresource.cpp: fix -unity-build
GCC 14 complains:

  In file included from unity_0_cxx.cxx:121:
  qresource.cpp:283:7: error: ‘QResourcePrivate’ has a field ‘QList<{anonymous}::QResourceRoot*> QResourcePrivate::related’ whose type has internal linkage [-Werror=subobject-linkage]
    283 | class QResourcePrivate {
        |       ^~~~~~~~~~~~~~~~

(Hot-)fix by adding qresource.cpp to NO_UNITY_BUILD_SOURCES.

Amends fe6dda9bb9310878b408b2421f60acb7135bd8ba.

Pick-to: 6.9 6.8
Task-number: QTBUG-132114
Change-Id: Ic414d1cf9e4dad94d4263b3657d31df896c4e417
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-12 21:06:59 +01:00
Thiago Macieira
b98cf4fc4a QString::fromUcs4: use std::char_traits or wcslen() to find the size
... when the user passes size = -1. std::char_traits<char32_t>::length()
doesn't appear to be an any better implementation than our simple loop,
but maybe some compiler will optimize it.

wcslen() is usually optimized in the C libraries, even for Unix
platforms that hardly ever use it (it's used as a fallback in qustrlen()
for non-x86 Windows systems).

Pick-to: 6.8 6.9
Change-Id: Ia143270869a3a7cf5754fffdc17e500fc454397b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-12-12 19:38:02 +00:00
Thiago Macieira
973d0c4c51 QString: update docs to prefer "UTF-32" over "UCS-4"
They are now the same, but the name UTF-32 is preferred over UCS-4.

The original ISO-10646 UCS-4 encoding was allowed to use all 31-bit code
units, from 0 to 0x7FFFFFFF[1] including those above 0x10FFFF, which
correspond to UTF-8's five- and six-byte sequences. Unicode doesn't
allow that and restricts the UTF to the range possible in UTF-16.

Renaming the functions is left as an exercise for the reader.

[1] https://en.wikipedia.org/wiki/UTF-32#History

Pick-to: 6.8 6.9
Change-Id: I2f29db62b974cb689585fffd9a6434ae252a7651
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-12-12 19:38:02 +00:00
Ulf Hermann
529ebb3170 Use inline namespaces rather than "using" for logging categories
Amends commit fa4bd30caa079a3b1e5eac1bb4f17365f456b8f9.

Fixes: QTBUG-132111
Pick-to: 6.9
Change-Id: Iad7969a1841b8cea162e4b0e6624d02313618ef1
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-12 20:38:02 +01:00
Marc Mutz
734bd05d0a Q{Any,Utf8}StringView: fix construction from arrays of unknown size
Like QStringView's, these classes' documentation promised
is_constructible<View,Char[]>, but failed to deliver, because neither
the (const Pointer&) nor the (const Container &) compile for arrays of
unkonwn bounds, and the (const Char*) one is just a QDoc fake.

Apply the same fix as for QStringView: Add a ctor specifically for
arrays of unknown bound, delegating to the (ptr) overload.

The GHS compiler doesn't like the CanConvert static_asserts, so
comment them out for it. The functionality itself is tested by
the from*ArrayWithUnknownSize tests.

[ChangeLog][QtCore][QUtf8StringView/QAnyStringView] Made construction
from arrays of unknown size compile. Such arrays will use the const
Char* constructor, determining the size of the array at runtime.

Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-112746
Change-Id: I7acdcae3c5bdf80a0bed673e621d53ef34a92a1e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-12 20:38:01 +01:00
Marc Mutz
67990c16a6 tst_QStringView: verify that char16_t[] args aren't ambiguous for QS/QSV overloads
They are not.

Pick-to: 6.9 6.8
Task-number: QTBUG-112746
Change-Id: I2a20d68543f5914690acbcb4f214b1d98681de6a
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-12-12 20:38:01 +01:00
Marc Mutz
56faffd92b QStringView: fix construction from arrays of unknown size
The original idea (8b5aa7b6c40d70a7ec15b3ea485f28a142fb247c) of the
separation of array and pointer ctors was to determine string literal
sizes at compile-time in C++11's limited constexpr semantics.

But when the scanning for NUL characters was added to the array ctor
in 107ff4c1d6b5da2cb11c65b2bd9106817f7fdb02, the distinction between
the two ctors became meaningless, because we were able to assume
post-C++11 constexpr to make the Char(0) scan a compile-time action.

Finally, 9e1dc1e8a9fda1a7576cc6377c8a36decff631eb removed the array
ctor in favor of the generic Container ctor. I didn't check whether
the old code handled arrays of unknown size, as in

    extern const char16_t str[];
    QStringView sv = str;
    ~~~
    const char16_t str[] = "str";

but std::size() (and therefore if_compatible_container) surely bails
on such arrays, and if_compatible_pointer also SFINAEs out. As a
consequence, such arrays cannot be used to construct QStringViews atm.

Fix by adding a new constructor for arrays of unknown size, delegating
to the existing pointer overload.

The GHS compiler doesn't like the CanConvert static_asserts, so
comment them out for it. The functionality itself is tested by
the from*ArrayWithUnknownSize tests.

[ChangeLog][QtCore][QStringView] Made construction from arrays of
unknown size compile. Such arrays will use the const Char*
constructor, determining the size of the array at runtime.

Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-112746
Change-Id: Ifdb217350d93d38f081c99f14661975491d32076
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-12 20:38:01 +01:00
Ahmad Samir
7ecb12b2c7 QtSql: fix GCC -Wextra-semi warnings after member function definitions
Pick-to: 6.9 6.8
Change-Id: I5b65f543d7a36386181e493d8b9ce0267132d686
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2024-12-12 21:38:01 +02:00
Ahmad Samir
458fb41e51 Fix GCC -Wextra-semi warnings with Q* macros
Namely, Q_ENUM, Q_DECLAR_FLAGS, Q_FLAG, Q_DECLARE_EQUALITY_COMPARABLE.

The sanitize-commit (from qtrepotools repo) git hook already warns about
these.

Pick-to: 6.9 6.8
Change-Id: If53f446c7c19856c4a5be1e0b0156e1892871dae
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2024-12-12 21:38:01 +02:00
Ahmad Samir
e5d8ee578d Fix GCC -Wextra-semi after member function definitions
Fixes: QTBUG-132101
Pick-to: 6.9 6.8
Change-Id: Ia2e13bdaf11c639c5590639717b5d31140352c44
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-12 21:38:01 +02:00
Marc Mutz
0744ed6eac tst_QAnyStringView: complete Char[] CanConvert sets
Other view tests test Char[N] and const Char[N] separately. Do the
same here.

For many Char types, the array CanConvert test was missing
completely. Add them.

Pick-to: 6.9 6.8 6.5
Change-Id: I1d0b6de394d548554a547f190e74cb8cead6ecd4
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-12-12 20:38:00 +01:00
Marc Mutz
da0eaec8fd tst_QStringApiSymmetry: test QByteArray(weak)/QByteArrayView overloading
Adding it here since this test case already has all the infrastructure
for the overload test.

Pick-to: 6.9 6.8 6.5
Change-Id: I2d7fff9d2d82fed3db2446690a354f939c9a37fc
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-12-12 20:38:00 +01:00
Marc Mutz
976051bed8 tst_QByteArrayView: check conversion from various QSpans
This is supposed to work, so check it.

Pick-to: 6.9 6.8
Change-Id: I201033656f123b09644e5de447cd5d7b038e5155
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-12-12 20:38:00 +01:00
Ivan Solovev
ba3f34b0b8 Fix docs for QSet (in)equality operators
The missing '&' prevented qdoc from generating the docs.

Amends f9f3bf79dccbfcabbd5c59c39f9f018d71b7549f.

Pick-to: 6.9
Change-Id: I1d8d7a4e2f4c46c4c365cb5a5e38877837881c45
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-12-12 20:38:00 +01:00
Ahmad Samir
291c762802 QtSql: fix GCC -Wextra-semi warnings after member function definitions
Pick-to: 6.9 6.8
Change-Id: I5b65f543d7a36386181e493d8b9ce0267132d686
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2024-12-12 20:21:24 +02:00
Ahmad Samir
8d3601dfe8 Fix GCC -Wextra-semi warnings with Q* macros
Namely, Q_ENUM, Q_DECLAR_FLAGS, Q_FLAG, Q_DECLARE_EQUALITY_COMPARABLE.

The sanitize-commit (from qtrepotools repo) git hook already warns about
these.

Pick-to: 6.9 6.8
Change-Id: If53f446c7c19856c4a5be1e0b0156e1892871dae
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2024-12-12 20:21:24 +02:00
Ahmad Samir
6b951f6c0c Fix GCC -Wextra-semi after member function definitions
Fixes: QTBUG-132101
Pick-to: 6.9 6.8
Change-Id: Ia2e13bdaf11c639c5590639717b5d31140352c44
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-12 20:21:24 +02:00
Marc Mutz
0bbbbfc78b tst_QAnyStringView: complete Char[] CanConvert sets
Other view tests test Char[N] and const Char[N] separately. Do the
same here.

For many Char types, the array CanConvert test was missing
completely. Add them.

Pick-to: 6.9 6.8 6.5
Change-Id: I1d0b6de394d548554a547f190e74cb8cead6ecd4
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-12-12 19:21:24 +01:00
Marc Mutz
140dac92f2 tst_QStringApiSymmetry: test QByteArray(weak)/QByteArrayView overloading
Adding it here since this test case already has all the infrastructure
for the overload test.

Pick-to: 6.9 6.8 6.5
Change-Id: I2d7fff9d2d82fed3db2446690a354f939c9a37fc
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-12-12 19:21:24 +01:00
Marc Mutz
8a3ffe7044 tst_QByteArrayView: check conversion from various QSpans
This is supposed to work, so check it.

Pick-to: 6.9 6.8
Change-Id: I201033656f123b09644e5de447cd5d7b038e5155
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-12-12 19:21:23 +01:00
Ivan Solovev
03389d4790 Fix docs for QSet (in)equality operators
The missing '&' prevented qdoc from generating the docs.

Amends f9f3bf79dccbfcabbd5c59c39f9f018d71b7549f.

Pick-to: 6.9
Change-Id: I1d8d7a4e2f4c46c4c365cb5a5e38877837881c45
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-12-12 19:21:23 +01:00
Dheerendra Purohit
51f702d402 QDebug: add refinements to qDebug support for stl containers
Refinements of the stl containers based on the comments.

Fixes: QTBUG-131766
Change-Id: Iddca031a7b63cc24a3d4a1fdede02b8968e95be9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-12 16:10:43 +00:00
Tatiana Borisova
d991572a45 [QDomNodePrivate] delete unnecessary pointer check from the statement
- prev pointer never can be null here, so the check can be deleted.

Ammends 948599e7b71f59fd9c9c0f7f3d1987ec93a23490

Pick-to: 6.8 6.9
Change-Id: Ie194f5f0432f6da5f6471328193112c970f623b6
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-12-12 14:27:14 +00:00
Eirik Aavitsland
73221d2638 QWidget::mapTo()/mapFrom(): Do not crash if parent argument is invalid
These functions iterate through the parent hierarchy until the widget
given as argument is found. If never found, the code would assert (in
debug mode) or just silently crash (in release mode).

No need to bring down the entire application just because some widget
coordinate calculation is off. Instead, just emit a qWarning and
return cleanly.

Task-number: QTBUG-132072
Pick-to: 6.9 6.8
Change-Id: I4d13f46037cdcf855f76e040f941a8a7050ab12b
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-12-12 15:27:14 +01:00
Piotr Wierciński
b7419557b1 wasm: Link with FETCH library only for MAIN_MODULE
For dynamic linking only the main module should
link with libraries like "FETCH".
When side modules are linking to libraries as well,
it leads to linking errors.

Pick-to: 6.9
Change-Id: I83e37add867f1ce2cbcab4801f49266a288a9ceb
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2024-12-12 10:05:28 +00:00
Ivan Solovev
77b94a1e6f macdeployqt: adjust to [[nodiscard]] QFile::open()
The QFile::open() method becomes [[nodiscard]] in Qt 6.10.
However, macdeployqt was not adapted to this change. As a result, an
attempt to bump the Qt version fails in the CI.

This patch fixes the tool.
Amends 7466831509fe163f3fd1e3a6bbf38f6f5a32ef00.

Change-Id: I0dc0bc4c892f42e58d80da2407ddd83781ad8246
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-11 18:50:06 +01:00
Eskil Abrahamsen Blomfeldt
250117086f Include right bearing in width of layouts wrapping on spaces
When we're calculating the width of the layout, we include the
right bearing of the last character in the text line if it is
negative (i.e. it exceeds the advance width). We do this by
storing the last glyph that has been verified to fit in the
line, so that we can retrieve its right bearing when we find
a break.

However, when we were wrapping on spaces this previous glyph
would always be a space, and the right bearing would
subsequently be 0. But then the trailing spaces would be
trimmed and the right bearing of the actual last glyph
would not be recorded and never added to the text width.

This caused a failure in tst_qquicktext on Windows with both
DirectWrite and Freetype: This was purely unlucky, because
the metrics of the Tahoma font happened to be such that the
right bearing on the 'k' was enough to cause a line to
overflow. Since we didn't account for it when setting the
width, we ended up with unexpected line breaks, causing the
test to fail.

This did not happen with GDI, since it rounded the right
bearing of the character down to 0 (which was actually
visible in the layout, in that the k was painted a fraction
of a pixel outside the text layout's width).

In addition, QTBUG-130313 was causing us to pick a different
font when resolving the non-existent font requested by the test,
so therefore the bug was not found immediately when moving to
DirectWrite as the default but only when QTBUG-130313 was fixed.

We fix this by
  1. When adding a chunk of whitespace, we record the previous
     non-whitespace glyph that has been verified to fit.
  2. When adding a chunk of non-whitespace, we only record the
     previous glyph verified to fit *if* it is not whitespace.
	 Otherwise we keep whatever we recorded before adding the
	 spaces.

Pick-to: 6.8 6.9
Fixes: QTBUG-132075
Change-Id: I8d9a2f3197068f5f93520d217a6bb89633644e95
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
2024-12-11 18:41:52 +01:00
Ivan Solovev
8784ea16a6 Refactor hasCompareThreeWay check
Use structs derived from std::false_type and std::true_type instead
of boolean constants. This allows us to make use of std::conjunction_v
and std::disjunciton_v in the conditions, thus making use of
short-circuit evaluation and saving unnecessary template
instantiations.

Still keep the constexpr bool *_v constant for the cases when we need
a signle check only.

Amends 678e9f614bc5a05d2ff16cf916397998e7cdfca1.

Pick-to: 6.9 6.8
Change-Id: If2ab48ef910e97f241f5922d4108a271bc532f3a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-11 18:04:29 +01:00
Tim Blechmann
b6f3695a80 Cocoa: emit config error when using 15.0 as deployment target
QCocoaScreen uses removed APIs, which cause the code no fail compilation
with CMAKE_OSX_DEPLOYMENT_TARGET=15.0.
Adding a compile-time check to detect this early.

Task-number: QTBUG-128900
Pick-to: 6.9 6.8 6.5
Change-Id: I7eeb60f5769af6b1622efd1e0637e85a038b7930
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2024-12-11 14:52:41 +00:00
Tor Arne Vestbø
59bbfb17db Windows: Return high-DPI pixmaps from QWindowsTheme::standardPixmap
Most consumers feed the pixmaps into a QIcon, pulling out pixmaps
of sizes 32, 64, 128, 256, 512, so consumers of that QIcon will
not see low-resolution pixmaps for the common sizes like 64x64.

However if someone uses standardPixmap directly, or request an
icon with size 512x512, we won't have a high-DPI pixmap.

Unlike QStyle::standardPixmap we don't have a QWidget/QWindow
argument we can use to resolve the target DPR, so we have to
assume the pixmap can be used anywhere, and use the highest
DPR we've seen so far, via QGuiApplication::devicePixelRatio().

Pick-to: 6.9
Change-Id: Ib7fb08ab4932da1ca3f3325e25a7022c1cd17435
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-11 13:43:29 +00:00
Yuhang Zhao
9b924a4907 Windows theme: don't refresh anything unless theme really changed
Refreshing the global theme may be expensive for large scale applications, and even if Windows sent corresponding message,
it may be triggered by many reasons, not just the system theme,
so no matter what we'd better add an extra check.

Pick-to: 6.9
Change-Id: I70847aa54fb4af37c81855a62330a4bce31ff104
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2024-12-11 11:57:58 +00:00
Liang Qi
e721189ae0 textinputv3: do commit when update_state_enter
In some situation, like with "Focus follows mouse" in System Settings
->Window Management->Window Behavior->Focus on KDE 6 Wayland, during
mouse clicks the lineedit to regain the focus, only
zwp_text_input_v3_enter() happens, we need to also do commit() for
the original state. The commit() was also done in "Click to focus"
via QWaylandInputContext::update().

Done-by: lilydjwg li
Fixes: QTBUG-131983
Pick-to: 6.9 6.8
Change-Id: Ic6270a531d40e369152845d9f6eb6eee90d03bcc
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-12-11 11:25:44 +00:00
Volker Hilsheimer
d10e9174fe QFontIconEngine: if we can't find the named glyph, try ligatures
Use QTextLayout to layout and shape the text, which will respect
ligatures. Many icon fonts might not name their icons, but have a
replacement ligature for the actual icon name replacing the text with
the respective glyph.

So if for the name of the icon we get a single glyph run with a single
glyph in it, use that to render the icon.

Pick-to: 6.9
Change-Id: If0e5c528c3ac4cccdbb7df5fb7fd32ca232f2a66
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-12-11 11:05:45 +00:00
Volker Hilsheimer
9d47233d2c QFontIconEngine: always initialize with a non-merging font
The icon engine needs to be able to rely on glyph indices belonging to
the correct font, and we generally don't want the overhead of iterating
through potential fallbacks if a named glyph or unicode code point
wasn't found in the font.

Assert in the QFontIconEngine constructor that the font we get has the
NoFontMerging strategy bit set.

Amends 2af58490b3d33aab8d08610939fe2b7cab4c469c.

Pick-to: 6.9
Change-Id: Ib38324aebbeda956c8dd053969d6cf08f7ef3c35
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-12-11 12:05:45 +01:00
Shawn Rutledge
a117525515 Widgets: ignore unhandled right mouse button presses
In many places this was already done; but there was some old code
remaining where mousePressEvent() simply returned without ignoring the
unhandled event.

Task-number: QTBUG-93486
Task-number: QTBUG-132066
Pick-to: 6.9
Change-Id: I4a876980b7ef88ee478fa8cfd9f68b5be5b217a2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2024-12-11 07:53:27 +01:00
Ivan Solovev
10c844f053 [doc] Clean-up QSpan docs
QSpan docs use \target commands together with the section headers, to
simplify linking to certain parts of the docs. This approach has its
own drawbacks, though, because the \target link is rendered as-is.
This patch improves usage of the \target commands, making the links
look better.
It does the following changes:
* Moves the \target commands before the related \section2 commands, so
  that the section header is visible when following the \target's link.
* Replaces the \target links with the actual section names in the \sa
  and other places of the docs where the links do not have the custom
  text, because otherwise the target names are actually visible in the
  docs instead of the section headers.

Amends 03e78e5d624d9752d76c7448d58c9d9d15a4dc18,
70dc8d3103fade380caec96f7531432cd8e8adb6, and
ef5ac956c755daa9ea84dabfa1314d104e5c62e4.

Pick-to: 6.9 6.8
Change-Id: I045824683f342079e33e89e3ee6f8e2e27a0acf5
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2024-12-11 01:51:06 +01:00
Marc Mutz
8940185869 tst_QStringView: add missing CanConvert from char16_t/wchar_t arrays
QChar[N] and ushort[N] are being checked, it's unclear why char16_t[N]
and wchar_t[N] were missing.

Add them.

Pick-to: 6.9 6.8 6.5 5.15
Change-Id: I9a2df2a75886b950e8c2bdec843e3e693e536f86
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-12-11 01:06:09 +01:00
Marc Mutz
01f0305dc6 Confirm QLatin1StringView can be constructed over arrays of unknown bounds
It can (unlike the other views).

Pick-to: 6.9 6.8 6.5 5.15
Task-number: QTBUG-112746
Change-Id: Id976429611c53f1c707de1d989c454507b8f4773
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-12-11 01:06:08 +01:00
Volker Hilsheimer
3dc28cfae9 Baseline tests: prefer a screen with a DPR of 1.0
Move the windows to a screen with a 1.0 DPR, if the primary screen has a
different ratio. This makes sure that we get reproducible runs also
locally, no matter where e.g. the mouse pointer is (which on macOS
defines which screen the window opens up).

Change-Id: Iab7708c4abc0c97486f00a44a4b0a4c2b9406a62
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2024-12-10 23:45:41 +01:00
Volker Hilsheimer
b340fb6982 Baseline tests: disable animations in the vista style
The Vista style uses a dynamic property on each objects to control
animations; respect that dynamic property on the style itself as well
to make it possible to turn off animations.

Do so in the baseline test framework to get rid of some flakiness when
using the Windows Vista style.

Change-Id: I2bad329786f38e37d99f947f121e5cd44f5741c1
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2024-12-10 23:45:41 +01:00
Volker Hilsheimer
be4e3082f7 Vista style: don't use transitions unless desktop-settings aware
Change-Id: Ib93c18406e324df854765b309cb7c1cdca7a194d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-12-10 23:45:41 +01:00
Shawn Rutledge
357c64a996 QWidgetWindow: send QContextMenuEvent even after accepted mouse press
It would be more consistent if we could rely on the accepted state of
the original QMouseEvent to decide whether to follow up with a
QContextMenuEvent; but not all Qt widgets call ignore() on unhandled
mouse events, both in Qt and in external libraries and applications
(including some from KDE). So we should at least wait until Qt 7 to
make this a requirement. It seems sensible to move the check into
QWindow::event() rather than trying to distinguish the window type in
maybeSynthesizeContextMenuEvent(). We merely output a categorized log
message to indicate when the legacy behavior is in effect.

Amends 84a5f50c7766c99f62b22bb4388137e0aa8dd13d

[ChangeLog][QtWidgets] If your QWidget subclass depends on receiving
QContextMenuEvent, and also handles mouse events directly, we
recommend that you call ignore() on unhandled mouse events (such as
right-button events). In Qt 7, we plan to stop sending
QContextMenuEvent if the triggering mouse event is accepted.

Fixes: QTBUG-132066
Pick-to: 6.9
Change-Id: I454813dab4c387112f161fc28a0ee94570013afa
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2024-12-10 22:57:57 +01:00
Christian Ehrlicher
f3d5bdf4bc SQLite: Update SQLite to v3.47.2
[ChangeLog][Third-Party Code] Updated SQLite to v3.47.2

Pick-to: 5.15 6.5 6.8 6.9
Change-Id: I3f40198db02c7f9599189ec2a0001f1c294616c8
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2024-12-10 19:58:30 +00:00
Piotr Wierciński
6359793541 wasm: Fix warning message for Emscripten version mismatch
Change-Id: I3ebecc5bae1eb5ed102705e41fa024f7caab7650
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2024-12-10 19:45:16 +01:00
Frédéric Lefebvre
b977893c6c Remove sizeOnHide manual test as irrelevant
Show and Hide two elements from a vertical layout, keeping the empty
space when hidden.

Remove sizeOnHide manual test as irrelevant.

Change-Id: If833569099dbe7cf23cd06a9a768b1787c99de39
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
2024-12-10 18:45:16 +00:00
Dheerendra Purohit
1873335568 QToolBar: Update implicit icon size if style changes
Add logic in QToolBar::changeEvent() to update icon size set via
stylesheet.

Fixes: QTBUG-45949
Pick-to: 6.8 6.9
Change-Id: I7fce830a969af8774116f0229153668252b55598
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-12-10 18:00:25 +01:00
Lars Schmertmann
3bec93738e Android: Fix typo in the documentation of the default log pattern
Pick-to: 6.9 6.8 6.5
Task-number: QTBUG-94708
Change-Id: I845f193f1b98219be205b8615f817f3315f4d149
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2024-12-10 17:14:32 +01:00
Frédéric Lefebvre
0fce5caf95 Refactor and modify auto test tst_QWidget::palettePropagation2()
Refactor auto test tst_QWidget::palettePropagation2() to use
QWidgetList instead of rewriting the same code several times.

Add a lambda that ensure widgets are polished before comparing them.

Fix flakiness on Ubuntu 22.04

Change-Id: I6e6b26cf153c441b7d69cfe1a0b2fd604a08cde8
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-12-10 16:14:32 +00:00
Marc Mutz
0afe31fa51 QSpan: document slice() and chop()
Needed to use a weird combination of \c and \a here, as qdoc on
one hand insists that all parameters be documented, and OTOH doesn't
support \a within \c.

Writing anything else than the equivalent code in \c to appease qdoc
would be childish. Equivalent code is the best-possible documentation,
as it leaves no question unanswered.

Pick-to: 6.9
Task-number: QTBUG-131672
Change-Id: I512872360b7eb212001723f2ba12d4c6eac0b6b0
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-12-10 16:14:32 +00:00
Kai Uwe Broulik
638c9bd259 QWaylandXdgSurface: Always clean up xdg_activation_token
If the token arrives after the surface has already been destroyed,
the lambda containing the deleteLater would never be called.

Pick-to: 6.9 6.8
Change-Id: Ic34d4e06e20fe522006afc55890cf42b8ba09979
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2024-12-10 14:25:54 +01:00
Edward Welbourne
2bdce97480 Fix typo in QTZ constructor docs
There is no fromSecondsAfterUtc(), I was thinking of
fromSecondsAheadOfUtc().

Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-131913
Change-Id: I6a89a27d678d23043819b93d5e4120d01002da4a
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-12-10 12:02:43 +01:00
Assam Boudjelthia
879cfec747 Android: suppress deprecation warnings for ExtractStyle.java
This class is basically almost unmaintained, so let's not
keep deprecation noise from it.

Change-Id: I009c1c6ee51998ba1578b9238ec8108f9e046799
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2024-12-10 12:52:39 +02:00
Yuhang Zhao
ad06099b93 Minor improvements of windows style
1. Make some global constants constexpr.
2. Make some file-scope global constants static.
3. Use QStringLiteral instead of plain const char*
4. Add "u" to QStringLiteral's content.

Pick-to: 6.9 6.8
Change-Id: Icbc105366ba40e970b256fe3da41231a6fb5064b
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2024-12-10 05:18:37 +00:00
Wladimir Leuschner
79aa4269bc QWindows11Style: Override alternate base color in darkmode
The alternate base color in darkmode was wrongly set to the accent color
instead of a lighter color. This patch overrides the alternate base
color for the QWindows11Style.

Fixes: QTBUG-131976
Pick-to: 6.9 6.8
Change-Id: Ie8f50b0042ca7bf746224275abc0cd255df7a4ad
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2024-12-09 22:54:40 +01:00
Frédéric Lefebvre
86d0f4a3c4 Remove task14109 manual test as irrelevant
Tests setAttribute (Qt::OpaquePaintEvent) and setAttribute
(Qt::StaticContents) on a widget.

Remove task14109  manual test as irrelevant.

Change-Id: I2292c4b45bfadb847c23250a94d9bfeecaa47343
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-12-09 22:54:40 +01:00
Allan Sandfeld Jensen
bde2292247 Add primary RGB color points getter
[ChangeLog][QtGui][QColorSpace] Added primary points getter and setter

Pick-to: 6.9
Change-Id: Ia4e412b3e63584cf88fa632e5c1d47618d07ebf1
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2024-12-09 16:37:36 +00:00
Frédéric Lefebvre
a507507ce1 Remove tst_manual_childwidget manual test as irrelevant
Test child widgets (on of which is native) with set cursors.

Similar test as tst_QWidget::setCursor().

Remove tst_manual_childwidget manual test.

Change-Id: Id9f0cf9cdb83ad86534761cf35b5359911a5cc8f
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-12-09 17:20:09 +01:00
Tor Arne Vestbø
6689921b9d iOS: Iterate accessible interface to find window
Many subclasses of QAccessibleInterface implement window(), but
some don't, and the documentation states that the backend (us)
will traverse ancestors until it finds one with a window.

We were not doing that for iOS, which caused a crash for
QAccessibleTabButton, which doesn't have a window.

In case we ever hit the code path where we can't find a
window we also skip adding the nil element to the array
in createAccessibleElement, as that causes an exception.

Amends 7a512d1267442e646bb7942291197b2b03f4d1cd

Pick-to: 6.9 6.8 6.5
Change-Id: I9b758423956e845a01b014022f4d3ab6306be94e
Reviewed-by: Doris Verria <doris.verria@qt.io>
2024-12-09 14:33:32 +00:00
Frédéric Lefebvre
af91b37e9f Add a comment to the class QPropagationTestWidget of tst_QWidget
It is not obvious, why this class has been added.

Add a comment to explain.

Change-Id: Ife19e7f508e23dc22968a462d2d00e6698b807b3
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-12-09 13:16:54 +00:00
Inho Lee
c1c10fca77 textinputv3: use the cursorBegin as a cursor position of preedit
When using preedit, CJ inputs use the cursor rectangle for showing
a candidate list.  The cursorBegin of preedit has been used for
the position in most compositors and desktop input-methods.

Done-by: lilydjwg li
Fixes: QTBUG-129331
Pick-to: 6.9 6.8 6.5
Change-Id: Id8a1fa864189ced98672c3b20c169dd6a950d18d
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-12-09 12:47:50 +00:00
Eskil Abrahamsen Blomfeldt
355f54f7d5 DirectWrite: Remove ad hoc font resolution through GDI
In b8612eaa2a17e12e31ee28141cff1fb43e54c00e, we added a fail safe
where failure to find the font name through DirectWrite would
try loading it through GDI instead and if that was successful we
would register the family with the database after all.

However, the code assumed that CreateFontIndirect() would return
NULL if the font did not exist. It does not do this, but instead
selecting the HFONT on the HDC will give us a suitable alternative
instead. The result would be that any missing font family would
be registered with the font database through this mechanism, even
if it really didn't exist.

This code was added in an early version of the patch, however,
and it should not actually be needed anymore, since we in later
versions of the same patch also added logic to populate the
GDI-compatible family names
(DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES etc.). This should
take care of backwards compatibility with the GDI names for fonts.

Since the code has been reported to cause problems on some systems,
it's safest to just remove this hack.

Fixes: 6.8
Task-number: QTBUG-130313
Change-Id: I7eca893d17796d9cac07391b7b947d28dd7cd920
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2024-12-09 12:11:05 +00:00
Topi Reinio
429f565017 Doc: Set trademarks page in global configuration
The new \tm command appends a trademark symbol and links to the
trademark documentation page if `navigation.trademarkspage` variable
is set. As we have such a page in qtdoc repository, set the variable
in the global configuration. This works as all Qt module docs have a
dependency to the `qtdoc` documentation set.

Pick-to: 6.8
Task-number: QTBUG-124393
Change-Id: Iabc6e7e5afe5114eac79947f0feb512458f1c4da
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2024-12-09 11:56:02 +00:00
David Edmundson
446c613fa7 Client: advertise utf-8 text formats when creating drags
Some clients ignore text/plain only look for utf-8 text to be sent.

When creating a clipboard source we advertise both, but this step was
previously not copied for drag handling.

Pick-to: 6.9
Change-Id: Ibe1476c309e88d6499ae0e6cb96a96aa07b4af71
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-12-09 11:45:34 +00:00
Michał Łoś
138160fccd Fix exception in memory heavy QLatin1StringMatcher test
tst_QLatin1StringMatcher::haystacksWithMoreThan4GiBWork test requires a
lot of memory to run (over 12GiB total) when run on 64bit platform. This
is addressed in try-catch block starting in line 535, in which check for
std::bad_alloc is added, skipping the test when it occurs.

Unfortunately, this helps with scenario where system has 4GiB or less of
memory, because in line 567 conversion of 4GiB+ std::string to QString
occurs, which requires additional 8GiB+ of memory. This ends up with
std::bad_alloc exception happening when system has less than 12GiB
bytes, failing the test. This was found during tests of VxWorks for
Intel x64.

Fix this by extracting allocation and surrounding it with try-catch
bock, skipping test if std::bad_alloc occurs.

Task-number: QTBUG-115777
Change-Id: Ie6df4d702f061b1d17cb0eab84228819d294a379
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-09 08:47:43 +01:00
David Edmundson
0a8fe091f7 Client: Always trigger a commit in flush
There are a few paths in wayland that require the client to always
commit to apply changes or ack requests. We need this synchronized with
any rendering so it is normally triggered with an expose or update event
relying that this will always commit at the end.

There is a path in QWidget code where if the window is not damaged we
never call backingStore->beginPaint. If this doesn't happen we don't
swap the front buffer, and the expose event will no-op. We want to avoid
attaching in this case, but we should commit without attaching
regardless to flush these events.

This fixes an issue where Qt could fail to ack configure events which
don't trigger updates.

Pick-to: 6.8
Change-Id: Iaa606b0bf9fbbaefd3e67444cc768f95076967fe
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2024-12-06 10:26:42 +01:00
Jie Liu
6d3f6d3ae5 datacontrolv1: reset offer if receive null selection
Change-Id: Ifc88b5cb54299df9177afe6ed9bcaa46b1fe21fb
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-12-05 17:09:47 +08:00
Kai Uwe Broulik
936260bbb9 QWaylandMimeData: Return converted MIME types in formats(), too
This brings it in line with QXcbDropData where formats_sys()
returns the format from mimeAtomToString (which contains
the special-case for text/x-moz-url).

Furthermore, in hasFormat_sys() just check formats() to avoid
yet another place where a special-case is added, again in line
with QXcbDropData.

Pick-to: 6.8
Change-Id: Ia2b7c149b35110ff9dd8deed94c3378afb047ac1
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-11-29 17:47:41 +00:00
David Edmundson
34b6195385 Client: Implement frame-perfect resizing
With synchronous delivery we can be sure that any exposeEvent blocks
until the frame is rendered and committed.

This patch introduces a new override to make the render thread back off
starting a new frame when a resize is pending. If a configure event is
received we do not need the render thread to dispatch a new frame as the
main thread will do so explicitly when the configure event has been
processed.

To handle the case of a frame already being in flight at the time of the
main thread processing a configure event, this patch submits a new
exposeEvent with the old geometry. This will block until any existing
frames are fully submitted and the new exposeEvent is handled. Together
with the allowsIndependentThreadedRendering hook we can ensure that no
frame of the old size are going to be committed after we finish
processing and acking the incoming configure request.

Change-Id: Ic8ec9803800b17d2b8419da1a93e8dc388e702ab
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2024-11-25 22:12:38 +00:00
David Redondo
fef73b9baa client: Redo management of tablet object proxies
Since bb151390240c1f20a6464adbefa497f3559554dd tools and pads can sometimes
be parented to tablets. When a tablet is unplugged sometimes the remove
event for the tablet can be sent before the remove events for the pad.
Deleting the tablet will also delete the pad but not the pad proxy,
resulting in a crash when the pad remove event is received.
This moves destruction of the wayland proxies which makes everything much
simpler as not every location that deletes those objects needs to call
destroy and fixes the described problem.

Pick-to: 6.8
Change-Id: I0aaeda3d3996251e411229b5e97aa1ce0bce43ac
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-11-25 11:12:47 +01:00
Kai Uwe Broulik
fbefe0eea3 client: Soften wording on fake screen message
Don't admit that our software might be crashy.

Pick-to: 6.8
Change-Id: I8b216478e2f214af64ae97ec149ebda751a8894f
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-11-19 09:54:39 +01:00
David Edmundson
bd2371fc59 client: Avoid additional translations copying backing store contents
The current code uses QPainter to copy damaged contents into the new
back buffer.

QPainter operates in logical pixels taking into account the
devicePixelRatio transparently. The current code tries to undo this with
another translation on top to work in device pixels.

With floating point numbers there's a tiny amount of inprecision, each
translation adds a tiny amount of error. The end result is pixels can
get missed.

Making QPainter calls in logical pixels gives us the exact path as the
main rendering.

Pick-to: 6.8
Change-Id: I2f6bd8a69a7273f21055248973e14e14066b1c67
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2024-11-15 16:25:56 +00:00
Lucie Gérard
84853a6a7b Add REUSE.toml files and missing licenses
REUSE.toml files are read by reuse to complement or override the
copyright and licensing information found in file.

The use of REUSE.toml files was introduced in REUSE version 3.1.0a1.
This reuse version is compatible with reuse specification
version 3.2 [1].
With this commit's files,
* The SPDX document generated by reuse spdx conforms to SPDX 2.3,
* The reuse lint command reports that the Qt project is reuse compliant.

In order to be reuse compliant all the licenses referenced in file
or within a REUSE.toml file must be present in the LICENSES
directory at the base of the module.
The missing licenses are added.

[1]: https://reuse.software/spec-3.2/

Task-number: QTBUG-124453
Task-number: QTBUG-125211
Pick-to: 6.8
Change-Id: I902e4e92c8cbe194270de9ac8105adc28a381e88
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-11-14 12:16:10 +01:00
Tim Blechmann
b227eb4aa4 Client: remove unused logging category
lcQpaWaylandInput is unused in this file and can be removed.

Pick-to: 6.8
Change-Id: If56a764b28837fc11b770a1b6739243e57641f68
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2024-11-14 11:37:27 +08:00
Tim Blechmann
f19309cec5 client: fix deprecation warning
use lcQpaInputDevices exported from QtGui

Pick-to: 6.8
Change-Id: I8a5c47ce35abdc39fb38a026b870f137f14a7448
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2024-11-14 02:48:48 +00:00
David Redondo
2753bf6b6b Adapt window recreation to wl_surface as winId and lifetime changes
Returning wl_surface as winId broke widget windows after reconnect.
When fetching globals from the new connection new screens are added,
this results in QWidget being notified of a screen change. It then
refreshes its cached winId which at this point in time will be 0
since the window does not have a new window yet. Then when a widget
repainting the backing store will never be flushed because it doesnt
find a native parent anymore by going up the parent chain and looking
for a widget with non-null winId.
Fix this by recreating the wl_surface after fetching the globals
but before the initital roundtrip.
While at it dont recreate role objects for windows that dont need
them. With the changes that also now hidden windows have wl_surfaces
we would recreate them along with closed popups.

Change-Id: Ib7ed27d1f25df84c85cce4802726178586c19d55
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-11-13 08:41:58 +01:00
Paul Olav Tvete
9aa5f633d4 MockCompositor: Fix potential race condition
The list m_viewports is being accessed from both the main thread
and the dispatch thread. This has not been observed to cause any
errors, but is a potential source of test instability. Using a
DirectConnection makes sure that both appending and removal
happens in the same thread.

Task-number: QTBUG-130627
Pick-to: 6.8
Change-Id: Iee6941d8794119e679a485778f0be5c40df27069
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-11-11 13:09:24 +01:00
David Edmundson
9fd572be56 client: Announce platform support for WindowActivation
QtWayland has had support for window activation for some time using the
xdg-activation-v1 protocol. Activating applications requires some
application intervention, but passing focus between windows should work
as automatically as any other platform.

The flag was still left unset as compositor support was lacking, but
this it is now universally supported.

Task-number: QTBUG-121732
Change-Id: I1f31bbf9c5c7cc371e058d2637a1ba2b2b411053
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2024-11-11 10:27:09 +01:00
Paul Olav Tvete
4781e2a088 MockCompositor: Protect against race condition
The QList m_fractionalScales was being changed from both the main thread
and the dispatch thread. This lead to read-after-free AddressSanitizer
errors when running autotests. Using a DirectConnection makes sure that
both appending and removal happens in the same thread. This does not
fix a theoretical race condition in DefaultCompositor::fractionalScale().

Fixes: QTBUG-130627
Pick-to: 6.8
Change-Id: Ie73f80d08929bcfcbd9940acdb4f86233df013cb
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-11-11 09:21:43 +01:00
Paul Olav Tvete
77aeb195a4 Position grabbing popups correctly when started from hover events
If there is no known lastInputDevice, child popups will be randomly
positioned. This can happen when a popup is triggered by a hover event.
The obvious fix is to call setLastInputDevice from pointer_enter().
However, Weston (and probably other compositors) do not accept enter
events as valid grab serials. Calling setLastInputDevice from every pointer_enter would therefore completely disable menu popup on mouse-over for those compositors.
The solution is to only call setLastInputDevice when we have not seen one before. This means that the user may have to click once to get hover popups to work. This should be an acceptable price to pay to avoid menus appearing at random positions.

Fixes: QTBUG-128937
Change-Id: I446abb2f4bed65cb4c46ec89d08025cd6cd8e5f3
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-11-07 09:30:23 +00:00
Vlad Zahorodnii
e7539d2ee8 Client: Avoid activating window on show if Qt::WindowDoesNotAcceptFocus is set
The Qt::WindowDoesNotAcceptFocus flag provides one more clue regarding
what the user intends to achieve. Technically though, the does not
accept focus flag doesn't influence a lot in practice as it's not
communicated back to the compositor, but it's still suitable for
determining whether the window needs to be activated when it's shown.

Change-Id: Idf80c1701966870b4bbe422ecb9c7cb33e3a6bc0
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-11-06 18:08:59 +02:00
David Redondo
af1f258c11 client: Fix changing to subsurface now that wl_surface is not destroyed
In the past isVisible() was equivalent to having a wl_surface - this does
not hold anymore. The QWaylandWindow will have a wl_surface for all its
life time. Changing parent while the window is hidden would run now
into a protocol error.

Change-Id: I2aec6217ad495daa9dbb2ee2fee1b73ba00e6937
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-11-06 14:07:09 +01:00
David Redondo
8b86bbe81f client: Fix crash on data_device_motion
When a window is closed/destroyed, a motion message can still be received
that was send by the compositor before closing the window.

Pick-to: 6.8
Change-Id: I49cfdcf9a4143df5c090dfb93f2920879ae43f80
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-11-06 11:50:13 +01:00
Jie Liu
92ec75ba8b Add support for wlr-data-control-unstable-v1 protocol
[ChangeLog][Third-Party Code] New protocol synced from wlroots.

Change-Id: Ia5f43e62f98e9c95ebd02077ec6dc132e13cf5e0
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-11-06 16:15:25 +08:00
David Redondo
207c51371d Client: implement toplevel icon protocol
This allows QWindow::setIcon to work on desktops that support the
standards. If an icon name is set, we assume it's from an installed
theme and provide the name, otherwise we provide buffers.

For SVGs the size hint from the compositor is used, otherwise we supply
pixmap data in all the sizes we have available.

[ChangeLog][Third-Party Code] New protocol synced from wayland-protocols

Change-Id: Iabbd928a3476aafa2d63a81e68299049e59991db
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-10-31 14:53:19 +00:00
YAMAMOTO Atsushi
1893303955 Fix typo in comment: 'polll' to 'poll'
Corrected a typo in the comment block, changing 'polll' to 'poll'.

Change-Id: I8f276d8a7f07114b323bf0c79e797e355dad1547
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-10-31 20:02:12 +09:00
Paul Olav Tvete
43d385e949 Check whether m_toplevel exists before dereferencing it
The parent surface could be a popup. In that case m_toplevel would be
nullptr. Since xdgshell doesn't allow an xdg_popup to be the parent of
an xdg_toplevel, the best we can do is pretend there is no parent in
this case.

Fixes: QTBUG-130128
Pick-to: 6.8
Change-Id: Ib0367429b71ee96cbd1c3119e77769c511370624
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2024-10-31 10:36:56 +01:00
David Redondo
ac879a0200 Implement support for attaching dbus menu bar to a window
This uses the KDE specific protocol, on other platforms it noops.
[ChangeLog][Third-Party Code] Adds the implemented appmenu protocol

Change-Id: Ie2dcf062fd8f3279e6e0ce142ee9e7b26cac4e9b
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2024-10-29 10:26:26 +01:00
David Edmundson
a49524bf03 client: Drop outdated QT_WAYLAND_RESIZE_AFTER_SWAP
QT_WAYLAND_RESIZE_AFTER_SWAP was added
in15f82d0bc40eae635ed1377ae39253a8f515ea4a in 2014 to provide an
opt-in-path to support drivers that did not apply an eglWindow resize
until after the swap occurred.

This is now the default in the EGL specification and fully supported in
QtWayland. The environment variable does nothing.

Change-Id: I8114d11801db5ba6863f48e2d44cca984bb58de7
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2024-10-25 23:07:59 +01:00
David Edmundson
dbe5894530 Client: Use synchronous delivery for geometry events
This simplifies the data flow and reduces the paths for some races with
threaded rendering.

Making all events synchronous does not work due to application logic
having nested event loops.

The design is all normal wayland events are flushed at the end of each
dispatch so that everything remains ordered. When a configure event
is received applying that state is queued. When it is applied, all
events emitted from this are flushed.

Application driven geometry changes are also synchronous.

The old code to manage frame synchronization is removed, this attempted
to not apply configure events whilst a frame is in flight. It doesn't
work properly as the render thread could start on the next frame whilst
the main thread processed the resize. It is problematic in this port as
the mutexes will cause deadlocks with sync delivery.

Task-number: QTBUG-121731
Fixes: QTBUG-117762
Fixes: QTBUG-119112
Change-Id: I5802b4006d307a45468767d68c3ad40078df5703
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2024-10-25 10:32:09 +01:00
David Edmundson
885a708e69 client: Notify application code of button release after leave
There is a code path to notify application code that mouse buttons are
released following a drag.

Compositors we will have been sent a leave event in the
meantime, making this code inert. Focus window will be null, and
mButtons will be empty.

We still need to send a release event QWindowSystem event to no window,
as we need to update any grabs on the device.

Pick-to: 6.8
Change-Id: I2a090561c7d3f4669ab2dbc4eb86c8226fe15d1a
Fixes: QTBUG-127821
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-10-23 09:26:10 +01:00
Lu YaNing
e00905d943 client: use wl_shm.release if available
Change-Id: Ica8a210e988604346cba36b69658bc83fbf21179
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-10-22 19:21:32 +08:00
David Redondo
1dfa712eb5 client: Run waylandscanner with private-code
This is the recommended mode, and failing to use private-code
makes libraries expose generated symbols like wl_shm_interface,
which may conflict with symbols from libwayland leading to
unexpected behavior or aborts.

Change-Id: Ifcb701a8670b339d24b13f2812c10493a64ee060
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-10-21 19:44:08 +02:00
David Edmundson
d335a332f8 client: Make use of floating QWindow::mapToGlobal
Wayland input is always surface-local, which we map to a faux global
position for Qt usages. Precision of non-integer co-ordinates were
either lost or handled in a more complicated way that needed.

Change-Id: Ia8101d4903caec42f1087a7b4adeff3a9a097a12
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2024-10-17 17:23:29 +01:00
Inho Lee
62f4289cde textInputV3: Prevent recursive update calls
If a 'done' which the compositor sends doesn't make any
update in the client side, an additional event and
updates will be skipped.

Fixes: QTBUG-126275
Pick-to: 6.8
Change-Id: I86bebb3cc645f46ec2bfc6ef587ff86b76d44c9e
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-10-17 12:18:32 +02:00
YaoBing Xiao
8784a01787 Client: Implement interface name printing for Wayland protocol
Change-Id: I73eb629caedf3c9f78b5d83168549125422092b6
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-10-16 19:24:12 +08:00
David Edmundson
2d5c66b79c client: Flush painting on subsurfaces
When native widgets are nested in Qt, they act like independent windows
with a shared backing store. The toplevel window gets multiple flush
events with an argument for the window sub-content.

In wayland we need a unique backing store, so this code copies the
relevant contents into a new buffer and attaches it to the
subsurface.

Task-number: QTBUG-128029
Pick-to: 6.8
Change-Id: I865cb271d694d8190a444eb5a98378cd6a30634d
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-10-15 13:27:38 +00:00
David Edmundson
193b7f011f client: Implement xdg_system_bell_v1
This hooks up QGuiApplication::beep to the new wayland protocol

[ChangeLog][Third-Party Code] New protocol synced from wayland-protocols

Change-Id: I188eeb68fce406a0938011eb844bf9fbdabf5904
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-10-15 13:31:19 +01:00
Inho Lee
41d4948606 Revert "TextInputV3: Prevent a recursive update call"
This reverts commit 0b1d950e437bd0e112b7f4f25b42f3318634200a.

set_cursor_rectangle needs commit for the proper cursor location.

Fixes: QTBUG-129584
Reopens: QTBUG-126275
Pick-to: 6.8 6.7
Change-Id: Ibb11cbceab9cf00a4a2fa5ed3efc5e4ddddcd8d7
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-10-15 11:45:35 +02:00
Shawn Rutledge
444e334265 Client: Send mouse events with QPointingDevice instances
We can't distinguish devices so far on Wayland: primaryPointingDevice()
is just an assumption. But at least we know which seat sends the event.
After this change, for example, the mouse seat name is visible in
qtdeclarative/examples/quick/pointerhandlers/singlePointHandlerProperties.qml

Task-number: QTBUG-85272
Task-number: QTBUG-115207
Task-number: QTBUG-129087
Pick-to: 6.8
Change-Id: I3822075bf5680c40b55868f413c48adaea1d3fec
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-10-01 12:34:00 +02:00
Xavier BESSON
33dcb1d7ec Return wl_surface* QWaylandWindow::winId()
Required when you want to use some of the wayland protocols
(For example: Keyboard shortcuts inhibit)

Fixes: QTBUG-67919
Fixes: QTBUG-93103
Fixes: QTBUG-94729
Change-Id: I112c4c3eac99187317dce8de59a77ba3b0e70d17
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-09-27 17:42:10 +02:00
Ilya Fedin
ab9d58cd42 Client: Use QPlatformWindow's DPR for fallback cursor scale and ceil it
This should provide a crisper cursor than flooring and QPlatformWindow
is a more right choice than QWindow.

Change-Id: I4d0a50e7e513b632532f8561fe709428599fab2c
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-09-27 12:17:40 +04:00
David Redondo
538e3f7421 client: Change default lifespan of wl_surface to match the window
This brings it more in-line with other platforms where the underlying
backing store has the lifespan of the window, implicitly fixing a
teardown issue with Qt Vulkan.

With this commit the wl_surface lifetime matches the QPlatformWindow, on
show and hide the shell surface is still recreated, with a null buffer
attached inbetween to get a blank slate as per the specification.

There is still some paths where a wl_surface is reset during the
platform window lifetime if the user ever converted a subsurface to a
toplevel or vice-versa, also for handling compositing restarts.

Task-number: QTBUG-125592
Change-Id: I449ec170a085c7c0fca504687556d702daddf79a
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-09-24 09:40:41 +01:00
David Edmundson
0e64cadb98 tests: Fix flaky reconnect test
testMultiScreen explicitly sets clients on monitors, for this to work we
need autoEnter disabled.

92952bd04a0452a45140ed9c9494279683bb80e1 set this on startup, but due to
the way we reset the compositor this needs doing multiple times if
multiple tests are run.

Change-Id: Iaad3058b3ad8a12d01b3bd8272615fcd74ea250d
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-09-17 10:10:36 +01:00
David Edmundson
8b9b2dec19 tests: Make tst_scaling more robust
When a fractional scaling value is sent, we expect the client DPR to
update, and a new frame sent to the compositor.

We can't be sure that our compositor thread won't already have the new
frame by the time we call surfaceCommitSpy.wait.

Change-Id: Iab7d57f07e854a79e69b97631fe1b6006a061b82
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-09-17 10:10:27 +01:00
Nicolas Fella
577d4e2244 QWaylandTablet: Implement cursor
Currently we don't set a cursor for tablet devices,
so we get either a generic fallback cursor (KWin)
or no cursor at all (GNOME).

This makes sure we get the same cursor we get for
mouse input.

The code is mostly identical to the mouse cursor
handling, so refactor things a bit to share

Pick-to: 6.8
Fixes: QTBUG-105843
Fixes: QTBUG-123776
Change-Id: Ie626ff978d9b66ec422804a103699eebec85e267
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2024-09-16 23:07:50 +02:00
Shawn Rutledge
efd45d447e client: Wait to create QPointingDevice; give seat name to ctor
Wait until both the seat name and capabilities are known, to avoid
depending on the order of messages. On Weston, seat_name() is called
after seat_capabilities(), while it's the other way around on others.

Pass the seat name along in each place where the QPointingDevice ctor is
invoked.

This gets us closer to multi-seat support on Wayland: at least
qtdecl/examples/quick/pointerhandlers/singlePointHandlerProperties.qml
can see the seat name of the device provided with each QTouchEvent or
QTabletEvent. Followup to bb151390240c1f20a6464adbefa497f3559554dd and
e168e1fc80231c0e2751b4f6f2a736efadff92fa

Pick-to: 6.8
Task-number: QTBUG-72167
Task-number: QTBUG-115207
Change-Id: Ife25cfec0307893d949a2a50a9b49a8f560a60e0
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-09-16 12:11:27 +02:00
David Edmundson
d749871d39 tests: Send seat name on bind
Pick-to: 6.8
Change-Id: I4cec8d6c26076f0213dbeb9ab3d39585936d0c25
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-09-11 22:29:22 +00:00
Ilya Fedin
ceebf0d57a Client: Ceil cursor's fallback buffer scale
This should provide a crisper cursor

Change-Id: Iaa3108cc2c6346e9db9755975ca2718875f470b7
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-09-11 21:50:13 +04:00
Shawn Rutledge
92af4c8d2b client: Reset tablet state on proximity out; quiet the warning
If !m_pending.proximitySurface, usually it's because the stylus is
leaving proximity. The "no proximity surface" warning (introduced in
4d844d36404597713a63879dc24f051de0ad3e5b) only makes sense if neither
applied nor pending state has a proximity service.

If we are leaving proximity, reset m_applied state as well as
m_pending state, because we don't expect any more tablet events until
after the next proximity in event. There was a bug that subsequent
proximity in events were not sent, because m_applied.proximitySurface
was still set (leftover state).

Amends bb151390240c1f20a6464adbefa497f3559554dd

Pick-to: 6.8
Change-Id: I019e91eebb1958cd6c17393482cbae4c4ba9308d
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-09-08 09:44:22 +02:00
Ilya Fedin
555fd6e1e1 Client: Fix desktop environment check for decorations
XDG_CURRENT_DESKTOP is an array and the current check doesn't work
on e.g. Ubuntu

Pick-to: 6.8
Change-Id: Iff049ad8dd432191f815c6c079448af02dc7a09a
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-09-07 21:19:21 +04:00
Thiago Macieira
5384317da8 Move the declaration of the qLcQpaInputMethods category to the header
Qt 6.8 requires it.

qloggingcategory.h:168:67: warning: ‘const QLoggingCategory& qLcQpaInputMethods() [with <template-parameter-1-1> = void]’ is deprecated: Use Q_STATIC_LOGGING_CATEGORY or add either Q_DECLARE_LOGGING_CATEGORY or QT_DECLARE_EXPORTED_QT_LOGGING_CATEGORY in a header [-Wdeprecated-declarations]

Pick-to: 6.8
Change-Id: I41815e1c1bfdd5bab41cfffdd50d4679670398d8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2024-09-07 16:49:00 +02:00
Nicolas Fella
fcdef0cd5f Client: Pass tablet input to decorations
Otherwise decoration cannot be interacted with using a stylus.

Since there is no reason for the decoration to distinguish between
stylus and mouse input reuse the existing mouse handling instead
of adding a dedicated tablet input function to the decoration API.

Fixes: QTBUG-117920
Pick-to: 6.8
Change-Id: I947e5b4f638fb3c2b15a1ca4ed01c02caf9d4812
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2024-09-03 21:41:26 +00:00
Shawn Rutledge
bb15139024 Client: Register QPointingDevices for graphics tablet devices
Followup to 4d844d36404597713a63879dc24f051de0ad3e5b

Reference material: https://wayland.app/protocols/tablet-unstable-v2

It's not clear how to get the number of buttons on a stylus.

QWaylandTabletToolV2::zwp_tablet_tool_v2_removed() is called when a
stylus leaves proximity; but we avoid deleting the QWaylandTabletToolV2
instance too soon, because a proximity leave event may be in flight at
the same time, carrying a pointer to the stylus device. Instead, each
"dead" tool is deleted when another enters. The tablet protocol makes it
difficult to retain the same instances indefinitely, as we would
otherwise do: the zwp_tablet_tool_v2 is constructed elsewhere, a pointer
is given to the QWaylandTabletToolV2 ctor and retained. So a "dead" tool
may hold a dangling pointer; and at the time a new QWaylandTabletToolV2
instance is constructed, its details are not yet known, so it would not
be possible to look up and reuse an existing matching instance (as we
would otherwise probably do).

Task-number: QTBUG-72167
Task-number: QTBUG-112432
Task-number: QTBUG-115207
Pick-to: 6.8
Change-Id: I3423a0d0bd2aae5be4e61cc60da8c3362a80d10e
Reviewed-by: Liang Qi <liang.qi@qt.io>
2024-09-03 16:40:51 +02:00
Shawn Rutledge
e168e1fc80 client: Provide seat name to QPointingDevice
Followup to c16f6d40518fce6576c311c658956e21f7d52372

Task-number: QTBUG-85272
Task-number: QTBUG-115207
Pick-to: 6.8
Change-Id: Icb6053e76432bb9ef58f1457da073695a674c6f6
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-09-03 06:09:37 +02:00
Michael Weghorn
4ef2c11560 Mark QWaylandWindow::windowTitle as overriding base class impl
QPlatformWindow::windowTitle is newly introduced
in qtbase and matches the semantics that
QWaylandWindow::windowTitle already implements, so
mark it as overriding the base class implementation.

Task-number: QTBUG-127563
Change-Id: Ia43359a494fde41314220c8d57783d114d9b8fa4
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-08-24 05:54:29 +00:00
David Edmundson
92952bd04a tests: Fix flakey reconnection test
testMultiScreen explicitly sets clients on monitors, for this to work we
need autoEnter disabled

Change-Id: Icb29b743ff8e645b4f22113a87a1ae09683fb044
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-08-16 09:39:31 +01:00
Eskil Abrahamsen Blomfeldt
458aadde42 doc: Add "since"-note about 6.8 additions in cmake API
The PUBLIC_CODE/PRIVATE_CODE APIs were added to the cmake
functions in Qt 6.8, so this should be mentioned in the docs.

Pick-to: 6.8
Change-Id: I0430cbc659ddd2db65401b94811ca0d4c8f12010
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-08-16 08:30:36 +02:00
Tim Blechmann
af6f515806 Fix compilation with -qreal float
Task-number: QTBUG-118877
Pick-to: 6.8
Change-Id: Ie5d4f8b500276e0939da6899306fcd6c87b226df
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-08-13 13:40:13 +08:00
David Edmundson
ce176682bc Client: Add test that we always respond to configure events
Change-Id: I35ca2bb3287efa4c79f1352ebc7f5da872b2d4ce
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2024-08-12 22:48:09 +01:00
David Edmundson
b2161c6bad client: Update internal geometry before notifying shell surfaces
Some shell surfaces will query sizes on the window directly. In particular Xdg Shell Popup repositioning.

The update is still processed before the expose event, so we have a chance to pause rendering for async geometry changes.

Change-Id: I3961b282dbb450c864e3543ef267ddcd7a9c36d7
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-08-12 21:48:02 +00:00
David Edmundson
c82535143a client: Correct argument name in input events
Input events sometimes carry serials or times, sometimes both, depending
on the event. The code has drifted from the spec. In the worst case we
are setting a serial as a timestamp which is very wrong.

Change-Id: I82397e06a432de79ef71475882673da4568743ca
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-08-08 23:09:27 +01:00
Eskil Abrahamsen Blomfeldt
7062695de7 compositor: Add CMake options to control visibility of generated symbols
This exposes the public-code / private-code options for the
waylandscanner. It is the server-side version of
2962aa9ed9487bc6aa54810ed4ace114b4f7d723.

Task-number: QTBUG-126301
Change-Id: I32490f6cbc9cac876c1f07c3930e8bafbc395e75
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-08-08 11:56:25 +02:00
David Edmundson
8754c9fe83 client: Workaround Gnome's incorrect xdg-geometry sizes
Mutter, depending on the scaling mode, will sometimes send the xdg
geometry size in device pixels rather than logical pixels.

It is reported as https://gitlab.gnome.org/GNOME/mutter/-/issues/2631
but it is closed upstream so we cannot rely on them fixing it.

This patch introduces the same workaround that GTK ships to work around
this behavior. If the scale is set, and the xdg geometry matches the
output geometry, then we can assume we don't have logical pixels for the
xdg geometry and should calculate it manually.

Fixes: QTBUG-122197
Change-Id: I7f640bac619be6eb07c84bb6913334a6356524a2
Pick-to: 6.8 6.7 6.5
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
2024-08-01 07:40:27 +00:00
Liang Qi
4bd62f740f QWaylandXdgSurface: add suspended in debug output
Pick-to: 6.8
Change-Id: I9318d132d3863f38d7264ebe360aad95de575fc4
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-07-30 14:13:25 +02:00
Ahmad Samir
37f25aeefb QWaylandClipboard: simplify some code
Change-Id: I4b87c1be8cb147830a3ad0ba8912134e12d226f5
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-07-22 20:07:34 +03:00
Ahmad Samir
d30ce747c2 QWaylandClipboard: fix crash when setting the same QMimeData* more than once
This also fixes a crash in qtbase's tst_qclipboard, one of the tests
there expects that calling setMimeData() on the same QMimeData* won't
cause a crash. This matches how QXcbClipboard behaves.

Amends 5925c3110df258e78e6086e3bf526b8f6f779039.

Pick-to: 6.8 6.7
Change-Id: I057315aa1466857b7cd7181eba92068e92154ef5
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-07-22 20:07:29 +03:00
David Redondo
279406aa20 Client: Use std::unique_ptr to manage window decoration
There was a potential crash in the QWaylandWindow destructor. First it
deletes the window decoration (but does not unset the pointer!) and then
deletes the surface via reset(). This eventually triggers
QWaylandDisplay::handleKeyboardFocusChanged which will call
decoration->update().
Using std::unique_ptr makes it easier to manage and prevents such errors.

Change-Id: I52edcdab0d25c35dc656581fbb5c1c9b5ca481c4
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2024-07-22 09:31:01 +00:00
David Edmundson
c50ebcd83d client: process exposure updates in the main thread
This is important for when synchronous delivery is enabled as that should only happen from the main thread.

Change-Id: I524443c6d2dd8dee8d36834b6d3032eb8f8c1750
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2024-07-18 11:10:18 +00:00
Volker Hilsheimer
6b6d4e4b0b Logging: use qCDebug/Warning/Info for categorized logging
When building qt with QT_NO_DEBUG/WARNING/INFO_OUTPUT set, then the
qDebug/Warning/Info macros expand to `QMessageLogger::noDebug`. That
helper is not defined to take a logging category or category function,
so using `qDebug(lcX, ...)` breaks the build. The correct way to emit
categorized logging is to use the qCDebug/Warning/Info macros.

Task-number: QTBUG-125589
Pick-to: 6.8 6.7 6.5
Change-Id: Ib76a3f2a366a2be27ebc2679be01a883a048347a
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-07-16 16:52:36 +02:00
David Edmundson
9a5054cb62 client: Guard against windows being on a null screen
calculateScreenFromSurfaceEvents uses the screen information from our
surface enter events. If this is not set yet, or refers to outputs not
yet complete we fall back to the QWindow::screen. This was introduced in
2f7a86fac338dc78259d93b675f1cd131c24c926.

It was assumed that this would always be a valid value as QtBase keeps
it updated, but there are apparently paths for it to still be null.

It will be evaluated again when the surface receives a wl_enter event or
the output that we have entered is finally initialised and we will then
be marked as on the correct screen.

Pick-to: 6.8
Pick-to: 6.7
Change-Id: I33b4a5112c3426a8ea523d39a0658ba7ffee5298
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2024-07-15 15:11:24 +01:00
David Edmundson
e705040909 client: Cache exposed state and unify sending events
Right now we are sending an expose event on every configure event
because exposure may have changed. This causes an overhead.

The mechanism for sending expose events is also scattered, there are a
lot of properties that affect exposure, having everyone track the full
state gets messy.

This is cleanup work to then be able to land viewport clipping and
synchronous event delivery.

Change-Id: I192b908cdb6f6adda7d0e33f83961861e09504e8
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2024-07-15 13:53:10 +01:00
Alexandru Croitor
18355d9d37 CMake: Annotate some targets with SBOM information
Pick-to: 6.8
Task-number: QTBUG-122899
Change-Id: I32c1489bbb3e3a48377f6aef94e4cd639257c9a1
Reviewed-by: Lucie Gerard <lucie.gerard@qt.io>
2024-07-12 11:36:22 +02:00
Alexandru Croitor
fd42445f06 CMake: Move each wayland protocol into a separate subdirectory
So that there is one qt_attribution.json file for each protocol, rather
than a single file with a long list.

This will simplify maintenance of annotating the targets for SBOM
generation when referring to the attribution files, and in general
simplifies maintenance of the attribution files.

It also makes it clearer if a 3rdparty protocol is missing an
attribution file.

Currently, the following protocols are missing attribution files:
- cursor-shape
- idle-inhibit
- xdg-toplevel-drag

And the following are unused:
 - xdg-shell-unstable-v6

[ChangeLog][Third-Party Code] Split the single qtwayland
3rd party qt_attribution.json file into multiple ones, per protocol,
to ease maintenance.

Pick-to: 6.8
Task-number: QTBUG-122899
Change-Id: I412df7f53715f55270280ab91f16a6d40f12a4f0
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2024-07-12 11:36:20 +02:00
Alexandru Croitor
7c4bbcfbf4 CMake: doc: Move 'since qt version' below find_package
To be in line with other command documentation.

Pick-to: 6.8
Task-number: QTBUG-126471
Change-Id: I1cf1078e8c4cd5dd27881294986457c63aa6c956
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-07-11 22:55:40 +02:00
Liang Qi
d4492782ed Update wayland.xml to version 1.23.0
This updates only the protocol definition, implementations
will need additional commits to opt into using them.

Change-Id: I5999e6dd75dfff7d904981fb1545d58c8b38ceb0
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-07-10 07:31:34 +00:00
Nicolas Fella
5d77ed0258 Client: Properly handle tablet manager being announced after wl_seat
When wl_seat is announced we create QWaylandInputDevice and there check
whether the tablet manager is available, create the tablet seat,
and store it in mTabletSeat.

If zwp_tablet_manager_v2 is announced after wl_seat, which
happens e.g. on Weston, we created the tablet seat in the
QWaylandTabletManagerV2 ctor, but didn't update mTabletSeat.

To address this, we move the handling to QWaylandDisplay and pass the
manager to QWaylandInputDevice, similar to how we do it e.g. for
text-input.

Pick-to: 6.8 6.7
Change-Id: I902375ec0085d34ba99cbe59bbbc4051e7d1e802
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2024-07-09 08:09:14 -07:00
Liang Qi
4ad1c345a0 Revert "client: implement QWaylandScreen::topLevelAt()"
This reverts commit 682f7c4b78ce130d621d70b770062d76cd13fa2a.

QtWidgets depends on the old QApplication::topLevelAt() behavior too much, especially for the single top level window case. It's not easy to be decoupled in this way.

Task-number: QTBUG-113404
Fixes: QTBUG-125878
Fixes: QTBUG-126313
Pick-to: 6.8 6.7 6.5
Change-Id: I5804d9c600c77e85f4f83753c87815fbbbc2362e
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-07-01 08:48:11 +00:00
Nicolas Fella
803f160dc3 Client: Pass modifiers to tablet event handling
So that the resulting QTabletEvent has the modifier information

Pick-to: 6.8 6.7 6.5
Change-Id: Ifbd771f59ac41b740ccb65db2986726e7a32a760
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2024-06-30 15:09:08 +02:00
Nicolas Fella
e349e5529d QWaylandDataDevice: Use lastInputWindow as source
Currently we only consider the pointer focus and touch focus window,
but not tablet input

Pick-to: 6.8 6.7
Change-Id: I62558a9b6362c9d773fbdf8949468529ee83bffe
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2024-06-26 20:34:40 +02:00
Nicolas Fella
de63a04367 QWaylandTablet: Update input device serial on events
Fixes: QTBUG-118640
Pick-to: 6.8 6.7
Change-Id: I46ed31d85f9c80ac27ab9c161c23fcb429f82f43
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2024-06-26 19:09:47 +02:00
Vlad Zahorodnii
1dc1938cd7 Client: Split requests to set window and content geometry
Currently, QWaylandShellSurface::setWindowGeometry() serves several
purposes. It's used to specify the bounds of the content when using
client side decorations (not preferred but the one that's painted) and
it's used to tell the compositor the preferred window size. These two
use cases are very different in nature.

This change introduces QWaylandShellSurface::setContentGeometry()
request, which can be used to communicate the bounds of the client
side decorated content. The content geometry is specified in the
surface-local coordinate system, i.e. 0,0 is the main surface's top
left corner.

QWaylandShellSurface::setWindowGeometry() takes window geometry in the
global coordinate system, excluding the drop shadows.

[ChangeLog][QtWaylandClient][Important Behavior Changes] The
QWaylandShellSurface::setWindowGeometry() function is no longer suitable
for communicating the bounds of client side decorated content. Custom
shell implementations should use
QWaylandShellSurface::setContentGeometry() instead.

Change-Id: I134ce4f0866d3abbe7050ed6769dc586210eac27
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-06-26 14:49:50 +03:00
David Edmundson
949bcf8712 client: Drop the concept of a queued buffer before the first expose
Added in 46aece51330b6f9b5b4bfd68a5b3b183dc5b1c38 this was part of a
guard to handle clients committing before the window was configured.

Since then there has been work in ensuring expose events are delivered
to the client correctly only when the window is configured. Including  e6d55239c454d454978edb7d8b17f6c993e7ba07.

Even if a client does manually explicitly flush a paint before the first expose, we should be able to simply discard the buffer. It's part of the contract that a client should redraw contents when it gets an expose event. This is better as any queued buffer cannot be of the right size and it simplifies the code.

Pick-to: 6.8
Fixes: QTBUG-126262
Change-Id: Ia4829ca75a55819b5e8ab366baedcdf83dfc14ec
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-06-26 08:44:21 +00:00
Eskil Abrahamsen Blomfeldt
dba3e364c9 Fix flakiness in tst_surface::createSubsurface()
The tst_surface test has disabled automatic frame callbacks
in the mock compositor. This means that if the timeout for
this (100 ms) happens before the test finishes, all
subsequent calls to isExposed() will fail, and commits will
not be sent.

The automatic frame callback was added for this specific
reason, but for some reason it was disabled for
tst_surface. This might just be conservative, but in
case it could break some condition in the other tests, I
have only enabled it for the specific test where it is
clearly required.

Task-number: QTBUG-126262
Change-Id: I91dbd6d837b5444c5e07659dc0b73fb28ece151d
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-06-24 12:07:32 +02:00
Inho Lee
0b1d950e43 TextInputV3: Prevent a recursive update call
While scrollEvent,
Qt calls textinput' update with cursorRect
and anchorRect. In that case,
TextInputV3's update function can make
another update calls with saved data from
compositor.
So, commit will be skipped for cursorRect
and anchorRect.

Fixes: QTBUG-126275
Pick-to: 6.8 6.7
Change-Id: I9c47c46b20a227e72488e3b9bac3d6fc5e4b9066
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
2024-06-20 18:29:08 +02:00
Niccolò Venerandi
6c836fe5fb Emit a LeaveEvent on drag and drop start
All focused windows will now receive a LeaveEvent when a drag and drop starts.
This makes sure that the dragged element does not preserve any hover decoration
during the drag and drop, and that other elements that happen to take place
of the dragged elements don't become hovered too.

Pick-to: 6.7 6.8
Change-Id: I0924fff987f143aff11284c808027dd210b48c2b
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-06-20 16:28:14 +02:00
Vlad Zahorodnii
df83f3e568 Client: Ensure that guessed popup parent has a shell surface
The last input window may not have a shell surface if it is a subsurface
or that window has been just made invisible.

Pick-to: 6.8 6.7
Change-Id: Iad11c68659579429ddc5d9ba0038975b25da8e0d
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-06-20 15:41:43 +03:00
Ulf Hermann
ec951588a8 Prepare for hiding of logging categories in namespaces
We can and should use the new export macro for the client logging
categories, but we need to manually define the compositor logging
categories now since they are public and we cannot change their symbols.

Task-number: QTBUG-67692
Change-Id: If4eb9c390a4851945d308e2b83ef13b12816698a
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-06-14 16:08:13 +02:00
David Redondo
56e4b5fa01 client: Remove support for surface extension
Qt Wayland Compositor does not implement this anymore.

Change-Id: If7a780218991aa35e9a34cd0eda3ae59a99844a2
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-06-05 15:48:27 +02:00
Kai Uwe Broulik
c1e0ffd286 QWaylandDataDevice: Use internal input device keyboard modifiers
QGuiApplication::keyboardModifiers() is somewhat wonky on Wayland
because on Wayland a modifier update is sent after the key event
but Qt only updates the modifiers in response to actual key events.

While this should also be fixed, using our internal state is
an easy way to avoid this and ensure the keyboard modifiers
in a drag/drop event are correct.

Pick-to: 6.8 6.7 6.6 6.5
Change-Id: I8bf0190663d7d47ea3d261e6daa4f622ea031e82
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-06-05 08:10:17 +00:00
David Edmundson
9425194431 tests: Re-enable test dontCrashOnMultipleCommits
Since the test was disabled, many changes have been made
in improving the mock compositor with regards to stability.
It appears the need to skip this test have been resolved.

Change-Id: Ia01528a29aca20f5ec7434401669672a0c5ac388
Fixes: QTBUG-68756
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2024-06-04 14:10:05 +00:00
Vlad Zahorodnii
ea0fbf92ec tests: Bump wl_compositor to v6
Change-Id: I4aa61193460ef9d2c8b4f9d46e10ef5bad4dcc87
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-06-03 11:13:26 +03:00
Vlad Zahorodnii
5ecf0fcdf1 tests: Implement wl_compositor v5
Change-Id: I60ff85d20b545ae97e3bbb49313ebedf1224a3ac
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-05-30 13:56:37 +03:00
Alexey Edelev
7fdb0a1c4a Remove the use of GENERATE_CPP_EXPORTS argument
The behavior that argument was enabling is the default one now.

Task-number: QTBUG-90492
Change-Id: I757472613f2c71eed9826c02de6f1cfc6727dc51
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-05-30 08:18:31 +01:00
David Redondo
c4b1a27943 client: Add option to automatically delete a buffer upon release
This is useful when using with protocols that use buffers that are
basically one-shot and  managing and reusing multiple buffers
is not needed.

Change-Id: Id4f6c01b7e873540fd87ab663ceb9069f2de0ca1
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-05-29 09:00:33 +02:00
Vlad Zahorodnii
9f3228ca4c Client: Fix QWaylandWindow::mScale default initializer
Amends 2c9580bf63cba0d4f470b594536692e2fbb01b1b.

Fixes: QTBUG-125872
Pick-to: 6.7
Change-Id: Iea58cf4dbd879cb1b443edf8b75f4f6bce4bc1a6
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-05-29 07:48:02 +03:00
David Edmundson
afa2909166 client: Support popup repositioning
Xdg popups can be repositioned at runtime. An important example is
tooltips where the same instance gets re-used between multiple
invocations.

shellSurface->setWindowPosition is guarded to not run from configure
events to avoid a feedback loop.

Window exposure is changed in xdgshell to mark the window as exposed
when applying the configure, not when it is received. This is needed to
ensure geometry is up-to-date.

This patch is orthogonal to providing proper semantic positioning.

Change-Id: I673957832d34129e9b9fc8fba732ffb2083a4d0b
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-05-28 14:53:09 +03:00
Inho Lee
668c086eff TextInputv3: fix indices and positions
Indices and positions in wayland are byte size
But some when qtwayland uses QString the size
conversion was incorrect.

Task-number: QTBUG-121446
Pick-to: 6.7
Change-Id: I4e25fb437557a2d6556050599d582ffacabcedbc
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-05-27 15:34:46 +02:00
Ilya Fedin
4580eac41c Client: Update size hints on custom margins change
As size hints get sent in window content geometry,
they have to be updated once window content geometry changes

Pick-to: 6.7 6.5
Change-Id: I7c17770d29be8381b0c43ab724202219a9cf7a5f
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-05-25 21:16:46 +04:00
David Edmundson
8457dd76e3 client: Avoid roundtrip to handle xdgoutput race condition
The original bug was that we could get a surface enter event before the
xdg output was fully ready, where we had a QPlatformScreen but no
QScreen announced.

A solution with a roundtrip was added, which works, but roundtrips cause
other problems processing messages out of order and inhibts a move to
synchronous delivery.

As an alternative fix we move the problem from QWaylandWindow to
QWaylandSurface and have that filter out not-ready QScreens.
The best output is then re-evaluated whenever a screen is added.

Change-Id: Iabc78917112aa8c58cad8e128c5bb3030f8c8f65
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-05-25 16:37:30 +01:00
David Edmundson
2f7a86fac3 client: Always update the window's screen on changes
QWindow::screen can be set by an application programmatically or be
updated from the platform.

Currently when the QPA handles a screen change we compare against
mLastReportedScreen to determine if we need to update anything.

This results have a situation where sometimes we use the new value from
the platform, sometimes not, depending on which screens happened to be
used.

To be consistent, always check against the window's current screen.

Change-Id: I7ea15aa497a81d0cf46efe274f83f4667304623e
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2024-05-25 16:28:21 +03:00
Vlad Zahorodnii
2c9580bf63 Client: Fix initialization of QWaylandWindow::mScale
QWaylandWindow initializes mScale to the scale factor of the currently
assigned screen when it's constructed. However, it doesn't keep track of
subsequent screen changes that may occur afterwards before
QWindow::setVisible(true). For example

    window.setScreen(foo);
    window.create();
    window.setScreen(bar);
    window.show();

In that case, the value of mScale will correspond to the scale factor
of output "foo" when show() is called.

A better place to initialize mScale is when the show() function is
called. Furthermore, since there's wl_surface.preferred_buffer_scale and
fractional_scale_v1.preferred_scale events, QWaylandWindow could stop
guessing the scale factor and rely on the compositor telling us that
information. However, it's important that the compositor sends the
preferred buffer scale before the first configure event arrives.

Fixes: QTBUG-124839
Pick-to: 6.7
Change-Id: I842aaa352d9cb1e53158f64f2ec0cd3734f7ecf3
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-05-24 14:23:57 +03:00
Vlad Zahorodnii
76f8559ca6 Client: Try harder to guess the transient parent window
xdg_popup requires a parent surface. On the other hand, Qt is quite
permissive, it allows showing a popup window without specifying the
transient parent window. Things have been slowly changing and more
controls specify the transient parent, but there are still apps that
don't do it. For that particular reason, QWaylandWindow has some
heuristics to guess the transient parent.

Currently, that heuristic works as follows:

- If QWindow::transientParent() is set, use that
- otherwise use the focus window

However, this heuristic doesn't consider that a window can be inactive.
For example, user hovers an element in the window while the window has
no focus.

This change proposes a heuristic that considers the last interacted
input device, i.e.

- if QWindow::transientParent() is specified, prefer that
- if there's a "top" popup, use it
- otherwise check the last interacted window

With the proposed heuristic, tooltips are less likely to be backed by
xdg-toplevel in inactive apps.

Pick-to: 6.7
Change-Id: I7e6a607dc38f9e8adce316d3540a9bd9c37cfed4
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-05-24 13:15:09 +03:00
David Redondo
4611355d69 client: Explain what PUBLIC_CODE does
Change-Id: If7d0954561cecddefada49d7f00359a711bb9e29
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-05-15 14:12:53 +02:00
Kai Uwe Broulik
7cf59cf455 Revert "Revert "QWaylandDisplay: Allow software-only deco and don't init GL needlessly""
This reverts commit ddb35b21ee48ca72808d5bcd865edd4ba64d75e8.

Reason for revert: Cause for test failure has likely been addressed by 38ac95c03b423a063d095aaa4e3254a43f97c49b

Fixes: QTBUG-124284
Fixes: QTBUG-124285
Change-Id: Iedeb1d2800951e549fe4a4846aaaa477cfa497ae
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-05-15 06:33:00 +00:00
Moss Heim
b28eed534f Remove unused private field
This causes a build failure under clang 17.

Change-Id: I9e256109ec6e7de146334012bce90912d0d4bb62
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-05-13 13:31:39 +02:00
David Edmundson
38ac95c03b tests: Don't use auto and manual configure together
The tests always send an explicit manual configure. This is important
because we want to test the client's first buffer is correct and this
comes after the first configure event.

Having auto configure enabled means it's racey and flakey between the
auto response on the compositor thread and the client dispatching a
manual repsonse.

Change-Id: I92170a2d96c01d01c22983e43ff1f1281b1a48a2
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-05-13 09:24:24 +01:00
David Redondo
24cd08a667 client: Disentangle platform services and windowmanagerintegration
The current state was a bit messy with the platform services being
the potentially no initialised qt window manager extension wayland
object.

Change-Id: Id1f911b75d34fcf70594ca7257b79bf431f0643f
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-05-10 08:57:33 +02:00
Lucie Gérard
4313de83d6 Change license for tools files
According to QUIP-18 [1], all tools files should be
LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

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

Pick-to: 6.7
Task-number: QTBUG-121787
Change-Id: I9a08423046dd325dd267d2390faf8d2eb0c76315
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2024-05-03 12:43:53 +02:00
Inho Lee
f6fb0407de Make wheel operations compatible with xcb
On xcb, Alt modifier makes wheel operations horizontal.

Fixes: QTBUG-124807
Pick-to: 6.7 6.5
Change-Id: I98cfe14b4df91169a5ff4e777ebe954087747e17
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-04-30 19:14:25 +02:00
Samuli Piippo
54af4f6e88 qtwaylandscanner: don't track source file location
Generate source code without information about original location of the
source file. Useful for reproducible builds.

Task-number: QTBUG-105926
Task-number: QTBUG-105913
Change-Id: I5f9b3f90e6e85c772a92425e7b796a9d63c3c713
Reviewed-by: Ari Parkkila <ari.parkkila@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-04-29 15:45:02 +00:00
Kai Uwe Broulik
0fc235c503 QWaylandWindow: requestActivate on show
For simplicitly, a Wayland compositor typically activates a window
when it is mapped. However, it does not necessarily have to and
might not want to in order to prevent stealing focus.

Inttroduce a requestActivateOnShow() on the shell which is called
when showing a window and, in case of XDG Shell, will explicitly
request activation (unless Qt::WA_ShowWithoutActivating is set)
and make use of the existing XDG Activation infrastructure.

Change-Id: I69ab5f2cee4540d5baefa5a266f22dbb165e4192
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-04-26 19:31:15 +01:00
Liang Qi
682f7c4b78 client: implement QWaylandScreen::topLevelAt()
For security reason, Wayland doesn't provide global position for
top level windows in most cases.

Task-number: QTBUG-113404
Pick-to: 6.7 6.5 6.2 5.15
Change-Id: I2cd11b641fba6582cf96cfbea16f5e598a473db5
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-04-22 15:44:41 +02:00
Liang Qi
f53c249d06 client: Synthesize enter/leave event for popup in xdg-shell - 2
This amends 179d0d34fa6b7d8d90ea766ac146c4b6485f3803.

We can't depend on QGuiApplication::topLevelAt(). For security
reason, Wayland doesn't provide global position for top level
windows in most cases.

We just synthesize enter/leave event for popup between it and the
parent.

Task-number: QTBUG-100148
Task-number: QTBUG-113404
Pick-to: 6.7 6.5 6.2 5.15
Change-Id: I9de1d413cdbc43486c1a110df4517750983e4fda
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-04-22 15:44:39 +02:00
Eskil Abrahamsen Blomfeldt
d3ea4de423 Make build error less ambiguous
The phrasing of the error message caused some confusion when people
thought it indicated that QtGui itself was missing from the build.
This tries to make it very explicit that it is the wayland-feature
which is missing and not QtGui itself.

Pick-to: 6.7
Task-number: QTBUG-123489
Change-Id: I8dcdf8bdbb05a379dea3021cec8bf8e7036d55dc
Reviewed-by: David Redondo <qt@david-redondo.de>
Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
2024-04-18 09:15:20 +02:00
Kai Uwe Broulik
01f102b2f9 Client: Wire up surfaceRoleCreated/Destroyed signals
Emit them after creating or destroying the shell surface.

Change-Id: Ied54933ca0f0aec25cc288f7cfe191c85b37f543
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2024-04-17 16:25:13 +00:00
David Redondo
2962aa9ed9 client: Add CMake options to control visibility of generated symbols
Using public-code by default is problematic if multiple libraries
contain wayland interface definitions generated with public-code
which exports the symbols of the interface definitions from the
library. If not all libraries are build against the same protocol
version and the symbol is resolved to a version generated from an older
version of the protocol, then libwayland will detect a protocol error
if a request or event from the newer version is used.
This introduces two new options PRIVATE_CODE and PUBLIC_CODE to
qt6_generate_wayland_protocol_client_sources which correspond to the
wayland-scanner options. For backwards compatibility PUBLIC_CODE
is the default.

Change-Id: Ia30ec4b83419962b768207d7353c495e11b0268e
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-04-15 14:50:16 +02:00
Eskil Abrahamsen Blomfeldt
ddb35b21ee Revert "QWaylandDisplay: Allow software-only deco and don't init GL needlessly"
This reverts commit aff3a43bf067656d326bb17f31ee097684213c22.

This optimization causes flakiness in the xdgdecorationv1 test, possibly
because it no longer handles the case where the supportsWindowDecoration()
function is called before the buffer integration is initialized.

So it unfortunately has to be reverted until a better approach can be
figured out.

Fixes: QTBUG-124259
Change-Id: I05f13a51b22b6779bffba531f08ebfd17a9afb38
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-04-11 12:44:39 +02:00
Vlad Zahorodnii
a3f4b0671f Client: Close xdg popups using QWSI::handleCloseEvent()
This shouldn't matter in practice, the main motivation behind this
change is to make window closing code consistent both for xdg-toplevels
and xdg-popups.

Change-Id: I74ef11ddbaf942cb545bb04baf7b35979adde81c
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-04-05 18:35:50 +03:00
Vlad Zahorodnii
c8451104de Client: Use QWindowSystemInterface::handleCloseEvent() to close xdg-toplevel
QWindow::close() will close a window regardless whether it's blocked by
a modal dialog. On the other hand,
QWindowSystemInterface::handleCloseEvent() will do nothing if a close
event is sent to an xdg-toplevel window with a modal dialog.

Pick-to: 6.7
Change-Id: I5f18d38d4fdbb5748687ee3537035172df916de9
Reviewed-by: Kai Uwe Broulik <kde@privat.broulik.de>
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-04-05 10:16:45 +03:00
Lucie Gérard
f3418491f2 Correct license for test files
According to QUIP-18 [1], all test files should be
LicenseRef-Qt-Commercial OR GPL-3.0-only

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

Task-number: QTBUG-121787
Change-Id: I35b93ca5f2fd27685eda4aafda48c24925c0c56f
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2024-04-04 14:24:21 +01:00
Kai Uwe Broulik
aff3a43bf0 QWaylandDisplay: Allow software-only deco and don't init GL needlessly
Don't initialize the client buffer integration just to check whether it can
do a decoration. If we had a GL window, it would have initialized GL already.

Also, we can do software-rendered decorations nowadays, only disable them
if the integration explicitly says it can't.

Change-Id: I396d32796a10ccffd6ef3bb0c5eaa3a1078b8d79
Reviewed-by: Ilya Fedin <fedin-ilja2010@ya.ru>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-04-02 07:40:59 +01:00
Ilya Fedin
2ab62833e2 Client: Replace a bunch of frameMargins with clientSideMargins
Use it wherever window coordinates should be translated to surface
coordinates

This also fixes the usage of QWindow::mapFromGlobal which is in wrong
coordinate space while handling CSD dragging from pending touch points

Change-Id: I66b114610f0e44fea10535594adb5d1284196662
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-03-29 12:42:59 +04:00
David Redondo
de0be2b5dc client: Implement dialog-v1 protocol
Allows to mark windows as modal dialogs.

Change-Id: Ie4999552933e02fc473e621e7cc5e3f2928c0adb
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-03-27 13:43:55 +01:00
Ilya Fedin
298c81ef7d Bradient: make drawing coordiantes consistent
Currently some parts of the decoration use surface size
(window icon, window controls) while other parts use window content
geometry. As backing store paints it from the start of the surface,
use surface size everywhere.

This is visible when setting custom margins.

Change-Id: I22a84fd35bd6e088c30ea265d8cb4af86f14e1a5
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-03-26 03:53:03 +04:00
Alexey Edelev
d5252fff74 Use NO_GENERATE_CPP_EXPORTS explicitly
Use NO_GENERATE_CPP_EXPORTS explicitly for modules that don't need
the autogenerated exports header file.

Task-number: QTBUG-90492
Change-Id: I3494ac88e136126265e14ef1a380c5ef26def3ef
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-03-25 11:09:35 +01:00
Lu YaNing
e89e8bf73f Use static_cast rather than dynamic_cast
To avoid RTTI.
When I tried to implement the reconnect function in Plasma5,
I found that the application would have a dynamic_cast crash
problem. Referring to other usage logic and suggestions in Qt,
it is recommended to avoid using dynamic_cast.

Change-Id: I4fd41846c3215f60aafc7e38d1542d52ec6759b8
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-03-21 09:06:41 +08:00
Ilya Fedin
1d6cecbb4a Client: Fix the mouse being stuck in pressed state after startSystem{Move,Resize}
Fixes: QTBUG-97037
Pick-to: 6.7
Change-Id: I812c25b98909f9ff05ffca122e7201665023172e
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-03-20 20:56:55 +04:00
David Redondo
8066293430 scanner: Make it work with mismatching protocol and file name
The names of the files that wayland-scanner generates are based on the
protocol file name not the protocol name that is defined in the xml.
When those two mismatch qtwaylandscanner would generate code that fails
to build.

Pick-to: 6.7
Change-Id: Ieecd7a122177530ab1ff890367ce53809a8bb7b9
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-03-20 08:53:07 +01:00
David Redondo
997b12fd56 client: Roundtrip in an own queue when exporting window instead of default queue
This way no other events will be dispatched which could cause calls into
user code when delivering events synchronously.

Change-Id: I5c195877388d178832067b5aba6b5f5abd26e099
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-03-20 08:52:42 +01:00
Jan Grulich
610bcae568 Add GNOME-like client-side decoration plugin
Adds a client-side decoration plugin implementing GNOME's Adwaita style.
This is trying to follow GTK4 Adwaita style, using xdg-desktop-portal to
get user's configuration in order to get whether a light or dark colors
should be used and to get the titlebar button layout. This plugin is now
used on GNOME by default, while defaulting to the original behavior for
non-GNOME DEs. It depends on QtSvg used to draw titlebar buttons so in
case QtSvg is not found, this plugin will not be build.

[ChangeLog][QtWaylandClient][Added GNOME-like client-side decoration
plugin]

Fixes: QTBUG-120070
Change-Id: I0f1777c4e0aa3467dafbbae8004b594cc82f9aa0
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-03-19 14:38:40 +01:00
Inho Lee
dce4d1a351 TextInputv3: use a serial for each resource
Each zwp_text_input_v3 object should have their own
serial number and it will not be cleared on the same object.

Pick-to: 6.7
Change-Id: I779c2ae07f1dab1ae4a7d87e4e183ce33ec804fe
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Weng Xuetian <wengxt@gmail.com>
2024-03-19 10:22:09 +01:00
David Edmundson
3134fef6e4 client: Only use viewport when fractional scaling is in use
Either viewport or wl_buffer.set_scale can be used to notify the
compositor that the client has scaled it's contents, with viewport being
more flexible and a requirement for fractional scaling.

Unfortunately Gnome before 36 announces viewport support, but it does
not work correctly. This patch workarounds that by only using the
viewporter when we're using fractional scaling otherwise continue using
the legacy path.

Fixes: QTBUG-122412
Pick-to: 6.7 6.6
Change-Id: I9a01d9456ce91735051f8f53fb4b72add6961fcb
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-03-14 09:24:45 +00:00
Liang Qi
e30dbe924b client: don't cache one type in QWaylandMimeData
"application/vnd.portal.filetransfer", which is only valid for one
time use.

Fixes: QTBUG-107858
Pick-to: 6.7 6.6 6.5 6.2 5.15
Change-Id: I094de22ea0bb9b3577572e6c57ebe42cdc8c7b41
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-03-13 12:37:27 +01:00
Liang Qi
4446f4571a client: use current modifiers in repeat keys
This amends 97232a3fd8970a072e36ac3d080ce828dd9243fb .

Fixes: QTBUG-123007
Pick-to: 6.7 6.6 6.5 6.2 5.15
Change-Id: I3b4e5d4a8304fd57558eec3897562895c294aadd
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-03-10 19:14:20 +01:00
JiDe Zhang
d3adcc073a Support multi-key for input context plugin
Sync from QPlatformInputContextFactory::requested in
8596998cb025a8338c9403f5ef9db5a23f5cc682 of qtbase to
QPlatformInputContextFactory.

Fixes: QTBUG-120202
Change-Id: Ib15d8a59c4cb3baaa19355ed5d7c30c87a7a1c16
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2024-03-10 16:51:56 +00:00
Kai Uwe Broulik
5fb45c9590 QWaylandShmBackingStore: Don't clear new buffers in beginPaint
QFile::resize done upon creation of the buffer already ensures
the buffer is filled with zeroes, so there is no need to paint it
transparent if the buffer had just been created.

Change-Id: I73ab297f148987acf52a0e08c7dd1ca57f7255be
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2024-03-05 08:36:25 +01:00
Kai Uwe Broulik
7de67b2db7 Revert "QWaylandDataDevice: Explicitly send null for rejected drag offer"
This reverts commit 6b8be3a4a95f3861c6b2c5d62925cc03651a7ddd.

Reason for revert: QtWaylandScanner now sends null for a null QString when the argument is declared as allow-null

Change-Id: I5b7e23285b300b76dabfd2999ab90e90e7328232
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-03-04 08:18:25 +00:00
Volker Hilsheimer
4b58d6ddce De-blacklist tst_seatv4::animatedCursor test
The test has no history of BFAIL outcomes for the last 6 months in
the dev branch.

Fixes: QTBUG-78317
Change-Id: I49742be9f3eac6463b066ede69e2cd143e1b35dd
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-02-28 21:19:23 +01:00
Kai Uwe Broulik
75d324cbb9 qtwaylandscanner: Send null for a null QString with allow-null
`toUtf8().constData()` on a null `QString` results in an empty
string sent over the wire, which is distinct from `null` when
the request has "allow-null" specified.

Notably `wl_data_offer.accept` uses a null mime_type for
"not accepted".

[ChangeLog][Important Behavior Changes][qtwaylandscanner] String
arguments in a request will now send null rather than empty string
for a null QString if the argument is declared with "allow-null".

Change-Id: I4b78246e4da7b60680d7797fd6309755f44d2bb6
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-02-28 13:26:47 +01:00
David Redondo
b0129c6af8 Do not create new wl_pointer objects when creating pointer gestures
get_pointer is the method belonging to QtWayland::wl_seat creating new
wl_pointer instead of using the already existing one. Since they were
tracked nowhere they where also leaked.

Pick-to: 6.7
Change-Id: I0b9d1914ea6a9e7b379fad905a319bde5fd7f136
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-02-28 13:26:47 +01:00
David Edmundson
d82cbae72d client: Always call mShellSurface->setWindowGeometry regardless of exposure
setWindowGeometry is called to tell shell surfaces when the window tries
to request a new size.

On XdgShell this should not be called before the window is exposed and
we are attaching buffers, this check belongs in XdgShell itself as other
shells may be using this for other purposes.

Pick-to: 6.7
Change-Id: Iae09e71e1b5071fc8c1f3790ec1a260c3d6462ce
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-02-28 09:03:49 +00:00
Kai Uwe Broulik
6b8be3a4a9 QWaylandDataDevice: Explicitly send null for rejected drag offer
qtwaylandscanner sends an empty string for a null QString
but `wl_data_offer.accept` uses null for "not accepted".

Pick-to: 6.7 6.6 6.5
Change-Id: I793d4315c9775a4bdc63085231318db8df829c8a
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-02-22 14:47:12 +00:00
Vlad Zahorodnii
9d0b3cf0d2 Client: Emit wlSurfaceDestroyed after actually destroying wl_surface
At the moment, the QWaylandWindow::wlSurfaceDestroyed signal is emitted
before destroying the wl_surface object. It's the opposite of its name.
Furthermore, the client code in Plasma assumes that the
wlSurfaceDestroyed signal is emitted after the wl_surface is gone, but
it isn't, which is the source of bugs.

Technically, it's an API breaking change. But this ordering issue is
quite annoying to deal in the client code and the QWaylandWindow native
interface api lives in the Private namespace.

[ChangeLog][QtWaylandClient][Important Behavior Changes] The
QWaylandWindow::surfaceDestroyed() signal is emitted after actually
destroying the wl_surface object.

Change-Id: I33e27c06795653d3e20e04a36cb39be8c46797ee
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2024-02-20 20:24:21 +02:00
David Edmundson
00fc00115d client: Support Xdg activation across shell surfaces
XDG activation operates on wl_surfaces, which can be used on all shell
types.

For the case of self activation there is was cast to the xdg
shellintegration on the focused window in order to populate the appId.
Only this part needs to be guarded, not the whole activation.

Pick-to: 6.6
Pick-to: 6.7
Change-Id: If44cc800b7cd98141ba05ba5d1cf0812ef777e7a
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Marco Martin <mart@kde.org>
Reviewed-by: David Redondo <qt@david-redondo.de>
2024-02-20 09:34:53 +00:00
David Edmundson
ef30575d37 client: Fix xdg shell setting only a minimum size hint
An unbound maximum size is sent across the protocol as 0.
We need to make this change before the check that the minimum size is
less than the maximum size.

This fixes having only a minimum size set. This bug is currently masked
by the platform forcefully applying the minimum size.

Pick-to: 6.6
Pick-to: 6.7
Change-Id: Ifca4fa01e4c2ac1c34aeb72db1584e4a868d50bc
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2024-02-20 09:34:46 +00:00
Ahmad Samir
55d8e22017 Mark the whole repo with QT_NO_CONTEXTLESS_CONNECT
By adding it to the default build flags via .cmake.conf.

tst_primaryselectionv1 and tst_datadevicev1: the connection type needs
to be explicitly set to DirectConnection, otherwise the test fails. The
sender and receiver are the same object, so typically would be in the
same thread. The docs say:
"If the receiver lives in the thread that emits the signal,
Qt::DirectConnection is used."

I suspect because the code is running inside CoreCompositor::exec() the
signaling thread is different from the thread the objects live in, so
leaving the type as AutoConnection when sender/receiver are the same
object doesn't lead to the type becoming DirectConnection.

Task-number: QTBUG-116296
Change-Id: Iad49889134a78fa723973ba6efbc237038f35b82
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-02-15 23:33:49 +02:00
Kai Uwe Broulik
a96b58798e QWaylandShmBackingStore: Split buffer preparation into dedicated method
Drop "resize(QRect)" since it is ambiguous with the resize coming from
QPlatformBackingStore.

This allows to ensure a back buffer from multiple places, such as the
upcoming "scroll" support.

Change-Id: I43a5ece2d0e25e64b41335ba59b2b8c4ffcfff74
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-02-15 18:47:45 +01:00
Eskil Abrahamsen Blomfeldt
468e59f478 doc: Add documentation for cmake functions
This adds documentation for the cmake functions used to generate
binding code for protocol extensions. Since the Wayland Client
library did not have any documentation landing page, it also
adds that. This currently only links to the cmake function, but
it can be extended to include other APIs later if we add them.

Pick-to: 6.7
Fixes: QTBUG-114147
Change-Id: I07d8dbe3bc32e5845482fe3e69ec6ba94897331b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-02-13 11:51:12 +01:00
Weng Xuetian
6529e2386f Prefer text-input-v2 over text-input-v3 for now
Qt's current text-input-v3 is converted from text-input-v4, but it's
current state is poor and does not support the same feature like v2.
KWin is the only major party that implements text-input-v2 and many
feature e.g. Plasma-mobile would require v2 feature to provide the
complete support. Until v3 is as good as v2, prefer v2 over v3 should
provide a smoother experience on KWin (for both 5/6) out of box and
won't affect other compositor.

Pick-to: 6.7
Change-Id: Iebfe20cfd61f4a96018c4d41a9c4c706b18c7199
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-02-12 17:14:59 -08:00
Vlad Zahorodnii
88b3411b87 Client: Map Qt::BusyCursor and Qt::WaitCursor to correct shape names
This amends 883cfa228332465b6aa1023f0787927187c828e6.

They are mapped vice versa. The wait cursor displays only an hourglass,
while the busy cursor usually displays an arrow and an hourglass.

Pick-to: 6.7 6.6
Change-Id: I449086f71b00993c061e8a56983c77925246dc37
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-02-06 15:15:22 +02:00
Inho Lee
fc63491355 Remove redundant calls, textInput()
It is used repeatedly. Normally it can be optimized by a compiler
but it might be helpful to see what it is by the name, inputInterface.

Pick-to: 6.7 6.6 6.5
Change-Id: I7f4988674d7249c84b1321e69146dfd92189f142
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-02-06 12:20:57 +01:00
Inho Lee
575448a77a QtTextInputMethod: hide inputPanel when focus leaving
When focusObject is changed,
hide the input panel if input method is not accepted.

Fixes: QTBUG-116600
Pick-to: 6.7 6.6 6.5
Change-Id: I50b5d051eea6f85365d8bc9aeadb46d8d866e362
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-02-06 09:45:27 +01:00
David Redondo
91d9156e7b client: Switch qt-toplevel-drag to xdg-toplevel-drag
While no released compositor implemented qt-toplevel-drag it was a
valuable to step to prove the protocol and the Qt implementation
together with development pre-release versions of KWin. Now that the
protocol is standardized we can switch to that version which is
functionally identical.

Pick-to: 6.6 6.7
Change-Id: I3beefe542cbabeddba4468b5d1fa24fcb05a2e5a
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-02-02 14:30:15 +01:00
David Redondo
9becad7b64 client: Clean up old registry on reconnect
Change-Id: Idcaf1aaef59529f0cb49c552418a434f7d449d7b
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-02-01 15:50:23 +01:00
David Edmundson
d01b735d50 client: Remove unused member variable in TextInputV3
Pick-to: 6.7
Change-Id: I717f16d6ff055b2c0221bfd9cae1bdc9fa7f6513
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-02-01 12:09:28 +00:00
Nicolas Fella
21f03c33b0 Client: Fix Qt::KeypadModifier for key events
Use the right QXkbCommon::modifiers overload that can resolve the
modifier.

f614fdfa5dc522f805c7c061535df6a0dc7409b9 did this for wayland-server,
do the same for the client side

Pick-to: 6.7 6.6 6.5
Change-Id: Iff0c105cb31201241d4972a7772cf997cede3fc3
Reviewed-by: Liang Qi <liang.qi@qt.io>
2024-02-01 01:44:14 +00:00
Tor Arne Vestbø
f616c5beef Remove QWaylandWindow::handleExpose
It was part of xdg-shell-v6 which has since been removed.

Pick-to: 6.6 6.7
Change-Id: Iecf5166b4c2710b209f7dfa0951958dcf82618f7
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-01-30 14:29:07 +00:00
David Redondo
424abe6242 client: Fix deletion of new queued shm buffers during reconnect
When reconnecting the cleanup of existing buffers is delayed in order
to preserve contents and copy them to buffers belonging to the new
connection. Due to the order of events it could happen that
a new buffer was deleted along with the old ones but still being
referenced by a window.
During reconnect all QScreens are removed and new ones added for
the wl_outputs on the new connection during the initial roundtrips.
When the first new QScreen is added  all QWindows move form the placeholder
screen to it. This can cause for example QWidgets to repaint. At this point
the windows are not reinited yet, and the buffer is queued inside the window.
Only afterwards the reconnected signal was emitted which would cause
deletion of all existing buffers including the newly queued ones.
To fix this the signal is moved after the first roundtrip where all globals
are announced and new buffers can be created but no new screens have been
announced yet. The signal is renamed to be more fit for its new location.

Pick-to: 6.7
Pick-to: 6.6
Change-Id: I06be14d235ac342a4b420176aadad3ccf18178fe
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-01-24 10:37:59 +01:00
David Edmundson
91a261b6ed Client: Update size hints when updating the decoration
Size hints are in wayland's "window geometry". This includes the space
for any client side decoration that QtWayland has to add.

We need to update the size hints whenever decoration is created or
destroyed and these margins change.

Fixes: QTBUG-121399
Pick-to: 6.7
Change-Id: Ie8c1898859774e1c8dff93695af15327379ad3b6
Reviewed-by: Liang Qi <liang.qi@qt.io>
2024-01-23 13:21:35 +00:00
David Redondo
3d47f834e0 client: Destroy window manager integration before display
Like the globals window manager integration needs the display to be
alive.

Fixes: QTBUG-121364
Change-Id: I3bf10737f9c1aa6d0b3c34d2268532ea6fc4e957
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-01-23 10:27:40 +01:00
David Redondo
992aa7e561 Mark QWaylandWindow::wlSurface as const
Change-Id: I416fee67bb35a88f55ac6d24d203e607f1ea1f32
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-01-19 15:02:15 +01:00
Inho Lee
e992607d50 TextInputV3: Remove unnecessary enableSurface/disableSurface
zwp_text_input_v3's enter/leave events are doing enable/disable
the surfaces.
enableSurface/disableSurface are called by setFocusObject and
it follows enter/leave.
These redundant routines are removed in TextInputV3

Fixes: QTBUG-120533
Pick-to: 6.7
Change-Id: I080c67629d7cf9a9029414f5a0ea6735cfe4642a
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-01-19 08:51:59 +00:00
David Redondo
c15b219108 Make sure wayland object destructors are called
Always at least call the generated "interface"_destroy method which does
destroy the proxy. For not already wrapped classes a small template
is introduced to pass a function that is called in the destructor.

Fixes: QTBUG-111576
Change-Id: I373463710764958ddea42ef0f7dc010c427b2ce8
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-01-17 09:06:19 +01:00
JiDe Zhang
2d4b077534 Disable client side decorations on Vulkan window
Fixes: QTBUG-120950
Change-Id: I22a78691bd09093432e5d11a72e3abbeadf36cf2
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-01-17 09:38:09 +08:00
Joerg Bornemann
564ca2f307 Add CMake autotest
Task-number: QTBUG-84884
Change-Id: I7be48ae60c1b08dee6e95b042b9c72d809a9f72f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-01-15 20:57:28 +01:00
David Edmundson
7b16ee4ae7 client: Avoid creating decorations in the render thread
createDecoration is called when on the main thread from when window
flags change, implicitly from initWindow, and also every
handleWindowStatesChanged which will be called when we get the first
configure event in an xdg shell.

There is no need to create the decoration in
QWaylandGLContext::makeCurrent. Any current call to makeCurrent before
the platform window is shown will not create a decoration as there's a check for a shell surface. Any call afterwards  will have already been handled by initWindow. Similarly the SHM backend store does not need to handle decorations itself.

Fixes: QTBUG-105703
Pick-to: 6.7
Pick-to: 6.6
Change-Id: I644cece28277131cf7a65eaa234ff08c8431d544
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-01-11 09:03:46 +00:00
Ilya Fedin
b19408d069 client: Fix text-input set_cursor_rectangle coordinates
They should be converted to native ones and shouldn't contain
server-side decorations

Pick-to: 6.7 6.6 6.5
Change-Id: Ia701edc22b68bec2fa46e95d7a812621142dcde0
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-01-10 20:23:55 +04:00
Kai Uwe Broulik
f1df592c96 QWaylandWindow: Update decoration when application palette/font changes
Ensures the decoration can redraw to adjust for the new colors/font.

Pick-to: 6.7 6.6 6.5
Change-Id: Ib46acde1d14baafda49f379f8279c396bc976bdc
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-01-10 17:23:55 +01:00
Kai Uwe Broulik
cc5d649c98 bradient: Use QWaylandWindow actual window title
It may include a suffix containing the application name
and is also what's set on the XDG Toplevel, i.e. what
the rest of the environment (task switcher, etc) sees.

This stores the title in QWaylandWindow and adds a
getter to retrieve it.

Pick-to: 6.7
Change-Id: I84f41c68b16b680cdbb5cf656c7078d1e41767d4
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-01-10 13:45:22 +01:00
Kai Uwe Broulik
b7723f14e6 bradient: Explicitly set Qt::PlainText textFormat
Otherwise a window title containing HTML tags can mess
up the layout.

Pick-to: 6.7 6.6 6.5
Change-Id: I7bd4abd2e0caa92cbb08c0eb46acba737126c913
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-01-09 13:19:12 +01:00
Kai Uwe Broulik
033bb3903a QWaylandScreen: Implement subpixelAntialiasingTypeHint
It isn't really used anywhere yet, since on Unix
QFontconfigDatabase doesn't use the screen's information.

Pick-to: 6.7 6.6 6.5
Change-Id: Icab81b2bf8df1a23223a74f2d4aee94601e0bea3
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-01-06 13:13:15 +00:00
Kai Uwe Broulik
4e3fc377ad bradient: Don't cache decoration colors
Reading them from QPalette on the fly is pretty negligible.
Easily ensures that the palette renders with correct colors
when the color scheme changes.

Pick-to: 6.7 6.6 6.5
Change-Id: I469fa2f32889a7841a3d4c4c8d11e1abf50ae66f
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-01-06 14:13:15 +01:00
Kai Uwe Broulik
c928425852 QWaylandShmBackingStore: Preserve buffer contents between frames
Doing a memcpy is quite expensive, particularly when only a small
region of the buffer (such as a blinking cursor) actually changed.

Instead, keep track of the damaged region and paint only what
actually changed into the buffer to be used.

Change-Id: Ibd81bbfe20d0750ddb751f41722a316387225ba6
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-01-06 14:13:15 +01:00
Kai Uwe Broulik
68ddc184fd QWaylandWindow: Reset input region on window reset
Amends 349cb9eb and fixes the input region (and thus
Qt::WindowTransparentForInput) not working on subsequent shows.

Pick-to: 6.7 6.6
Change-Id: Ie160aa0b2c13e6858b31ad98866a8689dfbad149
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-01-06 13:23:09 +01:00
Rob Hall
de1deab059 client: Fix window margin calculation
Don't subtract the size of the window frame margin from the content
area. Fixes an issue where an area of the window is unclickable when
client-side decorations are in use.

Fixes: QTBUG-120392
Pick-to: 6.7 6.6 6.5
Change-Id: I6a89b2d463be084233ea3448cacfbbd09d66b96e
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Kai Uwe Broulik <kde@privat.broulik.de>
2024-01-06 11:39:01 +00:00
Kai Uwe Broulik
5829719cc0 bradient: Use "Size" instead of "Split" cursors for resizing
SizeVerCursor: "A cursor used for elements that are used to
vertically resize top-level windows."

SizeHorCursor: "A cursor used for elements that are used to
horizontally resize top-level windows."

Pick-to: 6.7 6.6 6.5
Change-Id: Ib780269120aa373cd9fcf84826683cccd1dc4f4d
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2024-01-06 11:17:51 +01:00
David Edmundson
84aed4465e client: Do not constrain clients to size hints
The behavior of constraining requests from the system to the client
requested size does not appear to be in other backends.

It was added to QWayland before xdg-shell/qt-shell existed with hints
that can be supplied to the window manager.

This is important as the specification states that maximized windows
must follow the geometry requested and there is some movement towards
this applying for all tiled states.

Task-number: QTBUG-120035
Pick-to: 6.7
Change-Id: I7c203db18e34a8f81a39c504591f6b54df076da8
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2023-12-28 09:52:53 +00:00
David Edmundson
89dff9764a client: Clean up text input proxy object in textinputv3
This not only cleans up a tiny amount of memory, but also fixes a
potential crash if a wayland event were to arrive on the object after
the Qt level wrapper is destroyed.

Pick-to: 6.7
Change-Id: Id1c768b1f846925579220784e4312cede4efd095
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: David Redondo <qt@david-redondo.de>
2023-12-21 12:17:51 +01:00
David Edmundson
d13a291828 client: Clean up text input proxy object in textinputv2
This not only cleans up a tiny amount of memory, but also fixes a
potential crash if a wayland event were to arrive on the object after
the Qt level wrapper is destroyed.

Pick-to: 6.5 6.6 6.7
Change-Id: I6fafdd848d61da893304c4467a57b52d3771c508
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-12-21 12:17:49 +01:00
Kai Uwe Broulik
8013130a7b QWaylandMimeData: Skip "DELETE" format
This is presumably a left-over from XDND:
https://freedesktop.org/wiki/Specifications/XDND/
> In general, XdndActionMove is implemented by first requesting the data
> and then the special target DELETE defined in the X Selection
> protocol. [...] DELETE should be sent before XdndFinished.

Firefox sends this during dragging of files but trying to fetch it
will fail, leading to a timeout and potential freeze.

Pick-to: 6.7 6.6 6.5
Change-Id: Ic30f5cb23587c63d54859c5eaebb3a054a25ac69
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-12-20 16:09:22 +00:00
Kai Uwe Broulik
c7c22eaacd Don't use Qt keywords in headers
Unfortunately for many Wayland features applications need to access
Qt private headers which will fail if the project is built with
QT_NO_KEYWORDS.

Ideally, the examples and tests were ported, too, and QT_NO_KEYWORDS
enabled in .cmakec.conf.

Pick-to: 6.7
Change-Id: I9f988d304bcc8dba4dd84761c41ba3da2473515d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-12-18 14:34:19 +00:00
Nicolas Fella
d3a6c1e9ea Remove inactionable warnings suggesting qt-text-input-method-unstable-v1
These warnings can appear several times during the program execution,
spamming the log.

They are also inactionable for desktop use cases, since
qt-text-input-method-unstable-v1 is not a protocol implemented by any
desktop compositor.

Fixes: QTBUG-120171
Pick-to: 6.7
Change-Id: Icd5316000b43e4b16e1eaff9efcc0c363458b9af
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-12-18 12:23:08 +00:00
Kai Uwe Broulik
2136cedfff QWaylandCursor: Set appropriate shape for drag cursors
Even if the compositor is free to do whatever during a drag,
the client can still set a proper cursor. The codepath
without cursor-shape also doesn't special case them.

Pick-to: 6.7 6.6
Change-Id: Ib6b9864d8024ff2919471d6f2d12f9ba8e2e512d
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2023-12-14 14:48:21 +01:00
David Edmundson
8367c68db9 Support TextInput V3 over v4-wip
Support for v4-wip was not added into any desktop linux compositors, nor
was it ever enabled into the default Qt client builds for clients or
compositor.

TextInputV3 has become the most widely deployed. Whilst changes are
needed, they do not need to be breaking changes. A second iteration of
V3 can add the features we need. This is now in motion upstream.

For cases where QtWaylandCompositor is used, the custom Qt text input
method is preferred to work with the Qt virtual keyboard.

Pick-to: 6.7
Change-Id: I01e2686c67846804c0069f1495952b530547f91c
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-12-13 07:29:51 +00:00
David Edmundson
a55d86be87 tests: Only track one data offer during a drag
A drag consists of one data source which in turn will be represented by
one data device sent to each client.

We don't need to manage a list

Change-Id: Icd2aba3ced1d8254d15400b0b687888b0872cc35
Pick-to: 6.7
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-12-11 12:10:21 +00:00
David Edmundson
96b9b72016 client: If the window minimized state is requested do not forward other states
In QWindowPrivate::effectiveState if the minimize flag is requested all
other states are cleared. This makes sense for the internal
representation, but we do not want to send the unset maximised state
across the wire.

Fixes: QTBUG-119136
Pick-to: 6.7 6.6
Change-Id: I9b758c67ce11420b421a295fe3e65b68bf546027
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-12-11 10:41:03 +00:00
David Edmundson
d338d7c9fb Handle subsurfaces with async configure
With XDG Shell we cannot map a buffer until we get a configure event.
To handle this the normal expose events is blocked then sent explicitly
when we get this request.

This works, but we also need to notify that subsurfaces are now exposed
with the parent.

Pick-to: 6.7 6.6 6.5
Fixes: QTBUG-119882
Fixes: QTBUG-119883
Change-Id: I0ae69c8da702037e7575cfc0939d3e783b50f323
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-12-11 09:53:30 +01:00
David Redondo
ea5d6d8748 Error out early when base was build without our native interfaces
Instead of letting people run into compile errors, bail out and explain
what's wrong.

Change-Id: I2f2067ee07d95238e287e39ce78e73eddbca836c
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-12-09 08:39:10 +01:00
David Redondo
ca722d909b Adapt to QWaylandScreen being public
Change-Id: I8c260ab7177011fd22db856615c8f72d6a8fabeb
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-12-09 08:39:07 +01:00
Liang Qi
baa2104a7a client: implement QWaylandCursor::size()
See also 78272c667f008f6afcf5f84e0add525b56c3a558 in qtbase.

Fixes: QTBUG-118612
Pick-to: 6.6 6.5
Change-Id: I1cfd0c287b133c21a0ccdc5f283d9997f06fb2ed
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-12-08 12:59:07 +01:00
Kai Uwe Broulik
1f060ee077 QWaylandMimeData: Check text/x-moz-urls for UTF-16
And fall back to UTF-8 if it's not.

When dragging a picture out of Chrome, it sends a simple URL as
UTF-8 under text/x-moz-urls. QXcbMime has this fall-back, too
but I originally didn't consider it necessary.

Pick-to: 6.6 6.5
Change-Id: I52378cfc354de342623e5dd3f7e1d028951e8dab
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-12-04 21:30:21 +01:00
Ilya Fedin
d4220cf486 Client: Fix enter event cursor position with xdg-popup and QHighDpiScaling
QWindowSystemInterface::handleEnterEvent accepts device-dependent
position while QCursor::pos provides device-independent position.

Use QWaylandCursor::pos instead.

Pick-to: 6.6 6.5 6.2 5.15
Change-Id: I70d2997610f7a34c6763bd4f10f20a65c3debdbe
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-12-04 15:09:33 +04:00
Edward Welbourne
d3fd429f82 Remove redundant static uint32_t QWaylandDisplay::currentTimeMillisec()
Fortunately it was unused. Its 32-bit unsigned return type, measuring
time in milliseconds, wraps around every 50 days. If Qt Wayland ever
does need to know the current time in milliseconds, I can recommend
QDateTime::currentMSecsSinceEpoch().

Change-Id: I03e70e3c7060b1e8fb82fc2e151bb187b6598b96
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-11-27 14:13:17 +01:00
Edward Welbourne
9dd6286994 CMake: replace PUBLIC_LIBRARIES with plain LIBRARIES
This silences a warning from qt_internal_add_test().

Change-Id: Ie1afaa5789a488ad3190061c782a5bfb9f3d103c
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-11-27 14:12:16 +01:00
David Edmundson
669556852d client: Use correct offset handling features for wl_surface version 5
In version 5 wl_surface_offset was introduced and requires that
is used instead of passing the additional arguments to wl_surface_attach

Fixes: QTBUG-119177
Change-Id: I04d7a6f89d17991a8fc536f5cca9d5d8d5418940
Reviewed-by: Inho Lee <inho.lee@qt.io>
2023-11-26 08:32:42 +00:00
Tor Arne Vestbø
856b4352e2 Follow up handleWindowActivated -> handleFocusWindowChanged rename
Change-Id: I75eeae6dfa4af8a17dffaef74f15fc87a58bcf61
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2023-11-24 18:36:01 +01:00
Ilya Fedin
16ba2fad85 Client: Switch QWaylandXdgSurface::setSizeHints to the window content geometry
According to the protocol documentation, set_{min,max}_size work
in window content geometry while it currently works in QWindow geometry.

Practically this excludes shadows and includes the non-shadow part
of client-side decoration.

Pick-to: 6.6 6.5
Change-Id: Ib702e4c9036a07645ba254ac3cc0e5704a949fe4
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-11-23 20:38:30 +04:00
Vlad Zahorodnii
061340e9c6 Client: Move topmost grabbing popup tracking to QWaylandWindow
If the effective transient parent is different from
QWaylandWindow::transientParent(), then the popups may be closed in
wrong order and producing an xdg-shell protocol error.

This change lifts topmost popup tracking from the xdg-shell plugin to
QWaylandWindow so it can guess the correct transient parent and the
xdg-shell plugin doesn't have to pick a different parent behind our
back.

Fixes: QTBUG-119110
Pick-to: 6.6
Change-Id: I7c5f780b7bd4c3362aa7b22762ff336ae908ff70
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-11-17 07:52:33 +00:00
Weng Xuetian
fa1658f8bf client: Always clear queued buffer busy flag when resetting the window
In 816f41c00d22ca157eed273183f0711d9f1b41c7, the queued buffer is always
set busy, but it may not be reset correctly if the queued buffer is not
ever attached due to hiding the surface when window visibility is
being updated at a very fast speed.

Fixes: QTBUG-118650
Task-number: QTBUG-118650
Pick-to: 6.6
Change-Id: Id0bdd3caa69c821bb84927f01b4839f46eee8a10
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: David Redondo <qt@david-redondo.de>
2023-11-13 09:57:47 -08:00
Feifei Zhan
792f1915fc Add list is empty judgment,optimize to use constant
the last() method of the mPendingTouchPoints list is judged to be empty before it is called, and the last() is optimised to constLast() according to the logic below.

Change-Id: I8ec082a22c223d06dbe848bc70622710b6acfa50
Reviewed-by: Feifei Zhan <noone@onqt.com>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-11-03 02:57:19 +00:00
JiDe Zhang
e73979a94f QWaylandSurface: client support wl_surface version 6
Add QWaylandWindow::updateScale() function to update the window's scale
from QWaylandFractionalScale or QWaylandSurface::preferredBufferScale or
QWaylandScreen::scale or QWaylandSurface::preferredBufferScale.

Add QWaylandWindow::updateBufferTransform() function to update the
window's buffer transform from QScreen::primaryOrientation or
QWaylandSurface::preferredBufferTransform.

Change-Id: I2742701e92c7403a89df97b7fa06b5b0de6917a7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-11-02 19:03:07 +08:00
Ahmad Samir
7666f93b3b QWaylandMimeData: adapt to qt_safe_poll changes from qtbase
It's private API in qtbase and has been changed recently.

Change-Id: I763918a035bce67c06a6120e9d7dfb542ca023b8
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-28 18:35:28 +02:00
David Edmundson
d76ce4732e Client: Always populate mimedata in drags
It's possible for clients to perform a drag and drop operation within
their own client without any mimeData. A user can directly access the
original drag.

On wayland without any mimedata it's impossible for a client to accept a
drag as the mechansim involved is to either select a given mimedata
entry or an empty string. Within Qt we always accept the first format if
we accept a drag.

When dragging within our own window we also start a wayland drag so will
receive a cancel event from the compositor if the compositor doesn't
believe the client has accepted the drag.

This patch provides a dummy mimedata entry so that something can be
accepted.

Fixes: QTBUG-112161
Pick-to: 6.6 6.5 6.2 5.15
Change-Id: I6309d82e20545e10ebdb9dafde7e13a5e3be5ff2
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-10-23 11:00:10 +00:00
Lu YaNing
c16f6d4051 client: Provide seatname for multi-seat
In a multi-seat configuration the seat name can be used by clients
to help identify which physical devices the seat represents.

Change-Id: Id704ad289fe861c2170380f1575d298e8db03964
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-10-18 08:27:51 +08:00
Marc Mutz
e258b7345c Include what you need: <QPointer>
All these TUs relied on transitive includes of qpointer.h, maybe to a
large extent via qevent.h, though, given that qevent.h is more or less
the only public QtBase header that includes qpointer.h, something else
seems to be at play here.

Said qevent.h actually needs QPointer in-name-only, so a forward
declaration would suffice. Prepare for qevent.h dropping the include.

The algorithm I used was:

If the TU mentions 'passiveGrabbers', the name of the QEvent function
that returns QPointers, and the TU doesn't have qpointer.h included
explicitly, include it. That may produce False Positives, but better
safe than sorry. Otherwise, in src/, add an include to all source and
header files which mention QPointer. Exception: if foo.h of a foo.cpp
already includes it, don't include again.

Task-number: QTBUG-117670
Change-Id: I8eb00fbd2df16300b0cbfc4157612a45c72ac12c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-10-13 13:31:45 +02:00
JiDe Zhang
ad3bc01d35 QWaylandWindow: add QWaylandWindow::setScale
The logic for update window's scale is scattered in multiple places,
we should unify their behavior.

Change-Id: Ic8ba20fdbc44942aed9b4bd0b0b12dad7bee1719
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-10-07 18:06:23 +08:00
David Edmundson
646bca0c74 client: Implement QWheelEvent::inverted
"Natural scrolling" is a setting that makes trackpads act in the
inverse; moving up moves content down to mimic behavior of
touchscreens.

However not all scroll events are used for scrolling, so it can be
useful to know the real direction. This was exposed in QWheelEvent it
just needs plumbing.

Change-Id: I050b8b3e55796beff33badb7c073c0b93589294e
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2023-09-29 11:39:19 +01:00
David Edmundson
0b82d95632 client: support Xdg Shell not_shown state
This state is to indicate that a toplevel is not visible, either
minimised on another desktop. This maps to QWindow::isExposed.

In addition to XdgShell changes. QWaylandWindow is adjusted to check
exposure state before sendingExposureEvents.

Subsurfaces are un-exposed and re-exposed when the toplevel changes.

Change-Id: I76932c2c58681f832c1c2efde3cfde1c32cd3e05
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-09-25 12:34:22 +01:00
Paul Olav Tvete
1110b2c3e4 Fix use-after-free error in autotest
zwp_primary_selection_device_v1::destroy_func() uses the object after
calling zwp_primary_selection_device_v1_destroy_resource(). This means
that we cannot do "delete this" at that point. Instead delete all the
devices in the destructor of PrimarySelectionDeviceManagerV1, which
conveniently already has a list of selection devices.

Fixes: QTBUG-117068
Change-Id: I7012f801ef11283d5b66cefbf5481e9f1394f1b8
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-09-19 11:39:35 +02:00
Paul Olav Tvete
fa89154807 Fix use-after-free with animated cursors
In WlCallback::callback_done(), m_fn() can cause the callback object to
be deleted, so it should not be referenced after that. Since
m_autoDelete is never set to true, the rest of callback_done()
is dead code and can be removed.

Fixes: QTBUG-117067
Pick-to: 6.6 6.5
Change-Id: I0b1a1fcb8204cba789272f3861be4c2e2d0789b4
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2023-09-19 11:39:33 +02:00
Vlad Zahorodnii
379235e6ac tests: Fix tst_xdgshell::minMaxSize()
Amends 61f72fc6b614de71703a056ba557463126fdbb0b.

The new size hints will be committed when the surface is committed.

Change-Id: I94e944fee7dac63d5e9ac86fb348b5d24d54abfc
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-09-15 10:23:10 +03:00
Vlad Zahorodnii
486dcfc010 Client: Fix QT_WAYLAND_RESIZE_AFTER_SWAP
mResizeLock can be locked several times by the same thread in the
following scenario

    QWaylandWindow::setGeometry() at qwaylandwindow.cpp:429:43
    QWaylandEglWindow::setGeometry() at qwaylandeglwindow.cpp:58:32
    QWaylandWindow::resizeFromApplyConfigure() at qwaylandwindow.cpp:517:16
    QWaylandXdgSurface::Toplevel::applyConfigure() at qwaylandxdgshell.cpp:91:57
    QWaylandXdgSurface::applyConfigure() at qwaylandxdgshell.cpp:381:35
    QWaylandWindow::doApplyConfigure() at qwaylandwindow.cpp:628:38
    QWaylandWindow::applyConfigure() at qwaylandwindow.cpp:671:25

Since mResizeLock is not a recursive mutex, the main thread just blocks
in QWaylandWindow::setGeometry(). To prevent that, this patch changes
the type of mResizeLock from QMutex to QRecursiveMutex.

Change-Id: I362f4909bfdfc2d91b7cf902f27d35c742ac5091
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-09-12 08:41:27 +03:00
Vlad Zahorodnii
b59d243ce2 Client: Avoid locking resizing in QWaylandShmBackingStore
QWaylandWindow::setCanResize(false) will block applying configure
events. QWaylandWindow::setCanResize(true) will unblock configure events
and potentially apply a scheduled configure event if there's one.

QWaylandWindow::setCanResize(true) has to be called **after** committing
the surface to ensure that the xdg window geometry matches the buffer.
We don't want the xdg window geometry change when painting.

Unfortunately, setCanResize(true) can be called before the surface is
committed when using a RasterSurface, for example

 - QWaylandShmBackingStore::beginPaint(): calls setCanResize(false)
 - QWaylandShmBackingStore::endPaint(): calls setCanResize(true)
 - QWaylandWindow::setCanResize(true): applies pending configure event
 - QWaylandShmBackingStore::flush(): commits the surface, but the xdg
   window geometry is wrong now

As is, beginPaint() and endPaint() are not entirely correct functions
where configure events can be blocked. We need functions that wrap both
painting and flushing, which are not feasible with the current backing
store design.

On the other hand, it's worth noting that blocking configure events in
the backing store is not necessary because painting happens on the main
thread unlike OpenGL or Vulkan code paths.

Given the lack of synchronization points and the fact that rendering
happens on the main thread, this change removes blocking configure
events in QWaylandShmBackingStore. It fixes dolphin and various other
applications that use QtWidgets jumping while being interactively
resized.

Change-Id: I156e4fd5e04a6bba7e8d48171510d5ab0ec89713
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-09-11 18:48:31 +03:00
David Edmundson
3783016b72 client: Port QWaylandInputDevice to support QT_NO_CONTEXTLESS_CONNECT
There were two existing usages of the 3-arg connect, but the timer is
always scoped to be shorter than the receiver so it was previously safe.

Change-Id: I0bb5a38fed997cbb68e49defc51972894f5239ee
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-09-09 13:28:04 +01:00
Liang Qi
ea30d389f8 client: make drag and drop in same control works again
This amends 8a48175f26038541dfc1186d938dc46edb6048ab.

examples/widgets/draganddrop/draggabletext in qtbase now is fine.

Pick-to: 6.6
Fixes: QTBUG-116344
Change-Id: Ie930586fa7c6468c0e859786d968ad2343057e4d
Reviewed-by: David Redondo <qt@david-redondo.de>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-09-08 08:36:20 +02:00
Liang Qi
40720551fd Revert "Client: Send release button event on pointer leave"
This reverts commit 2aa8de5524cc769daf0b6ec6d29363311b8a441e.

It makes tests/manual/examples/widgets/draganddrop/puzzle not work,
which does drag and drop in same app.

Pick-to: 6.6 6.5 6.2 5.15
Fixes: QTBUG-115757
Task-number: QTBUG-97037
Change-Id: I738769fde96f7da91f5bc4dc7a70ed49596dcd61
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-09-06 11:16:35 +02:00
David Edmundson
46d98302f5 client: Add path to manipulate popup positioning via hidden properties API
Whilst long-term we want public API, we don't have anything available.

This patch provides a non-official override using properties without us
committing to any API promises moving forward.

Pick-to: 6.6
Change-Id: I46afbe9be7005d35305155643a1d158cf5bd509a
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-09-04 14:03:18 +01:00
David Edmundson
37afa0cbaa client: Simplify toplevel exposure tracking
m_exposeRegion was originally there to track the expose updates
requested from the client in situations where the shell integration is
filtering those events, i.e when we're waiting for the first configure
event.

The fix at e6d55239c454d454978edb7d8b17f6c993e7ba07 explicitly sends an
expose event to the whole window when we get the actual first configure
event, at which point caching the expose region at the time of the
handleExpose check is unnecessary.

Motivation for cleanup is a pending change to support
xdg_toplevel.suspended where we need to unexpose at a shell level.

Change-Id: I56c3bab91453956046c1d7f92a4395c951c48fb3
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-08-31 05:59:39 +00:00
David Edmundson
be38fbd3f4 client: Drop unused member variables
Change-Id: Id7cca9d5cb620dadb356e9cfcc68ca1203a0db98
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: David Redondo <qt@david-redondo.de>
2023-08-31 06:59:13 +01:00
Vlad Zahorodnii
61f72fc6b6 Client: Remove some surface commits
The buffer transform, input and opaque regions are double buffered
state. They will be applied on the next surface commit.

But the issue with them is that the relevant code makes surface commits
too. It's undesired as it can lead to qtwayland committing partial
state, for example it can break xdg surface window geometry.

This change removes hidden surface commits. The relevant properties will
be applied on the next frame.

Change-Id: I1c40c9a5430fb6b91d7643b20d628f8a9a9d501a
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-08-29 11:10:24 +03:00
Vlad Zahorodnii
b3c663d0f8 Client: Commit the initial surface state explicitly
QWaylandWindow lacks an explicit step to finish initializing the shell
surface by committing the surface. So far it used to work because of
hidden surface commits in
QWaylandWindow::handleContentOrientationChange(),
QWaylandWindow::setMask() and so on.

This change adds an explicit step to commit the initial surface state to
make the shell surface initialization robust.

Change-Id: Ibc38a4e0dbea689a727451c25a61af0270c7e548
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-08-28 14:11:59 +03:00
Vlad Zahorodnii
9f23e0756b Client: Fix coding style in QWaylandWindow::setMask()
The relevant code can be reformatted as follows

    if (isOpaque()) {
        if (mMask.isEmpty())
            setOpaqueArea(QRect(QPoint(0, 0), geometry().size()));
    } else {
        setOpaqueArea(mMask);
    }

which doesn't fully make sense.

Pick-to: 6.5 6.6
Change-Id: If78270273bff4eec9ad58666b6f31c5f10139caf
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-08-28 11:47:09 +03:00
Kai Uwe Broulik
3e65306ec3 QWaylandInputDevice: Don't create cursor surface just for hiding it
Just call set_cursor(null) directly.

Pick-to: 6.6
Change-Id: Id10b7d41775a41c805962d77fba2d7d2b19956d0
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-08-28 09:31:16 +02:00
Kai Uwe Broulik
5ff2599d51 QWaylandInputDevice: Reset cursor surface state when using shape cursor
CursorSurface::update only calls set_cursor if the hotspot or serial has
changed. Reset its state when using a shape cursor to ensure switching
back to a cursor surface (e.g. when switching from a shape to a bitmap
cursor) works as expected.

Pick-to: 6.6
Change-Id: Ia04dff468c251030a75e9f1eac642ed764879125
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-08-25 08:50:07 +02:00
Kai Uwe Broulik
f7e04622f4 client: Wait for the compositor to send a fractional scale
Don't assume it's 1.0 initially.

Pick-to: 6.6 6.5
Change-Id: I443cb40a0f3421e6d7bdeba550cc8fc94c646319
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-08-25 08:48:50 +02:00
David Edmundson
5e47af01b4 tests: Send frame callbacks by default
Currently we have special handling for wl-shell to automatically
respond to frame callbacks in the mock compositor.

With the framecallback timer this results in flaky tests as the window
becomes unexposed.

Pick-to: 6.6
Change-Id: I2add44d59ba26368c031a381849891f49764bfb5
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-08-22 14:17:10 +00:00
Vlad Zahorodnii
4a7e459dc7 Client: Fix keyboard focus when closing a popup
325a2338976c3cca6278436af03e7bd4e4378d7c changed the order in which the
shell surface and the QWaylandWindow::wlSurfaceDestroyed signal are
ordered.

Unfortunately, it broke popups with some compositors. When the
wlSurfaceDestroyed signal is emitted, QWaylandInputDevice::Keyboard is
going to reset its focused surface and call
QWaylandDisplay::handleKeyboardFocusChanged().

QWaylandDisplay::handleKeyboardFocusChanged() is going to call
QWaylandDisplay::handleWindowDeactivated(), it will make an async
roundtrip to determine the current focused window. This is to batch
leave and enter events.

Since the wlSurfaceDestroyed signal is emitted before destroying the
shell surface and the wl_surface, the compositor has no reason to change
keyboard focus, so qtwayland will think that the app lost focus for good
and close all popups.

This change restores the old behavior by making
QWaylandInputDevice::Keyboard connect to QWaylandSurface::destroyed
signal, which is emitted after the window's wl_surface is gone. It also
makes QWaylandInputDevice::Keyboard consistent with
QWaylandInputDevice::Pointer.

Pick-to: 6.5 6.6
Fixes: QTBUG-116051
Change-Id: If866f94a0cec1659c27ffeb2d263a2480ca8fdf1
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-08-17 11:48:52 +03:00
Kai Uwe Broulik
5ca00097c8 QWaylandDrag: Call into super class QBasicDrag::drop
It's where, among other things, the override mouse cursor is reset.

Otherwise the cursor stays a dragging hand indefinitely.

Pick-to: 6.6
Change-Id: I9e7a44e09d5806cd64e66ba7a7c96f2d24ec97fc
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-08-16 13:32:46 +02:00
Kai Uwe Broulik
9c1cd44144 client: Convert text/x-moz-urls to text/uri-list
Similar to how it's done in the XCB QPA.

This format is used by both Firefox and Chrome
for exchanging URLs.

Change-Id: Icd4406ff6297ea2800f4e1389ffc2878ee1ccb65
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-08-07 19:03:34 +02:00
Kai Uwe Broulik
349cb9eb7d QWaylandWindow: Support Qt::WindowTransparentForInput
This is achieved by setting an explicitly empty input
region (as opposed to a "null" region) on the window.

Unlike set_opaque_region, where a null region means an
empty region, in set_input_region it means an
infinite region.

Pick-to: 6.6
Change-Id: I018d53196bc816b5eaea7dd3b24626a9738c9f47
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-08-07 19:03:10 +02:00
Marc Mutz
75249a77b6 DefaultCompositor: use explcit lambda captures
C++20 deprecates the capture of *this in [=], and using [&] in a
connect() statement is a smell ("are we capturing local variables?"),
so just be explicit about what variables we capture (it's mostly
[this], anyway).

Amends f6dd4ab120f2f3822a19233233e791d4449e134a.

Pick-to: 6.6 6.5 6.2 5.15
Change-Id: Ia594ffd5c0b9e82c54aa67c74b0d59684aa92840
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-08-07 11:46:03 +02:00
Vlad Zahorodnii
f195fed91a Client: Fix buffer damage
If the specified damage rectangle has fractional coordinates in the buffer
local coordinate space, the buffer damage needs to be expanded, i.e.

- bufferRect.left = floor(rect.left * scale)
- bufferRect.right = ceil(rect.right * scale) = ceil((rect.x + rect.width) * scale)

Flooring the coordinates and ceiling the size is not enough. It can
produce incorrect results.

For example, consider that a rectangle with logical coordinates of
QRect(0, 23, 179, 46) has been damaged in a window with scale 1.5. When
flooring the coordinates and ceiling the size, the following buffer
damage rect will be produced: QRect(0, 34, 269, 69). Its height is off by
1, the expected height is 70 (ceil((23 + 46) * 1.5) - floor(23 * 1.5) =
ceil(103.5) - floor(34.5) = 104 - 34 = 70).

Pick-to: 5.15 6.5 6.6
Change-Id: I927e75a2224bb58b4634125011d1305dbdfbb3aa
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-08-03 12:59:08 +03:00
David Redondo
816f41c00d client: Set queued buffer busy
From the outside it doesn't matter if the buffer was really committed
or queued, it still in use. If it is not marked  busy QWaylandShmBackingStore
will delete when it is resized which can happen when the surface changes
screens or receives a new fractional scale resulting in a use after free
producing a crash or protocol error.

Pick-to: 6.6
Change-Id: I8abc4edbd8990af5114aa0b36c8ecedb37a4f0f6
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Kai Uwe Broulik <kde@privat.broulik.de>
2023-08-03 10:37:58 +02:00
Marc Mutz
369a5296a9 QWaylandWindow: adapt to QPlatformWindow::setBackingStore() addition
When qtbase/a4ca9e80658bca7dad1529f03c1b59173a6ecf62 added a virtual
QPlatformWindow::setBackingStore(), this was hidden by the existing
QWaylandWindow::setBackingStore(), causing a FTBFS on
-developer-builds.

Fix by using the newly-added detection macro to turn the existing
function into an overrider.

Pick-to: 6.6
Fixes: QTBUG-115691
Task-number: QTBUG-97482
Change-Id: If1d8c4443fe50030addb23331a50b7b9e1274626
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-08-02 17:49:38 +02:00
Marc Mutz
d8f0396961 Fix C++20 deprecated capture of *this in [=]
The exec() function is synchronous, so we can just replace [=] with
[&].

Pick-to: 6.6 6.5 6.2 5.15
Change-Id: I1b672b0ef456977fa0b898dff9c88f48765a3e41
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-08-02 10:32:08 +02:00
David Redondo
63e2f90266 client: Make sure screens stay virtual siblings during reconnect
The virtual siblings of QWaylandScreen are constructed from the
list of screens in QWaylandDisplay. It is important that when a window
changes screens due to handleScreenRemoved that the screens are siblings
otherwise the platformwindow is destroyed and window becomes hidden.

Pick-to: 6.6
Change-Id: I7ceeee4e18fbdfa936fe987441d35b8a5cb1eefd
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-07-28 19:28:47 +02:00
Alexey Edelev
9c3896c140 Ensure that WaylandGlobalPrivate_sync_headers is running
Work around QTBUG-115101.

Task-number: QTBUG-115101
Pick-to: 6.6
Change-Id: Icb195e0547b8faafea73d204650a1ee7bede4a7f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-07-07 09:21:53 +02:00
Alexey Edelev
27681c7906 Do not generate the deprecated 'QtWaylandClient/qwaylandclientexport.h'
Task-number: QTBUG-115029
Change-Id: Ief42a0eeb6360df7d12f367f023579106cc9db34
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-07-06 12:49:29 +02:00
Liang Qi
7d12b0e830 client: no need to update decoration when shutting down
Fixes: QTBUG-114995
Pick-to: 6.6 6.5 6.2
Change-Id: If7eaefc8cc0778246f13604809740426bcffa9f8
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-06-30 12:55:33 +00:00
Inho Lee
44a9d21c65 client: Fix variable names for QWaylandDisplay::GlobalHolder
After 5abc59a, wayland-text-input-v4-wip was broken.
In addition, mTextInputManagerv2 will be changed to
textInputManagerv2 as other protocols.

Change-Id: I5476a1bba579ef1d915959b3c3881cf80a56587d
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-06-30 10:14:10 +00:00
Liang Qi
f3919e9448 client: check nullptr before usage
in QWaylandInputContext::textInput() and QWaylandInputMethodContext::textInputMethod()

Fixes: QTBUG-114671
Pick-to: 6.6 6.5 6.2
Change-Id: I10e55f6f817a4b4d78a0262f87580d2fa2743f7b
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-06-28 14:04:40 +02:00
Liang Qi
be0dfe986e client: Use nullptr instead of 0 in QWaylandDisplay
Pick-to: 6.6 6.5 6.2
Change-Id: I7c1f3a24e55d1825fd6c941cd55b51cf195836da
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-06-28 14:04:39 +02:00
David Redondo
5abc59af2a client: Move wayland globals into a holding struct
This way all globals get automatically reset by reassigning a default
constructed value to the holder. This way a newly added global will not
be missed in the future.

Change-Id: Id3a62e30427cec9980ea076366e30b419ce1c2c6
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-06-13 23:49:10 +02:00
David Edmundson
9a8033ba5a client: Fix crash on dnd updates after client facing drag ends
A platform drag and a application-facing drag have two different
lifespans.

The platform drag lasts until all mimedata is transferred and the client
receiving the drops marks it as finished.

The application facing QDrag lasts until the client deletes it. We can
get a crash if we get updates during this time.

The drop event is guarded, but not the action negotiation.

Pick-to: 6.6
Change-Id: Ib9c047f04d65883105d4cd3f169637d0e038a63f
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-06-08 14:30:19 +00:00
David Edmundson
ad0e538664 client: initialize key repeat information
We can end up checking mRepeatKey.code before getting a key press is
recorded when the values are uninitialized.

This can happen if we get a key up for a previously held key or if key
repeats are disabled.

It's relatively harmless as it just stops a timer, but it can show up in
valgrind logs.

Change-Id: Ib7fe58b1976e9c89550c5a6252a34d66f83e2481
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-06-08 08:10:58 +00:00
David Redondo
7a93643df7 Add missing globals to reset on reconnect
These were recently added and not reset
on reconnect.

Pick-to: 6.6
Change-Id: I3b030154447662c9b9fde9b44cbea994333d464c
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-06-06 13:19:33 +02:00
Eskil Abrahamsen Blomfeldt
a7aced5707 Fix compilation with -feature-wayland_text_input_v4_wip
Someone changed something so this is no longer implicitly
included, so we need to add it explicitly.

Pick-to: 6.5 6.6
Change-Id: Ie4b5c5194e32d4b192444c931da56b7ec9009cd2
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-06-06 10:43:04 +02:00
David Edmundson
388e6659a7 client: Guard against client destruction in gestures
Client code can delete a window at any point. Any gesture events,
including a "begin" event can be already in flight before the compositor
is aware of the window destruction.

It's up to the client code to handle either the focus not being
initially found or the QPointer resetting and no-op.

Task-number: QTBUG-113145
Pick-to: 6.6 6.5
Change-Id: Ie2c01799bd38c6f295159876a1bcd018abe60188
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-06-06 07:45:05 +00:00
Ilya Fedin
2aa8de5524 Client: Send release button event on pointer leave
Fixes: QTBUG-97037
Pick-to: 6.6 6.5 6.2 5.15
Change-Id: I151239b276ab5aefe166f5615baf43dab428ce0c
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-06-05 18:00:15 +04:00
David Redondo
8a48175f26 client: Implement qt-toplevel-drag-v1
This protocol for tabs toolbars and dock widgets to be dragged in and
out of a main window using an extended version of the drag and drop
protocol. Application code in QtBase use a special internal mimedata to
specify a window that should be associated with a drag.

This is 1:1 match with the pending upstream proposal xdg-toplevel-drag,
and can be switched when that lands.

Change-Id: Idf0afb71cd98d45938b4641ce861484fffac911c
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-06-05 09:32:22 +01:00
Ulf Hermann
c6d402e02d Rename the tst_cursor CMake target
It clashes with another tst_cursor in QtGui.

Change-Id: I55118393a22a2323691f634f194558b1df33d2be
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-06-02 09:49:02 +02:00
David Edmundson
883cfa2283 client: Implement cursor_shape_v1
A new wayland protocol allows clients to specify the cursor being used
rather than load themes and attach buffers.

Short term this has better behavior for scaling.

Long term when this has universal compositor support we can
drop the theme loading code.

Change-Id: I119e1ca44d351e7b13b8ec56f2218d94b7da0705
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-06-01 14:57:20 +00:00
David Edmundson
4cfd0da3d9 Client: Guard our surface from being destroyed whilst rendering from Vulkan
Change-Id: Ibac173b769186b49251bad9b94c71b9ccea26a7e
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-06-01 14:13:12 +00:00
David Edmundson
5043973b14 client: Clamp fractional scaling to be >= 1.0
Whilst the fractional scaling protocol supports values less than 100%,
Qt does not.

In this case we should continue using 100% and let the compositor take
care of making it smaller.

Change-Id: Iaec32adc80aa37f441be37b39e3e0afcbf29136b
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-06-01 17:13:12 +03:00
David Edmundson
7238199c84 Client: Remove check for BypassWindowManagerHint when setting viewport
This check was put in initially to leave a code path for clients to
opt-out of Qt controlled viewport management. In practice, many X11
applications have this flag set for other purposes and this does more
harm than good.

Given this was never a documented feature, and it won't have been used
in practice given fractional scaling is not heavily deployed outside a
few linux desktops it is safe to remove.

The highDpiScaleFactorRoundingPolicy remains a way to opt-out.

Pick-to: 6.5
Change-Id: I2d111a76695dec27e9ee1a2a233252b70379a329
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
2023-06-01 14:15:15 +01:00
David Edmundson
6ef8bfd891 Update wayland protocol XML to version 1.22.0
This updates only the protocol definition, implementations
will need additional commits to opt into using them.

The upstream XML specification changed in a way that requires newer
libwayland to generate without warnings in strict mode. To support older
setups the strict argument to wayland-scanner has been removed.

Change-Id: I265a9e208bbf107895b493b952d65f6178ac76e7
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-06-01 13:14:56 +00:00
David Edmundson
6d1b95ac8b client: Move device initialization to device constructor
The typical pattern throughout QtWayland is for wrapping clients to be
entirely responsible for the lifespan of underlying proxy objects.

InputDevices previously had a subtly different pattern with proxy object
initialization being called externally.

Change-Id: I2e018bff38628b636d0f485d810521f8e00291f3
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-06-01 16:14:01 +03:00
Vlad Zahorodnii
5b2524c57d Client: Don't sanitize desktop file name
This doesn't work well if the app id ends with ".desktop".

Pick-to: 6.5
Change-Id: I33d7c92f87595251f0da90277d12b2a2bb286a30
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-05-31 08:55:03 +03:00
Phan Quang Minh
36ea56dae8 Don't floor device scale in QWaylandShmBuffer::imageInsideMargins
The offset of the drawing target returned from
QWaylandShmBackingStore::contentSurface() is incorrectly calculated due
to `mImage.devicePixelRatio()` being casted to `int` inside
`imageInsideMargins`, which causes the scale to be rounded down in case
of fractional scaled displays. This causes the window contents to be
incorrectly positioned on CSD-requiring compositors (e.g. GNOME),
eventually resulting in graphics corruption due to mismatched damage and
opaque regions.

Fix this by removing the incorrect `int` cast.

Pick-to: 6.5
Change-Id: I436d24522d23888b641cb21403f773e8ea113b8d
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-05-29 07:02:31 +07:00
Alexey Edelev
005c2aad5e Make sure that all wayland targets are found in source tree
We look for wayland targets at feature evaluation step. Meanwhile
recent changes related to the static Qt build disable promoting those
targets to global because they might be already promoted by QtGui from
wayland plugins.

This adds the lookup of all required Wayland targets at src level, so
we make sure they are accessible and valid for targets that link them.

Amends 573486001f594ececfcd5797692ff6c48ceb493c

Task-number: QTBUG-113560
Pick-to: 6.5
Change-Id: Id719f86c41c694278773720dd76260835645bfa6
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-26 13:32:28 +02:00
David Edmundson
5921924fba tests: Cleanup cursor role objects
They should have the same lifetime as the underlying surface

Change-Id: I35ad0377a506a4e18e7d4f37691189f636ae54bf
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-05-23 17:26:59 +03:00
Alexey Edelev
573486001f Avoid promoting Wayland targets to global if they already exist
Disable promotion to global for all Wayland targets that are already
promoted by another find_package calls.

Fixes: QTBUG-113560
Pick-to: 6.5
Change-Id: I7c6984ed15daf996dd87db13290c98ee2c4cbeb6
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-05-23 12:55:25 +02:00
David Redondo
117f8dedcc Properly clean up screens during reconnect
Otherwise the old screens are left dangling. Also create a placeholder
screen so the windows get assigned a valid screen upon reconnect.

Change-Id: Iea5d1da6f32be5e87464412447ae1449d91d8e75
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-05-17 10:19:06 +02:00
Ilya Fedin
f2344f7d71 Client: fix a typo in minimum window size handling
Amends a3c665b65aa241c3ca56f3311e9380e8e434a6f2

Pick-to: 6.5 6.5.1 6.2
Change-Id: I3919b913aa7b09f9d0863344d72e9f6e14a8634a
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-05-15 11:24:15 +04:00
Inho Lee
a3c665b65a Apply only valid min/max sizes
When setting min/max sizes, the minimum size can be larger
than the maximum size. In that case, the size hint won't be
applied to the geometry.
Setting size hint will be pending until the min/max pair is
valid and the actual geometry will not be changed with
the invalid size hint.

Fixes: QTBUG-113233
Pick-to: 6.5 6.5.1 6.2
Change-Id: Ia05944e8342e7f8d794aee7883e0637a4c711c9d
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-05-09 11:15:27 +00:00
Thiago Macieira
a6275b00bd QWaylandDisplay: suppress warning about mixing QByteArray & QString
src/client/qwaylanddisplay.cpp:627:36:   required from here
qlist.h:907:20: warning: ‘bool QByteArray::operator==(const QString&) const’ is deprecated: Use fromUtf8, QStringLiteral, or QLatin1StringView [-Wdeprecated-declarations]

Pick-to: 6.5
Change-Id: Ieab617d69f3b4b54ab30fffd175b5c4e76fdda4d
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-05-02 13:26:41 -07:00
David Rosca
4f8399d307 QWaylandWindow: Init parent wl_surface when creating subsurface
Fixes recreating subsurfaces after hiding and then again showing
the window.

Pick-to: 6.5
Change-Id: I2e3e7ceb42ec6b25cb64db260dfb74f6ebb10d27
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-04-19 15:52:57 +02:00
Paul Olav Tvete
d66e8f148f Make sure doApplyConfigure() is called from main thread
Task-number: QTBUG-101948
Change-Id: I867365384c43ccddf5b7a8600a3db84aa99aca6d
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-04-18 13:09:34 +00:00
David Edmundson
446508bea7 Client: Use correct type in vulkan window for null
VkSurfaceKHR is not a pointer, nullptr is not always the same size.

Pick-to: 6.5
Task-number: QTBUG-112808
Change-Id: I12e5f61b67b9aa331f7e42a952413e922d09eb8d
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-04-13 09:39:52 +01:00
Carl Schwan
684367c462 Implement setBadgeNumber for wayland backend
This is based on qtbase/ac973cb74fecdaedf31922dfd48ea522a7af8f51

Change-Id: Ifef0d36cef01fb673731f276d51100115678e749
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-04-12 08:52:28 +02:00
David Redondo
531ac86e95 Destroy frame queue before display
wl_event_queue_destroy accesses the display.
Found by running a test under valgrind.

Pick-to: 6.5
Change-Id: Ic89cbd3b6e98b4fc9561b0e63b5fab4886a1ec50
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-04-11 20:57:33 +02:00
David Redondo
f820a71a50 QWaylandClientExtension: Allow specifying destructor for wayland objects
While the template takes care of creating proxies automatically,
destroying them is harder since an interface can have 0 to multiple
destructors. However in the most common case there is only one or always
calling one is sufficient.
An additional template parameter is introduced that allows user code to
specify a callable taking a pointer to the scanner generated class that
should be called when the wayland object is to be be destroyed. This is
done when the global is removed or upon destruction of the C++ object
itself. The clientextension test is changed how it can be used.
Since it works via a non-type template parameter a pointer to a (member)
function can be passed or when compiled in c++20 mode a lambda or
for example a function object.
This new functionality is opt-in and the default behavior is unchanged.
The default value is nullptr used as a tag to do not enable the new
behavior.

Change-Id: I8043f7106fec0cd6f2a79682e5872cfa8da3d11b
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-04-11 16:17:42 +02:00
Ilya Fedin
5e864b671e Client: Check for shell integration when initializing platform plugin
This makes QWaylandDisplay::initialize return a boolean and moves the
QWaylandIntegration's failure check out of constructor as
QWaylandIntegration::shellIntegration is a virtual method, this also
removes the out-of-date comments about processEvents as it's no more
used in QWaylandDisplay::forceRoundTrip.

Fixes: QTBUG-102457
Pick-to: 6.5
Change-Id: I3c8f1d9fd195326b587b45318443c2beee1ebfc2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-04-03 19:45:49 +04:00
Ilya Fedin
d6d416b05e Client: let QWaylandClientExtension work before platform integration is assigned
Task-number: QTBUG-102457
Pick-to: 6.5
Change-Id: Ia47478a4fbf45ba96fd73c6a1a53c2b844aa41b4
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-04-03 18:33:26 +04:00
Vlad Zahorodnii
25e7d1ed11 Client: Provide hooks for parent windows to attach popups to them
The xdg-shell protocol allows to attach xdg_popups to parent surfaces
that are not xdg_surfaces. For example, in order to attach an xdg_popup
to a layer_surface, you would need to initialize the popup as follows

    xdg_popup popup = xdg_surface.get_popup(nil, positioner)
    zwlr_layer_surface_v1.get_popup(popup)

QWaylandShellSurface::attachPopup() provides a way to perform
parent-specific initialization, i.e. call
zwlr_layer_surface_v1.get_popup.

QWaylandShellSurface::detachPopup() was added mostly for futureproofing.
The xdg-shell doesn't say exactly how the parent surface must be
attached. In the example provided above, a request is used to associate
the popup with its parent layer surface. But one could also create an
object to represent the relationship between the two. The detachPopup()
hook can be used to call the destructor request for that object.

Change-Id: I43b10e77bd70751d8b4c3a0b5e1d294690bc471a
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-04-03 15:14:04 +03:00
Vlad Zahorodnii
e1ef4a7f89 Client: Track parent-popup relationship in QWaylandWindow
This reduces the amount of boilerplate code that goes in shell
integration plugins providing popups.

The main motivation behind this change though is to ensure that
QWaylandWindow::addChildPopup() gets called outside the
QWaylandShellSurface constructor so one could use the popup's shell
surface object to customize parent-child relationship.

    mShellSurface = mShellIntegration->createShellSurface(this);

when this code executes, addChildPopup() will be called before the
return value of createShellSurface() is assigned to mShellSurface.

Change-Id: I9ccfb21f46febb451bdd7b4aa7851a99f3a03655
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-04-03 14:00:42 +03:00
David Edmundson
eabe2a039b Client: Cleanup vulkan surfaces on hide
Otherwise a hide/show combination will result in use of wl_surface after
it has been destroyed by QWaylandWindow.

This closely matches what the pattern we use for QWaylandEGLWindow.

Pick-to: 6.5
Change-Id: Ic23f947046ce521125dfa8a3c22f5529dfcbece2
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-03-31 10:43:23 +01:00
Ilya Fedin
e786b30e23 Client: Fix the mouse being stuck in pressed state after DnD
I can still reproduce the problem using QtWidgets applications
on KDE Plasma 5.27. Both Windows and macOS QPA have a similar quirk
and they both send a MouseButtonRelease event rather than a MouseMove
event.

Amends 8d291193ab93acfd23d2e82fe0a3d827d17d7bae

Task-number: QTBUG-97037
Pick-to: 6.5 6.2 5.15
Change-Id: I864a1cb68b3660d858623f943b3958f7cafbf955
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-03-21 16:38:54 +04:00
Vlad Zahorodnii
b3a9990532 Client: Fix wl_surface destruction order
The main thread can attempt to close the window while the QtQuick render
thread is still busy.

If that happens, ensure that QtQuick render thread has finished
rendering and presented the last frame before destroying the wp_viewport
and any other associated surface extensions so the window destruction
looks more reasonable.

Pick-to: 6.5
Change-Id: I8d2a3372fe6de51f357eed513baaa34a148470e3
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-03-20 09:59:57 +02:00
Liang Qi
33a371758b client: Add support for xdg_popup_configure
This amends 6d1d6ebb60ce3f239f83c3459f4465746fcba65c.

Since set_constraint_adjustment() was supported, popup should reposition
itself from configure.

Need to find a way to test clientSideMargins() and etc in the future.

Fixes: QTBUG-110623
Task-number: QTBUG-87303
Pick-to: 5.15 6.2 6.4 6.5
Done-with: Ilya Fedin <fedin-ilja2010@ya.ru>
Change-Id: I734acfcde3ba5a35b6f4222358bc93e49fa43f7c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-03-10 19:00:15 +01:00
Edward Welbourne
0db6b5d6c5 Rename tst_reconnect to avoid clash with qtremoteobjects
Name is too generic, but I'll leave this module's maintainers to work
out what to do about that. Left the source file with the old name.

Change-Id: I0429f03ef06feeae95c2f72ac76cc75397051d9e
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-03-10 11:18:51 +01:00
David Edmundson
358655d8db Introduce path for surviving compositor restarts
This patch introduces an optional mechanism for clients to survive a
crash and reconnect seemingly seamlessly.

In the event of a disconnect from the compositor socket we simply try to
reconnect again and replay any data needed so that we maintain a
consistent state to where we left off.

From an application point-of-view any open popups will be dismissed and
we we potentially get a new framecallback, but it will be almost
entirely transparent. Users of custom QWaylandClientExtensions will be
notified via the activeChanged signal and rebuild as though the
compositor had withdrawn and re-announced the global.

OpenGL contexts will be marked as invalid, and handled the same way as a
GPU reset. On the next frame RHI will notice these are invalid and
recreate them, only now against a new wl_display and new EGLDisplay.

Users of low level EGL/native objects might be affected, but the
alternative at this point is being closed anyway. The entire codepath is
only activated via an environment variable.

Change-Id: I6c4acc885540e14cead7640794df86dd974fef4f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-03-07 13:26:50 +00:00
Eskil Abrahamsen Blomfeldt
0042b8040f Compile with -no-opengl
A few of the tests were including Qt OpenGL for no good reason,
and the link step should be optional.

Pick-to: 6.2 6.5 6.5.0
Fixes: QTBUG-110420
Change-Id: Icb78c15e49070c6938bf9bb75abfed677af6785b
Reviewed-by: Inho Lee <inho.lee@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-03-06 14:56:32 +01:00
Aleix Pol
a20ee861d6 client: Do not cast placeholder screens to QWaylandScreen
It's wrong to C-cast an object to a class that isn't theirs. Check if it
is a placeholder first.

Pick-to: 5.15 6.2 6.5
Change-Id: I45d3c423422ae6638a033fb0f4cfefc7cd4460f0
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-03-06 09:13:55 +00:00
David Edmundson
be98a978e0 Client: Allow runtime disabling of interfaces for debugging purposes
When running it's useful to confirm things work correctly in various
configurations. In particular testing how things behave
without server side decorations is important on all changes.

It's easier to make the client pretend the compositor didn't send
anything than change the compositor every time.
This also potentially makes unit tests simpler than having to change the
mock compositor setup.

Change-Id: Ide897d918384389009aa38c7030d5ac30fc837a6
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-03-02 13:42:23 +00:00
David Redondo
cb71234bc9 Port xdg shell plugin towards QWaylandShellIntegrationTemplate
Ports manual initialization to the automatic handling of the
template. For now the integration QWaylandXdgShellIntegration
and QWaylandXdgShell are still separate but could be merged
in a future step.

Change-Id: I73bb9674e62f24f403349784e1b1e52a39aa8e9f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-03-01 10:06:27 +00:00
David Redondo
0badceeb6d Port wlshell integration to QWaylandShellIntegrationTemplate
Change-Id: Ib05a4645f930f41819447f6e1d562753a36e5710
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-03-01 11:06:23 +01:00
David Redondo
621a2d94ae Port fullscreenshell integration to QWaylandShellIntegrationTemplate
Change-Id: Ia3271a312d857d7e864444ad77e8e18a4a3858bf
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-03-01 11:06:17 +01:00
Ilya Fedin
763229e8c0 client: Unify margins handling
Currently all the shell integrations except of xdg-shell pass
full surface size to resizeFromApplyConfigure.

xdg-shell behavior is not even consistent between the first and the
consequent calls to resizeFromApplyConfigure.

This replaces QWaylandWindow::customMargins with
QWaylandWindow::windowContentMargins in order to being able to retrieve
set_window_geometry margins separately from the geometry itself
and makes xdg-shell passing the geometry consistently as full surface
size removing the need in special casing.

This also makes QWaylandWindow::clientSizeMargins public so e.g.
xdg-shell can compute out absolute position for window content geometry
without special casing decorations

Pick-to: 6.5
Change-Id: I1b98afc8b5c867ecb7cc586267b13f7ec4b1a88c
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-02-28 22:44:47 +04:00
Vlad Zahorodnii
af8732f3ef Client: Remove flip popup constraints
xdg_positioner doesn't have good anchor rect and other needed
information so the compositor can properly flip popups. In some windows
I see that some popups are flipped in such a way that the popups look
"detached" from the parent window.

With the information that QtWayland provides so far only slide
constraint adjustments can produce somewhat expected results. Although
there will be still some issues near screen edges.

Pick-to: 6.5 6.4 6.2 5.15
Task-number: QTBUG-87303
Change-Id: I4021f497b78e62651fe606c4be21a387a92edd6c
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-02-28 13:10:13 +00:00
Vlad Zahorodnii
8a6ef48e39 Client: Update last input device on tablet tool tap
When user uses tablet exclusively to navigate in an app, the last
tracked input device will be null. As the result, any popup that
requires a popup grab will be backed by an xdg-toplevel rather than an
xdg-popup.

Fixes: QTBUG-111130
Change-Id: Ib87e732603bbe111c584361357727171825f8c68
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-02-28 14:09:40 +02:00
David Edmundson
c2cd7eb609 client: Utilize new handleWindowDevicePixelRatioChanged
Rather than assuming window scale should match the screen scale use an
explicit notification system.

This fixes issues caused by drift between the two:

Task-number: QTBUG-101656
Task-number: QTBUG-93380
Change-Id: I9edb5fd95b8ceeca8073db1f56d81a31bbc9c549
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-02-27 10:36:08 +00:00
Marco Martin
6e7de758be client: Force a roundtrip when an XdgOutput is not ready yet
Is possible that the server sends a surface_enter before
all the information of the XdgOutput have been processed by the client.
in this case the associated QScreen doesn't exist yet, causing a
QWindow::SetScreen(nullptr), which will fall back to
QGuiApplication::primaryScreen(), having the QWindow being assigned the
wrong screen

Change-Id: I923d5d3a35484deafa6f0572f79c16c27b1f87f0
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-02-27 10:07:47 +00:00
Ilya Fedin
ba604ed786 Fix build on CentOS 7
Have the following errors while attempting to build qtwayland v6.5.0-beta3:
    /usr/src/Libraries/qt_6.5.0/qtwayland/src/client/qwaylandshmbackingstore.cpp:48:19: error: 'F_ADD_SEALS' was not declared in this scope
       48 |         fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
          |                   ^~~~~~~~~~~
    /usr/src/Libraries/qt_6.5.0/qtwayland/src/client/qwaylandshmbackingstore.cpp:48:32: error: 'F_SEAL_SHRINK' was not declared in this scope
       48 |         fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
          |                                ^~~~~~~~~~~~~
    /usr/src/Libraries/qt_6.5.0/qtwayland/src/client/qwaylandshmbackingstore.cpp:48:48: error: 'F_SEAL_SEAL' was not declared in this scope
       48 |         fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
          |                                                ^~~~~~~~~~~

Pick-to: 6.5
Change-Id: I4b9b3a13ac47483594f454ba36dc5d720cb592a5
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-02-24 13:30:55 +04:00
Vlad Zahorodnii
cbab88861b Client: Stop requesting activation on every focus object change
Currently, windows with xdg-toplevel surface role request window activation
every time the focus object changes. It conflicts with the compositor's
activation and stacking order policies.

For example, when a window is minimized, the compositor will start an
animation and move focus to the next window. If that window activates
itself, it can be raised in the stack and start covering the minimized
window, thus making it look as if no animation is played at all.

This activation logic was introduced as part of qt-shell activation
model in a7bb7210ac76a397b4aec8d8f32d902dc932d855. On the other hand,
with the introduction of the xdg-activation-v1 protocol, there is a
better way to pass input focus, so drop the qt-shell hack in favor of
that.

Fixes: QTBUG-111377
Pick-to: 6.5
Change-Id: I8ed19f1be17f49fa9748b1cb5fdd0070791d2ecd
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-02-22 16:55:02 +02:00
Michael Weghorn
fb79f4c3bd Convert cursor bitmap to supported format
The 1-bit image formats QImage::Format_Mono and
QImage::Format_MonoLSB used by cursor bitmaps don't have
a corresponding wl_shm_format.

Therefore, convert to a supported image format as necessary
to make such bitmap cursors work on Wayland as well.

Fixes: QTBUG-95434
Change-Id: I402fd870b301ddc01075251b66f2cf7cc1923133
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-02-22 09:15:35 +01:00
Mårten Nordheim
f9180f6cd6 Fix automoc warning regarding include
There's no Q_OBJECT etc. in the .cpp file, so likely it was
removed, or it was intended to include the moc file for the
sake of the header. But moc-file for the header has another
naming scheme.

Pick-to: 6.5
Change-Id: If1202537a40d746e263fd6e6f67e316a2cdb109e
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-02-21 12:55:09 +01:00
Friedemann Kleint
43a99beccd Exclude sources generated by the scanner from CMake Unity (Jumbo) builds
The generated helper function wlRegistryBind() clashes.

Pick-to: 6.5
Task-number: QTBUG-109394
Change-Id: Ib814d4576c7565b0413ca16bc0bf5e95caa92c33
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-02-13 09:32:35 +01:00
Friedemann Kleint
e8a052bc8f Disambiguate input method constants
They cause clashes in CMake Unity (Jumbo) builds.

Pick-to: 6.5
Task-number: QTBUG-109394
Change-Id: I13b33c894818d8aebce763eaf6c961d806961a63
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
2023-02-13 09:06:23 +01:00
Friedemann Kleint
25d387c614 Disambiguate static variables
They cause clashes in CMake Unity (Jumbo) builds.

Pick-to: 6.5
Task-number: QTBUG-109394
Change-Id: Ia6e293fa30d788f8abd52bf675f11d7d0151259f
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-02-13 08:52:06 +01:00
Eskil Abrahamsen Blomfeldt
f821878cd7 client: Fix infinite recursion with text-input-v2
It was possible to get into an infinite recursion when
double-clicking an entry in an item view to edit it.

What would happen is that the editor takes focus, and we call
commit on the input method commit in case the previous focused
widget has pending input that needs to be committed. The
subsequent method event then causes the QAbstractItemView to
set focus, and since we have not yet updated the focus in the
previous call, we end up in an infinite recursion, eventually
crashing when the stack overflows.

As a guard for this, we only send an input method event when there
is actually pre-edit text to commit, and we reset the pre-edit
text immediately so that any subsequent call will just exit.

[ChangeLog][QtWaylandClient] Fixed a possible crash when editing
a field in an item view.

Pick-to: 5.15 6.2 6.4 6.5
Fixes: QTBUG-109302
Change-Id: I45237c80e53b1386705279899e19319180d78fa1
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Inho Lee <inho.lee@qt.io>
2023-01-30 10:27:06 +01:00
Ilya Fedin
0c96282e97 Don't change process locale while initializing QWaylandInputContext
This was overriding the locale previously set in
QCoreApplicationPrivate::initLocale and can switch the process to
non-UTF8 codepage

Pick-to: 6.5 6.4 6.2
Change-Id: I5cd6664d1a7c315019d6c798b33b9deb33982a59
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-01-26 10:18:47 +00:00
Ilya Fedin
41a9ffeb0c client: Attempt to request activate even if there's no focus window
The compositor is likely to display some indication
even if the activation fails, so it's helpful to always do the request.

Pick-to: 6.5 6.4
Change-Id: Ia3a8075e471d5a4b619f420ee166e7146f1229b8
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
2023-01-25 18:19:23 +04:00
Aleix Pol
9c35dc2284 QWaylandTabletSeatV2: Do not leak tablet information
Clean up after the information we allocated, this way address sanitizer
doesn't complain about it leaking.

Change-Id: Ib7ade93d6585b8c6be6a71d0497801d9cfe75d2f
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-01-24 14:30:40 +01:00
Aleix Pol
bc44aa6607 QWaylandDataOffer: Save double look-up
Only look up the value on the QHash once.

Change-Id: I7c7c2f72bb1aa8fad0d374d5ea84c093ea5a2f01
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2023-01-24 14:30:29 +01:00
Tang Haixiang
5925c3110d Client: Manage QMimeData lifecycle
QMimeData is created by user, it is not taken care of in qtwayland,
which will cause memory leak.

It is now handled in qtwayland that when a new QMimeData is set,
the previous QMimeData is freed.

Change-Id: Ic502021fe700c7ee10454d94f0d1868901809af7
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-01-09 21:13:02 +00:00
Vlad Zahorodnii
051b3ce2ee Client: Fix handling of Qt::BlankCursor
The cursor may not be properly set when a window has Qt::BlankCursor and
it's shown. In that case, the cursor surface may not be present and
wl_pointer.set_cursor won't be called.

On the other hand, wl_pointer.set_cursor must be always called when
wl_pointer.enter is received.

Pick-to: 6.5
Change-Id: I8540e7a02df1579b3380a1a1d4cfab42c1ab3104
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-01-05 15:54:42 +02:00
Vlad Zahorodnii
19f6aae5f2 Client: Port to QPlatformTheme::{MouseCursorTheme,MouseCursorSize}
It allows the platform theme to specify the preferred cursor theme and
cursor size without resorting to hacks such as setting XCURSOR_THEME and
XCURSOR_SIZE environment variables.

Pick-to: 6.5
Change-Id: I9e44f9c6dddbb5d730f8ac092f2c11fdbccf8d27
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-01-03 16:08:27 +02:00
Thomas Senyk
7ababb0dfb Add WL_SHM_FORMAT_RGB888 to supported shm formats
In addition a new entry in QWaylandCompositor::ShmFormat
allows compositors to enable that format at runtime

Pick-to: 6.5
Change-Id: I0f894adb3f688458a65713e343127fbcb26f8b65
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-12-13 12:02:10 +01:00
Vlad Zahorodnii
77442e107f Client: Handle zwp_primary_selection_device_manager_v1 global removal
The zwp_primary_selection_device_manager_v1 global can be withdrawn if
the compositor disables the primary selection, i.e. middle click to
paste selected text. QtWayland needs to handle that; otherwise the app
can crash.

Pick-to: 6.5
Change-Id: Idbb4db18b605f85a5951fa12c1bdf61898b0d123
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-12-13 12:47:24 +02:00
Vlad Zahorodnii
0052d0ed13 Client: Provide support for custom shells
Currently, an application can use only one shell surface protocol at a
time. However, there are applications that need to use more than one
shell surface protocol, e.g. xdg-shell + layer-shell. layer-shell can be
used for the desktop background window, and xdg-shell for popups, etc.

This change introduces an API in QWaylandWindow that allows specifying
the shell integration per window.

Custom shell code needs to call QWaylandWindow::setShellIntegration()
while the window is unmapped. By default, QWaylandWindow will use
QWaylandDisplay's shell integration plugin.

This change should be source compatible with existing shell integration
plugins deployed in the wild.

If the custom shell wants to track additional state for the window, it
should do it using its own means. Perhaps we could improve this in the
future releases of Qt.

[ChangeLog][QtWaylandClient] It is possible to run Qt applications using
more than one shell surface protocol, e.g. xdg-shell + layer-shell.

Change-Id: Id0458b32af623f114c06d51d0d21ad06efd69328
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-12-08 15:01:02 +02:00
David Redondo
9e23cbc94c client: Implement QNativeInterface::Private::QWaylandWindow
Task-number: QTBUG-94729
Change-Id: Ib79f3199a4518700aa032c5ca4760a2b53c401e5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-12-08 10:31:45 +01:00
David Edmundson
d62c5761e8 Implement fractional_scale_v1 and wp_viewport
This allows compositors to hint a non-integer scale to use on a window
which we can hook to Qt's existing fractional scaling support.

The viewport is used to communicate the relationship between buffer size
and logical size to the compositor. It is a non-integer alternative to
wl_buffer_scale

Change-Id: I1a850f1bcd40e8d04e241e18a538b11f18bc671c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-12-07 20:36:40 +00:00
Vlad Zahorodnii
f45244946c Client: Improve handling of 0xH and Wx0 xdg_toplevel configure events
The compositor can send a configure event with 0xH and Wx0 when it wants
the window to have some concrete size along one dimension but wants the
client to pick the size along the other dimension.

Change-Id: I2e72017d4a71b19a930da24fa5c58b6ce672fb94
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-12-05 18:27:59 +02:00
Eskil Abrahamsen Blomfeldt
389f01d835 client: Allow resizing with touch input on client-side decorations
The touch input for client-side decorations had its own handling
which only processed button clicks and moves. This meant that it
was impossible to resize windows using touch events. This
generalizes the mouse input code path and uses it for touch as
well. We need to take care not to update any mouse state in the
case of touch, since we only care about touch press events, so
we pass in a PointerType and disable parts of the code path when
the input is from a touch device.

[ChangeLog][QtWaylandClient] Enable resizing windows using
client-side decorations with touch input as well as mouse input.

Task-number: QTBUG-108690
Change-Id: I761ebb0c7c4844c52f793caa74e8606d1593757f
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-12-05 13:54:25 +01:00
Weng Xuetian
2b49cf04a6 Fix frame sync related to unprotected multithread access
There is a few crashes happens in real life that frame callback is
double-free'd and hit an assertion in wayland-client. e.g.
https://bugs.kde.org/show_bug.cgi?id=450003

This is due to the WaylandEventThread and calls to QWaylandWindow::reset
may free and unset the mFrameCallback at the same time. mFrameSyncMutex
should be used to protect such access.

Pick-to: 6.4
Change-Id: Ie01d08d07a2f10f70606ed1935caac09cb4f0382
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-12-03 20:33:33 -08:00
Vlad Zahorodnii
27e59681ac Client: Honor QGuiApplication::overrideCursor()
If there's a QGuiApplication::overrideCursor(), QWindow::cursor() can
still return a different cursor. This can result in a wrong cursor when
the pointer enters a window.

Pick-to: 6.4 6.2 5.15
Fixes: QTBUG-75919
Change-Id: I015117b4b6d252b421ab14bd8f2a8f582f7cae52
Reviewed-by: Liang Qi <liang.qi@qt.io>
2022-11-30 10:38:42 +01:00
Vlad Zahorodnii
6ec226dbd1 Client: Bump wl_output version
wl_output_release is available starting with wl_output v3.

Change-Id: I21822b26728ffb9318f1f8b4bd82ef7329682838
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-11-22 12:41:26 +02:00
Vlad Zahorodnii
f2f98a1181 Client: Call wl_output_release() upon QWaylandScreen destruction
It ensures that the proxy gets destroyed.

Change-Id: I915cc8814e33dd3b0405b2bf82bd12ce6b5f785b
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-11-22 10:47:44 +02:00
Vlad Zahorodnii
b2c0a783d0 Client: Add F_SEAL_SHRINK seal to shm backing file
This lets libwayland-server avoid installing a SIGBUS handler when it
wants to mmap() the backing file and access the contents of shared
memory client buffers.

Change-Id: Id0b17f729799535d73e8700c5a99c32fd88a068a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-11-18 11:13:25 +02:00
Liang Qi
f733811432 tests: fix tst_seatv4 to use 24 as default cursor size
Also set default cursor size to 24 for client, which is correct
both on KDE and GNOME at least.

Fixes: QTBUG-104259
Pick-to: 6.4 6.2 5.15
Change-Id: Ie4ba27695974025b093a86d8c96fb23d25ad23f7
Reviewed-by: Inho Lee <inho.lee@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-11-08 14:23:10 +01:00
David Edmundson
e0c53e4f6d Remove uneeded forceRoundTrip on XdgOutputManager
In the first rountrip we will get all wl_outputs and the
xdg_output_manager. Therefore we know we will have called wl_output.bind
and xdg_output_manager_get_output by the time we hit the
second roundtrip on startup.

Change-Id: I69f911c13f9bcdfb59b04eceea4bcca778e7755c
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-11-08 13:15:52 +01:00
Inho Lee
8826dbb613 Add dependencies of wayland protocols
Some macros are missing DEPENDS for add_custom_commands

Fixes: QTBUG-108142
Change-Id: Ifacb2ea9bf3003c10dd407a8c77fc06b893b6a65
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-11-07 17:48:08 +01:00
David Redondo
9c5b09ee8d Implement QNativeInterface::Private::QWaylandScreen
Change-Id: I2f5cc638f33fe0d884146342516efa7ce8474478
Task-number: QTBUG-94729
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-11-03 14:13:15 +01:00
Inho Lee
ea5bad9031 Always use blocking write for data_source.send
QtWaylandClient assumes that data_source's fd is BLOCKING,
but some compositors (e.g. mutter) pass an fd with
O_NONBLOCK set. In this case, 'write' is not guaranteed to
process all of the passed data in one call. Instead of
dealing with such partial writes, remove O_NONBLOCK.

Fixes: QTBUG-107076
Pick-to: 6.4 6.2 5.15
Change-Id: Ieb446da9fdfbaaa55100f573b396ee449cadc463
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-11-01 08:46:40 +00:00
Jonas Karlsson
50dbfe3970 Disable/fix warnings
missing-field-initializers and unused variable

Change-Id: I1a5ceaf53ec706786c73eecab0c002fa9153b962
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-10-28 08:17:09 +02:00
David Redondo
efdd7b5755 Implement QNativeInterface::QWaylandApplication
Task-number: QTBUG-94729
Change-Id: I84f080719c6364137368bdd1759947a6d6ef2e5b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-10-27 10:49:14 +02:00
Vlad Zahorodnii
9dd6cc1788 Client: Add support for xdg_toplevel.configure_bounds
Currently, QtWayland doesn't know about work area size, which can create
a problem where some windows don't fit into the screen area or work
area.

With the xdg_toplevel.configure_bounds event, the compositor can
indicate the client the recommended maximum window geometry size.

https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/41

Change-Id: I5214aba9f144d091a2afe639de94b8d717c42fdc
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-10-26 22:42:01 +02:00
Vlad Zahorodnii
165b770fc5 Client: Add support for high-resolution scrolling
With wl_pointer version 8, the axis_discrete event is replaced with the
axis_value120 event.

The main difference between axis_discrete and axis_value120 is that the
latter carries scroll deltas that can be fractions of 120, e.g. 30, etc.

See also https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/72

Change-Id: I4f724ead7ba146dde6d8975fa4edfcfca761769d
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-10-26 22:34:20 +03:00
Ilya Fedin
425cceca83 Implement window alert with xdg-activation
This is implemented by not specifying serial, as mentioned in
https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/9#note_854977

Tested on KDE Plasma

Change-Id: I4ef0975040bbce581b615b0318f90601e080235c
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-10-23 17:19:05 +04:00
Marc Mutz
2b63b8eb2a Port to new Q_UNREACHABLE_RETURN()
This is a semantic patch using ClangTidyTransformator to convert
sequences of Q_UNREACHABLE() + return into Q_UNREACHABLE_RETURN(),
newly added to qtbase.

    const std::string unr = "unr", val = "val", ret = "ret";
    auto makeUnreachableReturn = cat("Q_UNREACHABLE_RETURN(",
                                    ifBound(val, cat(node(val)), cat("")),
                                    ")");
    auto ignoringSwitchCases = [](auto stmt) {
        return anyOf(stmt, switchCase(subStmt(stmt)));
    };

    makeRule(stmt(ignoringSwitchCases(stmt(isExpandedFromMacro("Q_UNREACHABLE")).bind(unr)),
                  nextStmt(returnStmt(optionally(hasReturnValue(expr().bind(val)))).bind(ret))),
             {changeTo(node(unr), cat(makeUnreachableReturn,
                                      ";")), // TODO: why is the ; lost w/o this?
              changeTo(node(ret), cat(""))},
             cat("use ", makeUnreachableReturn));

a.k.a qt-use-unreachable-return.

subStmt() and nextStmt() are non-standard matchers.

Change-Id: I3855b2dc8523db1ea860f72ad9818738162495c6
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-10-19 07:18:49 +02:00
Volker Krause
a34a3ff75e Allow to run wayland-scanner without --include-core-only
There are Wayland protocols for which using this option doesn't
result in compilable code. Examples are input-method-unstable-v1
and linux-dmabuf-v1.

Pick-to: 6.4
Change-Id: I06dea12dea1058fb6bd99522aa4278c36d271d4e
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-10-18 17:01:59 +02:00
Alexey Edelev
e2d3b915be Adapt module to work with the new syncqt
Add dependencies to WaylandCompositor_sync_headers for the qml plugin
targets. Add deprecation macros. Fix syncqt warnings.

Task-number: QTBUG-87480
Change-Id: I0e169344c9a8186484fbb36f5ec1e03cd38ea19b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-10-12 11:42:03 +02:00
Alexey Edelev
fb8e5fddca Add private header filters to the qt_interal_add_module calls
This is required to filter the generated wayland files when syncing
headers.

Task-number: QTBUG-103196
Change-Id: I86d440bf8b56802dff2fa75ba621c37a8daa8bbf
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-10-12 11:41:59 +02:00
Marc Mutz
0cf9831657 Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.

Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace.

Task-number: QTBUG-99313
Change-Id: Ia64c6615ee81f7ad5d0658449b0ee347c3db8c29
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-10-10 20:28:09 +02:00
Marc Mutz
6c4ec81e6e Port from container::count() and length() to size()
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8:

  auto QtContainerClass = anyOf(
      expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o),
      expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o));
  makeRule(cxxMemberCallExpr(on(QtContainerClass),
                             callee(cxxMethodDecl(hasAnyName({"count", "length"),
                                                  parameterCountIs(0))))),
           changeTo(cat(access(o, cat("size"), "()"))),
           cat("use 'size()' instead of 'count()/length()'"))

a.k.a qt-port-to-std-compatible-api with config Scope: 'Container',
with the extended set of container classes recognized.

Change-Id: I574208abc90a8042b500b3f96e3862b0ff339eb6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-10-10 20:28:01 +02:00
Luca Di Sera
b32c8dd49e Fix syncqt warnings
Change-Id: I739eb81ec78a071baa85d24f26bb45b184b9068c
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-10-10 13:35:29 +02:00
Marc Mutz
bebf43bcc8 Replace qExchange with std::exchange
None of these users require C++20 constexpr or C++23 noexcept, the
only remaining difference between std::exchange and qExchange.

Task-number: QTBUG-99313
Change-Id: Ic5a0bd36d715af2cbc5f9936fdff665ee6eeea4e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-10-06 10:14:19 +02:00
Kai Köhne
ece18f7ce2 Fix qt_attribution.json file
Fixes

File ./qtwayland/src/3rdparty/protocol/qt_attribution.json: Unknown key File.
File ./qtwayland/src/3rdparty/protocol/qt_attribution.json: Unknown key License file.
Could not parse file ./qtwayland/src/3rdparty/protocol/qt_attribution.json: object is missing after a comma

Pick-to: 6.4.0 6.4
Change-Id: I145f9bcc40f175f5d909f7f947c2a20333b70c0c
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2022-09-29 08:25:50 +02:00
Fushan Wen
a0dd7d52b9 Call finishDrag() in QWaylandDataDevice::dragSourceCancelled()
Drags can either get finished or cancelled. If a drag is finished
successfully we call finish on the QBasicDrag instance, which quits
the nested event loop. This patch adds the connection for cancelled
drags.

See also: https://bugs.kde.org/show_bug.cgi?id=446111

Pick-to: 6.4 6.2 5.15
Change-Id: Ib93040648da88a433d647c87adcb7a7fabcaef6c
Reviewed-by: Liang Qi <liang.qi@qt.io>
2022-09-22 10:55:01 +00:00
Ilya Fedin
0b0788c824 Client: fix enlargening window position by margins size
In a7bb7210ac76a397b4aec8d8f32d902dc932d855 it was changed to
sum the current geometry with the margins. This makes Qt thinking
that the window is moving on every configure request and makes the
previous fix (b25af2c7687b5802b48076ba1a885cc986084629) actually no-op

I'm not sure why it was changed as the commit is squashed, but I hope
the intention wasn't to make Qt think the window is endlessly moving
(exactly that happened though)

Pick-to: 6.4 6.3
Change-Id: I7cde12ea5548d59810e2631be2a0085f86d5c4b9
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-09-20 15:31:06 +04:00
Janne Juntunen
2653ed9761 Client: skip building tests which cannot be run on webOS
WebOS developers have informed us via QTBUG-106114 that opening
multiple (consecutive) windows from single webOS-QtWayland client is
not supported and majority of our test cases try to do exactly that,
causing a segmentation fault. Therefore we need to skip these tests.

Fixes: QTBUG-106638
Pick-to: 6.4
Change-Id: Ifbdb2cfb663f8eccd3d68e30445e2a0f39b11355
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-09-15 16:17:22 +03:00
Alexandros Frantzis
ae732f333d Use CRLF line delimiter for text/uri-list data
According to RFC 2483, which describes text/uri-list, the line delimiter
must be CRLF (instead of the currently used LF). Some applications
strictly expect the CRLF delimiter and fail to properly parse the
uri-list otherwise (e.g., WineX11/XWayland).

https://datatracker.ietf.org/doc/html/rfc2483

5. The text/uri-list Internet Media Type
The format of text/uri-list resources is:
3) As for all text/* formats, lines are terminated with a CRLF pair.

Pick-to: 6.4 6.3 6.2 5.15
Change-Id: I7c062224a9060028ab6293fdf172692ade28cca5
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-09-05 10:55:56 +00:00
David Edmundson
9631d9f27a Client: clear focus on touch cancel
When we get a touch_cancel event all touches should be treated as
lifted.

The next frame call focus is set, with no pending touch points but
without having gone through touch_up. We call mPendingTouchPoints.last()
without guards even though it is potentially now empty.

Change-Id: I3719f9507c5d397d8641692271d878076b7c23b8
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-09-05 11:52:00 +01:00
Lucie Gérard
42b9e035d5 Change the license of all CMakeLists.txt and *.cmake files to BSD
Task-number: QTBUG-105718
Change-Id: Icb25ea4e07a38eea81f55ed59c6d3b9d37602626
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-23 23:22:59 +02:00
Ilya Fedin
877b143019 Client: add custom margins support to xdg popups
xdg_positioner operates in window content geometry (i.e. without shadows),
so it's necessary to remove popup's and parent's shadow from position and
size calculations.

Pick-to: 6.4
Change-Id: I997ba2c45ae341a09a8284226629e8107800e894
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-08-23 01:22:59 +04:00
Eskil Abrahamsen Blomfeldt
6f8b1bd725 Avoid calling requestUpdate from wrong thread
In certain circumstances, we can get to createDecoration()
from the render thread (from QWaylandGLContext::makeCurrent)

Calling requestUpdate() from this secondary thread would
cause an assert, so we queue the call on the appropriate
thread instead.

This amends 1a2e499e0e05a03460f4335d5266be485f97d3fa.

Pick-to: 5.15 6.2 6.3 6.3.2 6.4
Fixes: QTBUG-105308
Change-Id: I4805265f39e24eb1464897532be2025bc3c27728
Reviewed-by: Inho Lee <inho.lee@qt.io>
2022-08-17 08:38:00 +00:00
David Redondo
4132a63f14 Provide a handle for desktop portal via xdg-exporter
Change-Id: I6b2034c1833ae497ef05af7c377e4bfd3747b6fe
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-07-29 15:07:10 +02:00
Jan Grulich
95edea11f1 Client: do not take decoration shadows into account when placing popups
The anchor rectangle is relative to the window geometry, which according
to xdg-shell specs shouldn't include invisible portions like shadows.
This causes all popups be wrongly positioned when drop-shadows are used.

Pick-to: 6.4 6.3 6.2
Change-Id: Iac30ab264599f9898f3ddecd7f0c5f2aca824ad6
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-07-29 14:16:11 +02:00
Thiago Macieira
7aae0a115b Fix several more improperly placed #include moc
Like commit qtbase/638893bea083b619b73b33a7dd5589fb2c4c4242.

Script to find them:

 git grep -l '#include.*moc' \*.cpp \*.mm | \
   xargs awk '/QT_BEGIN_NAMESPACE/ { i=1 } /QT_END_NAMESPACE/ { i=0 } /#include.*moc/ && i { print ARGV[ARGIND], $0 }'

Pick-to: 6.4
Change-Id: I6f936da6f6e84d649f70fffd17058fd05cfc5c6d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-28 07:04:40 -07:00
Alexandru Croitor
8ec60005f4 CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers
Change-Id: I95f27e29fdee60acecba4fbba9b1b77c1680cee5
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-28 11:27:34 +02:00
Weng Xuetian
959134c4de Only close popup in the the hierchary
Imagine following event sequences:
1. a tooltip is shown. activePopups = {tooltip}
2. user click menu bar to show the menu, QMenu::setVisible is called.
    now activePopups(tooltip, menu}
3. tooltip visibility changed to false.
4. closePopups() close both tooltip and menu.

This is a common pattern under wayland that menu is shown as a invisible
state. This patch tries to memorize the surface hierchary used to create
the popup role. And only close those popups whose ancesotor is hidden.

Pick-to: 6.4
Change-Id: I78aa0b4e32a5812603e003e756d8bcd202e94af4
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-07-24 05:20:34 +00:00
Ilya Fedin
6939f52984 Client: Expose a way to set window margins via native interface
The lack of such API is a big hassle to me since a long time.
All that time I was forced to have my own fork of the
xdg-shell plugin in the application code in order to have
shadows on Wayland with custom client-side decorations.
I hope I won't have to maintain the fork anymore.

Pick-to: 6.4
Change-Id: Iaf498469843b5cac5c458049164065c4ef15877d
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-07-19 19:15:01 +04:00
Weng Xuetian
e43b382fb3 Also use text-input if QT_IM_MODULE is empty or "wayland"
Previously, text input can only be used when only when QT_IM_MODULE is
unset, it is counter-intuitive when empty and null has different meaning.
Additionally making "wayland" to use text input to make it easier to enforce
wayland context. Gtk's relevant value is also "wayland" so it will be more
consistent.

Pick-to: 6.4 6.3 6.2
Change-Id: I39b8c899b0ab7965d4b17ca29ed9eadc14f17e88
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
2022-07-13 10:07:04 -07:00
Ilya Fedin
b5160ae118 Client: get activation token automatically whenever possible
This allows the application to change focus between its own windows
without any code change whenever possbile

I.e. if application already has a focused window or the token is specified
in XDG_ACTIVATION_TOKEN environment variable

Pick-to: 6.4 6.3
Change-Id: I6f54d12197ac0c10bfda2a517aa11bc291e3b471
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
2022-07-11 03:33:27 +04:00
Lucie Gérard
c1187f4daa Add license headers to cmake files
CMakeLists.txt and .cmake files of significant size
(more than 2 lines according to our check in tst_license.pl)
now have the copyright and license header.

Existing copyright statements remain intact

Task-number: QTBUG-88621
Change-Id: Ib014757184540728f40df71cd580f01e85fbbb56
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-08 13:41:49 +02:00
JiDe Zhang
2720ecf2ee Use QColor::fromString instead of some deprecated functions
It's a follow-up of a series changes from
78b6876974d2cea087cb229257097052dad5fcf7 in qtbase.

Pick-to: 6.4
Change-Id: I4ad19b07489630a4648b5d6ca4a8c074ed88827b
Reviewed-by: Liang Qi <liang.qi@qt.io>
2022-07-05 05:05:36 +00:00
JiDe Zhang
425893491d Fix some build warnings
Pick-to: 6.2 6.3 6.4
Change-Id: I61edd5ab0f4383930ad37916e4cec4ab714274d4
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-07-04 17:10:02 +08:00
Eskil Abrahamsen Blomfeldt
79cc2f159c client: Respect initial size when only one component is set
We would ignore the initial size of the window if only either
the width or height were set and the other was left at 0. Instead
of using isEmpty() for checking if the geometry is valid, we
check the width and height individually.

Pick-to: 6.4
Task-number: QTBUG-66818
Change-Id: Ib2a22443fd6b88175599da08651fa72c921ea485
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-06-30 08:17:44 +02:00
Eskil Abrahamsen Blomfeldt
495fd51531 Remove unused variables
They appear to have been around and unused forever, but
I've started getting warnings (-are-errors) about this.

Pick-to: 6.4 6.3 6.2 5.15
Change-Id: I2f3006aa47de24927d7edd2d7f43cff78f965f87
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-06-28 08:17:41 +02:00
David Redondo
0d46bfd475 Keep toplevel windows in the top left corner of the screen
We can't know the actual position of a window on the screen. This causes
an issue when Widgets try to position a popup/menu absolutely and keep
it on the screen when the screen geometry doesn't include (0,0).
Instead report their positions always as the top left corner of
the screen that they are on.
This new behavior can be disabled for qt-shell or via an environment
variable by users that rely on the old behavior.

Fixes: QTBUG-85297
Change-Id: Iacb91cb03a0df87af950115760d2f41124ac06a3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
2022-06-22 09:12:24 +02:00
Thiago Macieira
64be7816a8 Client: fix license in two files
This amends a7bb7210ac76a397b4aec8d8f32d902dc932d855.

The client library is LGPL. Probably a copy & paste error.

Pick-to: 6.3 6.4
Change-Id: I6d3880c7d99d4fc494c8fffd16fa869e524d5ac2
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-21 18:50:22 +00:00
Lucie Gérard
f16eb3fef0 Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
License files are organized under LICENSES directory.

Pick-to: 6.4
Task-number: QTBUG-67283
Change-Id: I106d3a5d1a7b96250380b6f51a48f3b19d10e4d9
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-06-10 15:11:54 +02:00
Ilya Fedin
1c2113afbd Client: Expose default input device's serial through integration
Default input device is not so useful
without serial for calls like xdg_toplevel_show_window_menu

This is done in the same way as
apptime/appusertime/gettimestamp in xcb's native interface.

Pick-to: 6.4
Change-Id: I20e7dee19cf20e819a557e23c539066945cecb46
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-06-09 16:16:35 +04:00
Liang Qi
953d769677 QtWaylandClient: includemocs - qt6
Pick-to: 6.3 6.2
Task-number: QTBUG-103295
Change-Id: Ia4cb0df840b27e70f162e28d13bedd992c27cd83
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-01 10:58:12 +02:00
Liang Qi
4a57ddd3ba QtWaylandClient: includemocs
Pick-to: 6.3 6.2 5.15
Task-number: QTBUG-103295
Change-Id: Ibac5e794c7d7f35d51d8d48110892c33a0b67c7a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-01 10:58:10 +02:00
Liang Qi
cef1e8f7f0 QWaylandXdgShellIntegrationPlugin: includemocs - qt6
Pick-to: 6.3 6.2
Task-number: QTBUG-103295
Change-Id: Iff8a76926a8a0b581a0290b5b6ab44453ac774ec
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-01 10:57:59 +02:00
Liang Qi
60e835a410 QWaylandXdgShellIntegrationPlugin: includemocs
Pick-to: 6.3 6.2 5.15
Task-number: QTBUG-103295
Change-Id: I974dbcd67bc4a45cf18d0fdf197bcaeb12c633b4
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-01 10:57:57 +02:00
Liang Qi
aa2de8df9f QtWlShellIntegrationPrivate: includemocs
Pick-to: 6.3 6.2 5.15
Task-number: QTBUG-103295
Change-Id: I000dd8b5fa13747acfa8c12df4203dfdaa48b9c4
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-01 10:57:54 +02:00
Ilya Fedin
bb3eeb085c Client: fix mouse cursor restoring check when cursor enters the content area
In a02c408afc1ec3713d26f133277cbba2d207f102,
windowContentGeometry was changed by adding shadow margins,
but the check ensures that the point inside the content area
rather than the decoration and windowContentGeometry is smaller
than the decoration geometry now as it excludes the shadow.

Creating the geometry from surfaceSize fixes it.

Pick-to: 6.3 6.2
Change-Id: If20a387b6864c1bc961352654f827a45cee77bd1
Reviewed-by: Jan Grulich <jgrulich@redhat.com>
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
2022-06-01 04:34:45 +04:00
Eskil Abrahamsen Blomfeldt
d112d4ec8e client: Avoid protocol error with invalid min/max size
If the application sets an invalid minimum and maximum size
(where the minimum is higher than the maximum), then we
would blindly send this over the protocol, which is a protocol
error according to the spec. Qt compositors will warn about
this and ignore the size, but mainly because "but there's no
matching error defined" according to the comment. Other
compositors may close the connection when this happens.

To avoid crashing the app based on bogus min/max size, we
make sure we never send a maximum size which is less than
the minimum size. This corresponds to the behavior of
compositors which accept the size without raising an error:
the minimum size takes precedence.

Note that 0 means "no maximum size" in the protocol, so we
cap the value before applying this logic.

[ChangeLog][Client] Fixed an issue where setting an invalid
minimum and maximum size on a window would cause some
compositors to raise a protocol error.

Pick-to: 6.2 6.3
Fixes: QTBUG-102626
Fixes: QTBUG-103391
Change-Id: I4004a4550a9fe3dae6a27169b4d1a9a616e21841
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-05-23 10:54:27 +02:00
Thiago Macieira
737c940ebb CMake: use the --build-macro option to qtwaylandscanner
So we get correct exports different from imports, which are required for
GCC 12 with -mno-direct-extern-access and protected visibility.

Change-Id: If05aeeb7176e4f13af9afffd16e856de1f4f68d6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-05-19 23:00:35 -07:00
Thiago Macieira
949b3f731c qtwaylandscanner: add a way to use an build macro in the generated code
Change-Id: If05aeeb7176e4f13af9afffd16e85611ff7c42f2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-05-19 23:00:29 -07:00
Thiago Macieira
38d6f09d30 Replace QScopedPointer with std::unique_ptr
As the warning asked.

qwaylandshellintegrationfactory.cpp:67:28: warning: ‘T* QScopedPointer<T, Cleanup>::take() [with T = QtWaylandClient::QWaylandShellIntegration; Cleanup = QScopedPointerDeleter<QtWaylandClient::QWaylandShellIntegration>]’ is deprecated: Use std::unique_ptr instead, and call release(). [-Wdeprecated-declarations]

As a drive-by, change *foo.get() to *foo.

Pick-to: 6.3 6.2
Change-Id: I7fb65b80b7844c8d8f26fffd16e97fe161d6a67a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-05-11 21:00:44 +00:00
Janne Juntunen
aedb14b232 client: Mark return values as unused to suppress compiler warnings
Return values of two write() functions were ignored, causing warnings
which were treated as errors on webOS emulator build.

Fixes: QTBUG-103378
Pick-to: 6.3
Change-Id: Ifc2e944dee376973b69220b7f75dc346c0a71e71
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-05-11 15:20:16 +03:00
Thiago Macieira
66217476bb QtWaylandClient: use the CMake exports.h support
The one in qtwaylandglobal.h was wrong. It just happened to work on
Linux because the lack of import wasn't an error... until GCC 12 with
-mno-direct-extern-access.

Pick-to: 6.3
Change-Id: If05aeeb7176e4f13af9afffd16e8535b469f9158
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-04-28 20:57:04 -07:00
Tang Haixiang
27c6c16743 Use QPlatformWindow's API as much as possible in QPA
When using highdpi, window->geometry != platformwindow->geometry.
In QPA we should use QPlatformWindow's API.

Fixes: QTBUG-102601
Change-Id: Ib4ff2edbc045cf441cd2d594d502875417eb4917
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-04-20 08:32:42 +00:00
Kenneth Topp
bb2788d9f7 use poll(2) when reading from clipboard
change clipboard read away from select(2) call which can fail when
an application has large number of open files

Change-Id: I6d98c6bb11cdd5b6171b01cfeb0044dd41cf9fb5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-04-14 17:00:06 -04:00
Liang Qi
179d0d34fa client: Synthesize enter/leave event for popup in xdg-shell
Fixes: QTBUG-100148
Pick-to: 6.3 6.2 5.15
Change-Id: I45e3156d7942cff9968674c0b253d15be7235921
Reviewed-by: Tang Haixiang <tanghaixiang@uniontech.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-04-04 11:01:49 +01:00
Kai Köhne
dd83a27fec Fix format of qt_attribution.json files
Also fix a typo in the license name.

Amends db3df0b3b439a

Pick-to: 6.3.0 6.3
Fixes: QTBUG-102148
Change-Id: Ic231a4b744864c19190d428a9a2fc5101ffa77f0
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-03-31 18:55:48 +02:00
Liang Qi
b3395051bf client: add ScreenWindowGrabbing capability
On Wayland, there is no protocol to do it yet.

Task-number: QTBUG-100792
Task-number: QTBUG-101145
Change-Id: I4bfef2920547babf0ccc00a27062d0db77ae5b7f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-24 10:23:43 +01:00
David Edmundson
e228149142 client: Avoid trying to read/cancel read if wl_display_read_events failed
wl_display_prepare_read and
wl_display_read_events/wl_display_cancel_read must come as matching
pairs. Otherwise we set libwayland's internal read count to a negative
number and causes all types of deadlocks. If prepareReadQueue fails but
we haven't explicitly quit waitForReading returns a success statement
but we haven't opened anything.

Pragmatically most times wl_display_prepare_read fails it's because of a
wayland error which is handled by exiting anyway, but it is better to
err on the side of safety.

Change-Id: Ia29c3217622d97594404be3daf4c50338a1d3fb0
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-03-23 12:36:21 +00:00
David Edmundson
fe472ee0f4 Client: Fix up thread usage for mSurface
It didn't make sense that mSurface was protected, but the mutex
was not. Also try to improve documentation.

Change-Id: I2f59557cccbb2d6f0b2772ce3c8a2dab01167a6c
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-03-22 16:09:48 +00:00
Liang Qi
b72632e01e tests: fix DefaultCompositor::surface() when index > 0
This amends c98bbc549557b1e0e7c972687ac2760204dff2a5.

Pick-to: 6.3
Change-Id: Id0759ebab699d762c134246d0ec9f72b03923bac
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-03-22 10:18:49 +01:00
Paul Olav Tvete
b41a7e47ee Fix race condition on mWaitingForUpdateDelivery
Change-Id: I0e91bda73722468b9339fc434fe04420b5e7d3da
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-03-21 14:40:34 +00:00
Paul Olav Tvete
eddb08768f Revert "Client: Remove mWaitingForUpdateDelivery"
The reverted commit introduces a severe performance regression
when a client window is resized while a QtQuick renderthread
animation is running.

This reverts commit e625089f40ab5b2f3220a9ffc3e047d1c3fc2740.

Fixes: QTBUG-101726
Change-Id: Ib5b52ce06efec8c86fada1623c2af82099e57fc6
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-03-21 15:40:30 +01:00
David Edmundson
077df2acef Guard mResizeDirty by the correctMutex
mResizeDirty is used in the GUI thread in setCanResize which can be
called from the GUI thread. It is queried and set whilst the resizeLock
is held. We need to guard our usage.

Change-Id: I5f8dcf8aa2cb2c4bb6274103df1da9e3e268605a
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-03-17 10:49:25 +00:00
Fabian Kosmale
d9c88ebb91 wayland: do not rely on transitive includes
Change-Id: I149e04d31ef3e897e25a91450427237069af4c34
Reviewed-by: Liang Qi <liang.qi@qt.io>
2022-03-11 12:48:43 +01:00
Liang Qi
945ffa2fd7 client: update button state and etc in pointer_leave()
The cleanup work needs to be done even the surface is null, for
example, a window was closed in mouse press handler, then will not
get a mouse release.

Fixes: QTBUG-100942
Pick-to: 5.15 6.2 6.3
Change-Id: I637a6744909ddbe62bdeba6b21494e5a6ae7fa9f
Reviewed-by: Tang Haixiang <tanghaixiang@uniontech.com>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-03-10 11:35:33 +01:00
David Redondo
b285a1d8af Add globalRemove to QWaylandClientExtension
Adds support for handling of removal of the relevant global to
QtWaylandClientExtension. The user is responsible for destroying the object
once it becomes inactive to match the behavior on destruction.
Two signals for globals and their removal are added to QWaylandDisplay
to make it a bit nicer to use in a more "Qt-way". The addRregistryListener
function is kept for now until other places are ported.

Change-Id: I4ccbaa32e18a5ae15871aa23639e2b4a372cc34e
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-03-09 15:30:01 +01:00
Thiago Macieira
2ddd1eca36 Make sure all private headers include at least one other
See script in qtbase/util/includeprivate for the rules.

Since these files are being touched anyway, I also ran the
updatecopyright.pl script too.

Change-Id: Ib056b47dde3341ef9a52ffff13ef677e471674b6
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-03-08 08:06:44 -08:00
Liang Qi
6d1d6ebb60 client: set_constraint_adjustment() for popups in xdg
See also https://cgit.freedesktop.org/wayland/wayland-protocols/tree/stable/xdg-shell/xdg-shell.xml#n234 .

Kudos to Greg V for his original patch in jira.

Fixes: QTBUG-87303
Pick-to: 5.15 6.2 6.3
Done-with: Greg V <greg@unrelenting.technology>
Change-Id: I57df9aedea7cc6f0b6fa142a6fc6c3bdc98324c8
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-03-08 13:11:07 +01:00
David Redondo
9acb30b224 Allow creating popups from non xdg-shell parents
It's possible to create xdg-popups with a null parent and set a parent
via some other protocol. This will be useful for the work of allowing
multiple shells in one process.

Change-Id: I1fb9035be4b3999ff284bcc5c60eb4142cee1294
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-03-08 12:55:18 +01:00
Eskil Abrahamsen Blomfeldt
3345c04e24 Add attribution for text-input v1 protocol
This was not added together with the protocol. This change also
disambiguates v1 and v2 as two separate entries, since the
licenses are different.

Change-Id: I2309aced67ae69bc2d8117688e5d7b1074e8bf8f
Reviewed-by: Dominik Holland <dominik.holland@qt.io>
2022-03-03 15:14:42 +01:00
Eskil Abrahamsen Blomfeldt
4878afdd37 Update 3rdparty attributions
The XDG activation protocol was added with no attribution and
the Wayland protocol version was updated without updating the
version in the XML.

Pick-to: 6.3
Fixes: QTBUG-100901
Change-Id: Ifaaf69b7d498ea7106d4bfd6ada978475447d296
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
2022-03-03 07:28:44 +01:00
Ulf Hermann
a1a671eb95 Reduce memory leakage
We need to clean up the event queue when we're done.

Change-Id: I13a9eb77e978f4eab227a3a28dab8ebc8de94405
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-02-23 09:33:21 +01:00
Vlad Zahorodnii
a4647c1f15 Client: Fix opaque region setter
The rect is in the global coordinate system, while the opaque region
must be in the surface local coordinate system.

Change-Id: I75042b4d779dfd4dfe610aad1f0387879f11b048
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
2022-02-21 09:05:50 +02:00
David Edmundson
610e084250 client: Simplify round trip behavior
The custom event queue was removed in
d49cd790d8525071f6613066caf5e8dd2f5ca980 (2015) so the comment about not
being able to use the inbuilt round trip method no longer applies.

This fixes a real world problem. Use of a blocking round trip should not
process non wayland events. Doing so can lead to misbehaviour client
side as things happen out of order. The move to the event thread created
several regressions as we now get events before the QGuiApplication is
fully constructed.

Change-Id: I650481f49a47ed1a9778c7e1bc3c48db6e8f0031
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-02-14 09:46:49 +00:00
Weng Xuetian
651d6dcfe3 Update the preedit styling mapping
- None mapping to no style.
- Default/Underline mapping to underline.
- Highlight/Selection mapping to background color/text color with highlight/highlight
text with underline.
- Active/Inactive mapping to bold text with underline.
- Incorrect mapping to red wave underline.

Pick-to: 5.15 6.2 6.3
Change-Id: Iab51d671b8f83aece8596f7f7610de19343fcceb
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
2022-02-12 07:27:32 -08:00
Weng Xuetian
0f2af27045 Cursor position == 0 should still show the cursor
Otherwise the cursor would be hidden even if preedit is empty.
Amends 8b3de53ee666c8ea16c735180a7305df2494b16a

Pick-to: 5.15 6.2 6.3
Change-Id: I320733b917779b7b51aa4a28eaea411fdb10a318
Reviewed-by: Liang Qi <liang.qi@qt.io>
2022-02-12 15:27:24 +00:00
Marc Mutz
40051c3388 tst_inputcontext: fix warning about unused lambda capture
Says Clang 10:

  tst_inputcontext.cpp:194:11: warning: lambda capture 'this' is not used [-Wunused-lambda-capture]
    exec([this] {
          ^~~~

Code was added for 6.3, so only:

Pick-to: 6.3
Change-Id: I3818d1707e917c2c804d4ab0349e48667cf4a126
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-11 23:56:14 +01:00
Inho Lee
f9f086e8cb Update the window geometry when changing decorations
Windows' geometries should be updated when changing decorations.

Fixes: QTBUG-100467
Pick-to: 6.3 6.2 5.15
Change-Id: I5ec9968aa48422776d184a8fa2f5d86ecc3ca5c3
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2022-02-09 19:23:01 +01:00
Inho Lee
0bbff7ff60 Do not delete window decorations before next update
When window decorations are turned on/off, a timing issue might happen
with accessing deleted decorations.
A boolean value, mWindowDecorationEnabled, will be used instead of
mWindowDecoration.

Pick-to: 6.3 6.2
Fixes: QTBUG-59627
Change-Id: I5514a408d89340fdbf481721ea2dc4bf62078852
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-02-09 12:19:06 +01:00
Shawn Rutledge
699770b7c7 Fix unused warnings
Unused lambda capture and private variables that clang complains about.

Pick-to: 6.2 6.3
Task-number: QTBUG-100249
Change-Id: I204eea8d4fc0c22542224d94bae113fa66870d15
Reviewed-by: Liang Qi <liang.qi@qt.io>
2022-02-09 09:24:59 +00:00
Vlad Zahorodnii
e625089f40 Client: Remove mWaitingForUpdateDelivery
Currently, mWaitingForUpdateDelivery is shared between the main thread
(doHandleFrameCallback()) and the frame callback event thread
(handleFrameCallback()), however the access to it is not synchronized
between both threads. On the other hand, QWaylandWindow
already ensures not to create a frame callback if there's already one
pending.

This change removes mWaitingForUpdateDelivery flag because it should be
already covered by mWaitingForFrameCallback and to remove unsynchronized
shared state between threads.

Change-Id: I0e5a25d18d1e66c4d7683e7e972330c4d7cbbf38
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-02-08 16:43:51 +02:00
Christophe Giboudeaux
fcf3fc37a4 CMake: Fix qtwayland feature detection
The dmabuf_server_buffer test links to EGL and libdrm and the vulkan_server_buffer
one needs to link to wayland-client

Fixes: QTBUG-100475
Pick-to: 6.3 6.2
Change-Id: Idbcef88bba0a9d5ef7bfeaa55668c94caee6ab83
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-04 23:15:52 +01:00
Joni Poikelin
cdc1b7ab94 Fix crash if no input method module could be loaded
Pick-to: 6.2 6.3 5.15
Change-Id: I8f346def616606a6c5540856bd08a84ee7ed5ca2
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-02-03 14:53:42 +02:00
Dominik Holland
a0b4d3e947 Add client support for the text-input-unstable-v1 protocol
This is used by weston for forwarding virtualkeyboard related
event from keyboard applications to a Qt client.

Right now Qt only supports text-input-unstable-v2, v4 and the
special qt-input-method protocol, while weston only supports
text-input-unstable-v1.

Without this, a virtual-keyboard application can't be used
with a Qt client within weston.

Change-Id: I9a34a87100854bb0b0f76762ced56419e70c297e
Reviewed-by: Inho Lee <inho.lee@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-02-02 13:02:17 +00:00
Youngjin Kim
2e6aed4ffd Use scope resolution operator for request
If the combination of the name of the protocol interface and the name of
its request is same as another interface name, it can cause problem in
calling the constructor instead of method generated by wayland-scanner
when calling request.
For example, if you have an interface named "foo" and its request named
"bar", it might conflict with another interface named "foo_bar".
A real example for this is presentation_time protocol which has
a request "feedback" in the interface "wp_presentation" while it also
has another interface named as "wp_presentation_feedback".

Pick-to: 6.3
Change-Id: I7c007978d4aa404d10441643d5461372f33954e5
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-02-02 18:36:01 +09:00
Liang Qi
290f345d84 Fix build with -no-feature-tabletevent
Pick-to: 6.2 6.3 5.15
Fixes: QTBUG-99965
Change-Id: Ib7fcf92973b4e559713ae27ad0c7f843f9122daf
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-01-25 17:09:01 +01:00
Seokha Ko
3047afe05f Fix wayland touch event to use time stamp from wayland compositor
Touch events may be ignored if we set time stamp in handleTouchEvent()
when handling touch events queued in wayland socket in main thread.
So use time stamp from wayland compositor.

Task-number: QTBUG-100150
Pick-to: 6.2 6.3
Change-Id: I14fd3791b4d29177c71662d1cf26c0eed0abb767
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Seokha Ko <seokha.ko@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-01-25 12:17:56 +00:00
Thiago Macieira
199b82b5cf XDG shell: fix warnings about unused variable
qwaylandxdgshell.cpp:508:15: warning: unused variable ‘activation’

Pick-to: 6.3
Change-Id: I0e5f6bec596a4a78bd3bfffd16c995a0b7feef5c
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
2022-01-21 18:44:26 +00:00
Alexandru Croitor
92bbd0921e CMake: Ensure qt_cmdline.cmake files exist for each configure.cmake
Otherwise the configure script won't understand command line options
like -no-feature-egl-extension-platform-wayland because the
subdirectory configure.cmake files are only loaded by the configure
script when there are accompanying qt_cmdline.cmake files.

Pick-to: 6.2 6.3
Fixes: QTBUG-99802
Change-Id: Ifd6ea6f366ac5fe09a9eafe3be7d889044caa52f
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2022-01-21 11:09:27 +01:00
Tang Haixiang
1df3c996e8 wayland touch event to add key modifier
Add touch event keyboard modifier for wayland, which is done in qpa
xcb, which is very convenient on tablets with keyboards.

Change-Id: I4e6ed369f3444da41d06f9a9a83addf7de0a4e91
Reviewed-by: Povilas Kanapickas <povilas@radix.lt>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2022-01-17 09:15:30 +00:00
Cathy Park
05fefdbf57 client: Add waitForFrameSync for Vulkan
Frames are processed by mFrameQueue in Qtwayand. However, in vulkan
backend, frames are sent by handleUpdate() but waitForFrameSync()
is not called which should handle frames in mFrameQueue.
For the current vulkan backend, frames are only handled by drivers
like mesa. So in the current vulkan backend, some particular animations
don't run or are slow because frames sent by qtwayland are not being
handled.

Fixes: QTBUG-96222
Change-Id: Ifbab385ca619ef9461104eb8bd778f17093a56b5
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: YoungSun Park <cathy.park@lge.com>
2022-01-03 16:46:38 +09:00
Eskil Abrahamsen Blomfeldt
1a2e499e0e Fix missing update when toggling client-side decorations
When CSD is toggled while a window is showing, it would change the
size and recreate the buffers, but since the widget area remained
the same size, we would not trigger a redraw. The result was that
when you got any update to the window, it would redraw the widgets
that had changed, and the rest would be transparent.

Since this is a fairly specialized case, we fix it the simple way,
by just issuing an extra update when it happens.

This also required an update to the surface test, since there is
an additional buffer commit in the beginning of the sequence now.

Pick-to: 5.15 6.2 6.3
Fixes: QTBUG-95032
Change-Id: Ic4bdb9c66a2ea76546926dd622f2d2dac5dce10c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2021-12-21 12:04:15 +01:00
Eskil Abrahamsen Blomfeldt
46991c54c8 client: Fix crash on shutdown on Mesa driver
On Wayland, then the mesa driver is in use, calling
eglDestroySurface() while OpenGL commands are being
executed may crash. While this means the driver does
not operate by the specs in this case, the driver is
so popular that it makes sense to work around it.

To work around this, we read-lock the surface while
rendering and wait for a write-lock before we destroy
the EGL surface.

[ChangeLog][QtWaylandClient] Fixed a crash on shutdown that could
happen with some graphics-heavy applications when running on Mesa
drivers.

Pick-to: 6.3
Fixes: QTBUG-92249
Change-Id: I8b8461066cc9f948dc44ddeeddaa6e7d92b76f04
Reviewed-by: Liang Qi <liang.qi@qt.io>
2021-12-21 11:21:25 +01:00
Weng Xuetian
8b3de53ee6 Set preedit cursor when cursor equals to 0
Pick-to: 6.3 6.2 5.15
Change-Id: I832fbb22d973b36ac4ab51570fc53bc2e4c3ed58
Reviewed-by: Liang Qi <liang.qi@qt.io>
2021-12-20 10:31:15 +00:00
Liang Qi
1616b042bb Client: support high-dpi mode for window icon
Fixes: QTBUG-90530
Pick-to: 6.3 6.2 5.15
Change-Id: Ib1f36e1cb89352dfac8a385a7b097cfc0226e813
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-13 13:28:51 +01:00
Elvis Lee
39388b160c Support presentation-time protocol
With the protocol, client knows accurate presentation timing
which can support vsync-based rendering for smooth video
playback with video/audio synchronization.

Also, the protocol provides metrics from client to on-screen
for optimizing frame latency.

Tested with weston-presentation-shm client which also requires
xdg shell.

Change-Id: I3b286420e7221aa1c9b81bf7ae9ae70d3cbe6eb6
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-12-10 19:02:09 +01:00
David Redondo
ea49c2e19d Handle the transientParent of a window having another kind of surface
Useful for the current work of allowing multiple shells in one process.

Change-Id: I68424687df9069fd4339f2764649db1df70a6c9a
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-12-09 17:59:25 +01:00
Paul Olav Tvete
c31a609bbd Remove QWaylandShellIntegration::findGlobal
This is no longer necessary now that the recommended way of creating
custom shells is to use QWaylandShellIntegrationTemplate. This also
restores the old internal API in use by existing shells.

Task-number: QTBUG-94330
Change-Id: I0fa0ba0d928baa2edf5d68e879558081026436c8
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-12-09 13:57:23 +01:00
Arjen Hiemstra
18df960499 Client: Delay deletion of QDrag object until after we're done with it
In certain cases, most notably when performing drag and drop operations
with touch, the QDrag object gets deleted before data_source_send is
executed. This then tries to access a deleted data_source, crashing the
client.

To avoid this, we indicate we want the QDrag object to stay around and
then delete it in QWaylandDrag::finishDrag, which with data_device v3 is
guaranteed to be called after everyone is done with the data source.

Change-Id: I6a2f5a219f58d1b721a9fec33c57d26d2c522ec9
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-12-09 13:57:23 +01:00
Aleix Pol
3bf9a581ee Implement xdg_activation_v1 protocol
Change-Id: Ib5c8d0c6a209308c2c1a7f5e45d8866ba0127d81
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-12-09 10:33:08 +01:00
David Edmundson
30fecf220d Client: Implement DataDeviceV3
DataDeviceV2 fixes a leak of DataDevice resources.

DataDeviceV3 brings multiple improvements:

Action negotiation. The source announces which actions are supported,
the target then announces which subset of those action the target
supports and a preferred action. After negotiation both the source and
target are notified of which action is to be performed.

Drag sources are now notified when contents are dropped and when a
client has finished with the drag and drop operation.

A good test is the draggableicons example in QtBase.

Change-Id: I55e9759ca5a2e4218d02d863144a64ade53ef764
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-12-09 09:32:59 +00:00
Paul Olav Tvete
d89d826bb2 Remove the XComposite buffer sharing extension
These extensions were disabled because they did not work properly and they
are no longer very useful. It does not make sense to keep
non-functional code around when it is unlikely to be fixed.

[ChangeLog][Extensions][The xcomposite-egl and xcomposite-glx shell
extension protocols have been removed.]

Task-number: QTBUG-97985
Change-Id: I0ad37bd2b35551d7b2b1e5e7d4e77a51037864ad
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-12-07 12:25:13 +01:00
Inho Lee
2bd5d5f2be Use a correct serial for xdg_surface.ack_configure
Previous pendingConfigureSerial can be overwritten regardless of the
current configuration. With this patch, the client surface can use
correct serial for xdg_surface.ack_configure.

Fixes: QTBUG-95962
Pick-to: 6.2 6.1 6.0 5.15
Change-Id: I849d2daf4acc8ef6e7f8528af9c5a57f671f43e6
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-12-07 11:11:00 +02:00
Vlad Zahorodnii
caded7fb85 Client: Make xdg_output.name required only if it's supported
The xdg_output.name property is available only since version 2.

Fixes: QTBUG-98010
Pick-to: 6.2
Change-Id: I1051b8e9d99fe27f0170ea202deac9cdad9818ae
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-12-03 06:56:42 +00:00
David Edmundson
06f069bed8 Client: Upgrade Seat support to v7
- Finish implementing support for axis_wheel_tilt. Some code existed
already, hence only debug and unit test are changed

- The unit test is renamed to seat as the only change is new events.
There is nothing deprecated and therefore no need to test backwards
compatibility.

- Set our supported version number to 7

No version bumps of libwayland are needed, our current minimum version
includes wl_seat v7.

Task-number: QTBUG-96258
Change-Id: Ief18bc5cef3fcbd0699dd52ccad513d47c6c010b
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-12-02 23:35:04 +00:00
Thiago Macieira
715a39f026 Q*FActory: remove unused path arguments
Cargo-culted from somewhere but not used in any of these classes. This
just made the code bigger for no reason.

Also take the opportunity to make it work with !QT_CONFIG(library),
which apparently no one bothered to try because it clearly didn't
compile. Not that I have tried either...

Task-number: QTBUG-97950
Pick-to: 6.2
Change-Id: Ice04365c72984d07a64dfffd16b48632888ed664
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2021-12-02 09:02:23 -08:00
David Edmundson
fbba12d7db Client: Avoid processing of events when showing windows
The only time we want to dispatch events from the wayland socket is when
the application is waiting for external events. Doing so at any other
time will cause unpredictable behavior in client code.

This caused a crash downstream where we had outputs get altered whilst
itterating through outputs, which shouldn't happen.

There is no benefit to flushing here, it won't make anything appear
faster as we haven't attached the buffer yet.

Change-Id: Ie13eae4012dab96a93d8810f468d1343402b8c28
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
2021-12-02 12:07:31 +00:00
David Edmundson
37e3c0ff45 Update wayland.xml to version 1.19.0
This updates only the protocol definition, implementations
will need additional commits to opt into using them.

Change-Id: I67d6b011e6192ae99f526a16325150eb26cc9236
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: David Redondo <qt@david-redondo.de>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-12-02 10:57:50 +00:00
Paul Olav Tvete
a7bb7210ac Introduce new qt-shell and an API for custom shells
Adds a new API for writing custom shell extensions. This API is supported,
but semi-public. Binary compatibility is not guaranteed.

Also adds qt-shell, a new shell that maps directly to the QWindow API, and
provides functionality that Qt provides on other window systems, such as
absolute window positions and window activation. This shell is not intended
for use on the desktop.

This is a squashed commit of a development branch consisting of approximately
60 changes. Contributors:
  Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
  Paul Olav Tvete <paul.tvete@qt.io>

Task-number: QTBUG-94330
Task-number: QTBUG-91542
Change-Id: I419b6bd8179fe03e4da47d328c7ff4b4795b8a91
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2021-12-02 09:08:40 +01:00
David Redondo
0a8d63ea67 Only return modifiers if we have focus
If we don't have focus, we can't infer anything about the state of
keys.

Change-Id: I773a3d7768abe6d595f0ffbc279d61a47c27ea24
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-11-29 15:27:06 +02:00
Inho Lee
ef140369ba Support text-input-unstable-v4-wip
This feature can be enabled by -feature-wayland-text-input-v4-wip.
It is disabled by default.

TextInputManagerV4 is available in a compositor.
zwp_text_input_v4 is available for QT_WAYLAND_TEXT_INPUT_PROTOCOL in
a client
It supports Hangul(Korean) with a qtvirtualkeyboard patchset
(refs/changes/02/357902/3)
It includes some workarounds for ibus because each ibus module has its own
policy for focus-in/focus-out.
enter/leave will synchronize with enable/disable and they will happen
whenever focus-in/focus-out happen.
Cursor/anchor positions are byte offsets.
Surrounding text will be trimmed when it is over 4000 byte.

For debugging,
uses "qt.waylandcompositor.textinput" in a compositor side
uses "qt.qpa.wayland.textinput" in a client side

Tested on qtvirtualkeyboard and ibus

TODO :
 * QTBUG-97248 - event:preedit_commit_mode is not implemented yet. Current
    preedit_commit_mode is 'commit'.
 * request:set_text_change_cause is not implemented.

Task-number: QTBUG-94327
Change-Id: I72644893f40f30c4b03cd6a7d05483d12bde1070
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-11-19 10:33:31 +01:00
Marc Mutz
a420bc6a63 tst_seatv4: fix compilation with GCC/C++20
Explicitly defaulting the default ctor suppresses aggregate
initialization. It's also a pointless thing to do, so don't do it.

Pick-to: 6.2 5.15
Change-Id: I8ec14f22ae1ead2dd6db643a6462f719fda344b8
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-11-16 18:13:37 +01:00
Marc Mutz
46e42b89b8 tst_seatv4: fix deprecated implicit capture of this by [=]
Since exec() is a synchronous call, we can just take everything by
reference instead.

Pick-to: 6.2 5.15
Change-Id: Ic1588db69ed6bb0d8dd39ff0439ad0fc97dd957f
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-11-16 17:13:16 +00:00
Inho Lee
0e198e55a7 Do not create decorations when the shellSurface is not ready
A cases reported that client windows try to make decorations
when their shell surfaces are null.
Since the surfaces' requests for decorations should be applied,
those case will be failed to create decorations.

This patch was modified by Paul Tvete's advice.
(paul.tvete@qt.io)

Pick-to: 6.2 5.15
Task-number: QTBUG-97608
Change-Id: I2563dbd73b730f81cc411857af07da99ceb2d063
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2021-11-12 10:07:14 +01:00
Liang Qi
80600c9f3d Clean up some qDebug() which are not intended
This amends 636d52abb37abd400407a564ec8ab1f355cf9766.

Change-Id: I7dbd06b75d994d4957f0fbafed2f708f900a949d
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Inho Lee <inho.lee@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-11-11 13:19:34 +01:00
Paul Olav Tvete
bc6f446738 Don't build XComposite buffer integration by default
Both xcomposite-egl and xcomposite-glx have rendering issues, and they
do not work with the latest Nvidia driver versions.

These plugins were created to allow testing/debugging of QtWayland-based
compositors on desktops that did not support Wayland natively. At this
time, Wayland is much more widely supported on the desktop, and

[ChangeLog][Extensions][The xcomposite-egl and xcomposite-glx shell
extension protocols are no longer built by default.]

Task-number: QTBUG-92074
Task-number: QTBUG-97985
Pick-to: 6.2
Change-Id: Ifded68b92e91e2d98aa44b8cfc624a4072b30451
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
2021-11-11 09:06:42 +01:00
Liang Qi
636d52abb3 tests: add test for multiple text input
Change-Id: Ief343ebf9d0d6d00533eb3c698c416f4205bbfac
Reviewed-by: Inho Lee <inho.lee@qt.io>
2021-11-09 12:07:31 +00:00
Inho Lee
81fa930ca1 Refactor QT_WAYLAND_TEXT_INPUT_PROTOCOL
Redundant logics are moved from registry_global.
QT_WAYLAND_TEXT_INPUT_PROTOCOL works with priority.
If QT_WAYLAND_TEXT_INPUT_PROTOCOL is empty or invalid,
    the order of priority is qt_text_input_method_v1;zwp_text_input_v2

Task-number: QTBUG-96414
Change-Id: I1601091782ee63a57cbc678604b604d0ea287ccd
Reviewed-by: Liang Qi <liang.qi@qt.io>
2021-11-08 12:15:09 +02:00
Inho Lee
0c434b3537 add abstract class QWaylandTextInputInterface in client side
There are several protocols for text-input and it will be an abstract
class for them. It is not related with qt_text_input_method_v1.
It will help to implement zwp_text_input_* protocols.

Change-Id: I2207887d84d416469217cff7d011648402a53664
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-11-08 11:19:56 +02:00
Thiago Macieira
b2b710ba7a CMake: remove results for tests not tested
This amends 19281f9c3ba64adf1b6ffce88bd8da3da28beb1c.

Pick-to: 6.2
Change-Id: Ice04365c72984d07a64dfffd16b1f0fe50e083f1
Reviewed-by: Liang Qi <liang.qi@qt.io>
2021-11-03 10:35:17 +00:00
Liang Qi
eeaf852d48 client: emit QInputMethod::visibleChanged() for qt_text_input_method_v1
Also emit keyboardRectangleChanged() when necessary.

This amends 6578795ab5de18d1a39c3a31c619a4414eca7453 .

Pick-to: 6.2
Fixes: QTBUG-96298
Done-With: Paul Olav Tvete <paul.tvete@qt.io>
Change-Id: I5095f9b921f85851c7525d45fe6f8fe219c963fb
Reviewed-by: Inho Lee <inho.lee@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-10-28 12:57:38 +00:00
Liang Qi
dcac8ed7df Support different text input protocols - update
This amends 227ea40b804c9093e9cfdc88c6acdab730b7d878.

Only update text input when needed. And try to unregister the ones
which are not needed.

For client side, when QT_WAYLAND_TEXT_INPUT_PROTOCOL contains
multiple valid ones, the order doesn't matter now.

Fixes: QTBUG-97394
Task-number: QTBUG-96414
Change-Id: Ibe174056a4d4a4f2026e488d2ea99ec875b11ccc
Reviewed-by: Inho Lee <inho.lee@qt.io>
2021-10-20 13:02:49 +00:00
Liang Qi
c98bbc5495 tests: support ivi-shell again in tst_client
This amends 4767e91f7bd32ee6ffc7701035f430e453b99784.

QT_WAYLAND_SHELL_INTEGRATION=ivi-shell ./tst_client

Task-number: QTBUG-96440
Change-Id: I3c6d06e978c9aab3a2a61797fe359e0b1e90df17
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-10-19 10:22:59 +02:00
Giulio Camuffo
468ac1fefb Move the wayland socket polling to a separate event thread
New event threads is introduced which calls poll() on the wayland fd,
instead of relying on the event dispatcher by using the QSocketNotifier.
This allows to call in the proper order the wl_display_prepare_read(),
poll() and wl_display_read_events() functions.

One thread is responsible for the default queue; when needed, it emit
a signal so that the main thread can dispatch the queue. Another thread
is responsible for the dedicated queue for frame callbacks; this thread
will dispatch events on the thread itself.

QWaylandWindow is updated to, instead of each window's dedicated event
queue, use this queue for frame callbacks.

Co-authored-by: Ratchanan Srirattanamet <ratchanan@ubports.com>
Task-number: QTBUG-66075
Change-Id: Ibb33ad7f4193b866d1b8d7a0405a94d59dcad5eb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-10-18 16:28:52 +07:00
Rodney Dawes
201af1b56b Fix the logic for decoding modifiers map in Wayland text input protocol
Correctly check for the flags in the modifiers map when we get it from
the compositor, instead of modifying the map in the for loop conditional.

[ChangeLog][QWaylandInputContext] Fix modifiers map decoding
logic when receiving the map from the compositor.

Fixes: QTBUG-97094
Pick-to: 6.2 5.15 5.12
Change-Id: Idad19f7b1f4560d40abbb5b31032360cfe915261
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2021-10-15 08:50:09 -04:00
Joerg Bornemann
36f4cf3900 Skip unnecessary commands when cross-building tools
Call qt_internal_return_unless_building_tools() directly after
qt_internal_add_tool() to avoid having to special-case code for when
this function only creates imported targets in cross-builds.

Task-number: QTBUG-85084
Change-Id: I1830d4e2b9006d1f789ec4889a01bbb66f63ff11
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-10-07 13:16:32 +02:00
Liang Qi
227ea40b80 Support different text input protocols
from clients and one compositor at same time.

For compositor side, just need to have TextInputManager and
QtTextInputMethodManager together.

For client side, set QT_WAYLAND_TEXT_INPUT_PROTOCOL env to choose:

* If the env is unset(empty) or invalid, it will search
qt_text_input_method_v1 and zwp_text_input_v2 in order
* Set as "qt_text_input_method_v1" or "zwp_text_input_v2" if compositor
supports
* Set as "zwp_text_input_v2;qt_text_input_method_v1"

Change-Id: Ieec293ff412bf2d3e5ca9c69a951bfe1899cc808
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-10-07 12:13:01 +02:00
Liang Qi
4767e91f7b tests: port tst_client to use shared folder
instead of shared_old

Task-number: QTBUG-96440
Change-Id: I1f9e04841b432937e47ed337b05fe96b2e0662fc
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-10-06 14:49:55 +02:00
Jan Grulich
5c9a38e768 Client: do not empty clipboard when a new popup/window is opened
If we open a new popup or a window within the same app we have to avoid
invalidating selection offer when losing focus, because it's still the
same client who has the focus and we might not get a new selection offer
by the compositor and therefore we would lose clipboard content.

Fixes: QTBUG-93474
Change-Id: Ia2ef826c2967b1daf1cdeb085e8dae66d090dbcf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-10-05 16:16:13 +02:00
Dominik Holland
4be0cbb5b3 Add explicit dependency to Libdrm::Libdrm for the client as well
Similar to the compositor, we can't rely that qtbase always has a
dependency to it.

Pick-to: 6.2
Fixes: QTBUG-96845
Change-Id: I2b5535c3cb57c8f2193800aac09e097d2b729ce2
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-10-05 12:28:40 +02:00
Méven Car
55d2590abf Wayland client: use wl_keyboard to determine active state
Commit d4d47f2a043f3e7548ba10c69fb54637511ba563 made QWaylandDisplay
use the xdgshell's active state for QWindow::isActive(), instead of
using wl_keyboard activate/deactivate events.

That seems to have been a misunderstanding, since xdgshell activation
is only supposed to be used to determine visual appearance, and there
is an explicit warning not to assume it means focus.

This commit reverts this logic back to listening to wl_keyboard.
It adds a fallback when there is no wl_keyboard available to handle
activated/deactivated events through xdg-shell, in order to fix
QTBUG-53702.

windowStates is handled so that we're not using the Xdg hint for
anything with QWindowSystemInterface::handleWindowStateChanged or
anything where we need to track only having one active.

We are still exposing it for decorations, which is the only reason to
use the Xdghint over keyboard focus - so you can keep the toplevel
active whilst you show a popup.

Change-Id: I4343d2ed9fb5b066cde95628ed0b4ccc84a424db
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-10-04 11:12:52 +02:00
Georges Basile Stavracas Neto
0a80b46583 Client: Always destroy frame callback in the actual callback
It's good hygiene to destroy all frame callbacks. Destroy the
frame callback and cleanup the mFrameCallback class member in
the callback itself. The callback destruction happens before
calling handleFrameCallback() to avoid the theoretical case
where another frame callback is queued by handleFrameCallback(),
and then immediately destroyed in the callback handler.

Change-Id: Ide6dc95e3402932c58bfc088a9d471fda821e9a1
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-09-27 02:38:50 -03:00
Georges Basile Stavracas Neto
d2a37a747c Client: Don't always recreate frame callbacks
The main QWaylandWindow method that is executed when handling updates is
QWaylandWindow::handleUpdate(). This method always, unconditionally queues
a frame callback, regardless of whether any other one is already queued.

On some circumstances, e.g. when a window is hidden or completely obscured
by other windows, it stops receiving frame callbacks from the compositor.
However, QWaylandWindow would continue to request for them, which eventually
fills up the Wayland socket, and causes the application to crash.

This can be avoided by checking if the platform window is already waiting
for a frame callback, before queueing another one.

In QWaylandWindow::handleUpdate(), check if mWaitingForFrameCallback is true
before queueing frame callbacks, and early return if that's the case.

The XDG-shell test needed to be updated for this: The mock compositor is
not responding to any frame callbacks, so the window will be unexposed,
no longer get paint events and therefore not trigger any commit. This
worked by accident before because we were issuing updates quickly enough
to reset the timer before it had a chance to unexpose the window. The
easiest fix is just to disable the dependency on frame callbacks in
this test, since that is clearly not what it's testing.

Task-number: QTBUG-81504
Change-Id: Ieacb05c7d5a5fcf662243d9177ebcc308cb9ca84
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Georges Basile Stavracas Neto <gbsneto@gnome.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-09-27 06:54:39 +02:00
Paul Olav Tvete
430ab36bb4 Wayland client: Don't applyConfigure for destroyed surface
If a window is rapidly hidden and re-shown multiple times, the configure
for a deleted wl_surface may be invoked after a new surface has been
created. This change makes sure we always reset mWaitingToApplyConfigure
before a new wl_surface is created. The superfluous applyConfigure
invocation will then be safely ignored.

Fixes: QTBUG-96464
Pick-to: 6.2
Change-Id: Ie2d718f77dc8de93674c6b86b5128c4f50414df1
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-09-24 11:57:53 +00:00
Paul Olav Tvete
8bedacb8d3 Wayland client: Fix crash when windows are shown/hidden during drag
Fixes: QTBUG-87624
Pick-to: 6.2 5.15
Change-Id: I1b9443df091878abcd4fbe9c55927cb819aebd59
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-09-24 11:57:48 +00:00
Alexandru Croitor
03ff403826 CMake: Bump almost all cmake_minimum_required calls to 3.16
Needed for subsequent change that will check and error out if the
version is lower than 3.16. We do that to ensure all policies
introduced by CMake up to version 3.16 have their behavior set to
NEW.

Pick-to: 6.2
Task-number: QTBUG-95018
Change-Id: I43575e48cb4ddb70b80f09e0432a2f88b01bec86
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-09-22 19:37:15 +02:00
Eskil Abrahamsen Blomfeldt
42ab2bfa61 Unskip tst_xdgshell::showMinimized()
This passes now, so re-enable it.

Change-Id: I2e0c40d5d2f3b6bb84f71f4ad192384f88e8e34e
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-09-22 14:11:14 +02:00
David Edmundson
60fb809a79 Client: map keyboard mapping privately
We are never going to write back changes into the compositor's keymap,
so there is no reason to have support for writing back to the
compositor.

V7 of the spec says:
"From version 7 onwards, the fd must be mapped with MAP_PRIVATE by the
recipient, as MAP_SHARED may fail."

Whilst we don't support v7 yet it is harmless to change this early.

Task-number: QTBUG-96259
Change-Id: I16afcae4aa89ff24955981e714096359d0a54792
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-09-08 16:39:23 +01:00
Craig Scott
66cbac0b30 Revert "Ensure versionless wrappers do not introduce a new variable scope"
This reverts commit 0402f082db34577c4ef38b8d4a7ae0ac2436568e.

Macros add another level of escaping that functions do not. The
conversion of the versionless wrappers to macros may alter the
behavior, so revert that change.

Task-number: QTBUG-96219
Pick-to: 6.2
Change-Id: I75d7223477894fd28c261ffb8476ab64f5b7d9be
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-09-06 18:48:28 +10:00
Craig Scott
0402f082db Ensure versionless wrappers do not introduce a new variable scope
Using function instead of macro prevented the wrappers from being able
to pass back any variables set by the wrapped function in the calling
scope. Prefer macros to avoid future changes which might do this from
silently swallowing such variable setting.

Task-number: QTBUG-96121
Pick-to: 6.2
Change-Id: I293999c8054c2572e9145974a9ffac661f70bf35
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-09-01 17:42:08 +10:00
Jan Blackquill
16d383ce68 Correctly detect if image format is supported by QImageWriter
The code queries potential image formats by stripping a mimetype of its
'image/' prefix and making the rest of the mimetype capitalised, such as
'image/png' -> 'PNG'. The problem is that this is then searched for in
QImageWriter::supportedImageFormats() by simple equality. The method
returns a list of lowercase byte arrays, not uppercase. As the codepath
can never match due to checking for an uppercase word in an array of
lowercase words, this means that images are effectively always sent as
BMP format, even if they should be sent in other formats, such as PNG
or JPEG.

A simple inspection with GDB (or a qDebug) reveals this:

```
(gdb) p QImageWriter::supportedImageFormats()
$31 = {"bmp" = {...}, "bw" = {...}, "cur" = {...}, "eps" = {...},
  "epsf" = {...}, "epsi" = {...}, "icns" = {...},
  "ico" = {...}, "jp2" = {...}, "jpeg" = {...}, "jpg" = {...},
  "pbm" = {...}, "pcx" = {...}, "pgm" = {...},
  "pic" = {...}, "png" = {...}, "ppm" = {...},
  "rgb" = {...}, "rgba" = {...}, "sgi" = {...},
  "tga" = {...}, "tif" = {...}, "tiff" = {...},
  "wbmp" = {...}, "webp" = {...}, "xbm" = {...}, "xpm" = {...}}
```

```
(gdb) p QImageWriter::supportedImageFormats().contains("PNG")
$32 = false
```

```
(gdb) p QImageWriter::supportedImageFormats().contains("png")
$33 = true
```

The fix for this is simple: lowercase the remainder of the mimetype,
instead of uppercasing it, and we can start hitting the codepath that's
supposed to write non-BMP formats.

Change-Id: Id3e9b730b7edcabcb2f1b04d8ef0a4c1fb9c9159
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-24 19:30:45 -04:00
Ulf Hermann
fba81e2346 Avoid memory leaks in QWaylandInputDevice
Use QScopedPointer and QObject-parenting to get rid of the allocated
objects.

Change-Id: I8a0ce2d1bae6a69b458a01731489813ef2aa8044
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2021-08-18 12:44:38 +02:00
Alexandru Croitor
2a966bcd13 CMake: Use renamed qt6_add_plugin PLUGIN_TYPE option
Task-number: QTBUG-95170
Pick-to: 6.2
Change-Id: I60fd4ef84fb4887294bde766790b279d12f1288a
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-08-09 14:48:27 +02:00
Joerg Bornemann
8c657f5819 CMake: Make WAYLAND_INCLUDE_DIR argument internal
As discussed in QTBUG-95177, this argument of
qt6_generate_wayland_protocol_{client|server}_sources is for internal
use only and should not be exposed publicly.

Rename this argument to __QT_INTERNAL_WAYLAND_INCLUDE_DIR.

Fixes: QTBUG-95177
Change-Id: I1437007b4bfd398372a932ec09a5eba0daa9af69
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-04 11:22:39 +02:00
Joerg Bornemann
6e14376d6d Fix building standalone examples with CMake
Building standalone examples with CMake failed with

    The following imported targets are referenced, but are missing:
    Qt6::WaylandGlobalPrivate

Fix this by recording the extra package dependency for WaylandClient and
WaylandCompositor.

This amends commit 46641fddcde3e658676a94f09d9cb4bd4e7289fb.

Fixes: QTBUG-95388
Change-Id: If6e1f3673dc59b1c50f25077677a21f7ff4f0cb7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-04 09:09:46 +02:00
Alexey Edelev
9ec8d463aa Adjust INTERFACE_MODULE_HAS_HEADERS property name
After introducing the _qt_module_has_headers target property, it's
better to replace the INTERFACE_MODULE_HAS_HEADERS use by
_qt_module_has_headers since properties duplicate each other.

Pick-to: 6.2
Change-Id: Ia1b35cc21bf31fce593c374d196aa450e6fd7e08
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-02 12:51:57 +02:00
David Edmundson
1b0445156d Client: Drop unused member variable
Change-Id: I9b3f1d1a2ff2e9658604778e1ab4b8b7c030e1ac
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2021-07-23 08:49:19 +01:00
Shawn Rutledge
a43bf3fc73 Use QPointF for native gesture delta values
Needed after qtbase e3aa45006dc883adb92b4c94a0108d3b75012dce and
de540c283d96630c189df9c9be37f68ad8285056.

Pick-to: 6.2
Change-Id: Ieb199eca9d550d9e8e4963458508a91ec9db1728
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-07-15 13:29:37 +02:00
Shawn Rutledge
cd995a7adf Improve categorized logging output
Change-Id: I8e4b48af21fe41bc76f83baa89e79a0e0fe8037c
Reviewed-by: Povilas Kanapickas <povilas@radix.lt>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-07-14 09:35:56 +02:00
Aleix Pol
c4b1dbfc06 Do not update the mask if we do not have a surface
mMask serves as a cache to remember what we've sent, the source of truth
for the value is window()->mask().
No need to store values that we are going to discard, because it will
confuse the state of newly created windows.

Change-Id: I6aa3da82c7f09c7ef90d0f7060f292fb042730f0
Pick-to: 5.15 6.2
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-07-13 15:36:15 +02:00
Joerg Bornemann
80c336554d CMake: Don't give plugins PUBLIC usage requirements
The pro2cmake.py conversion script faithfully reproduced the .pro files
for the plugins, which specified the libraries as public. But in CMake,
the implications of this are that public usage requirements should then
be propagated to consumers. We don't expect any consumers, since a
plugin is created as a MODULE library in CMake, so for Windows we don't
even have an import library to link with. The only exception to this is
for static builds where plugins are created as STATIC libraries
instead, but only in certain controlled situations do we then link to
plugins. Even then, usage requirements are not expected to propagate to
the consumers, so these relationships should always be specified as
private.

Pick-to: 6.2
Task-number: QTBUG-90819
Change-Id: Ia7a8f27d4eecf067055511577ec664ad857905cd
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-06 21:06:01 +02:00
Joerg Bornemann
46641fddcd Restructure configure features
Create a new module WaylandGlobalPrivate that is merely a collection of
build features that are shared by client, compositor and plugins of
qtwayland.

Move the features wayland-client and wayland-server to
WaylandGlobalPrivate to be able to access both features in
src/CMakeLists.txt. This removes the need for explicitly including the
configure.cmake files of client and compositor, which fixes QTBUG-88261.

Move the features that are defined in both, client and compositor, to
WaylandGlobalPrivate.

The module is defined in src/CMakeLists.txt to ensure that the
targets created by the qt_find_package calls in src/configure.cmake are
accessible in subdirectories below src/.

We need the (nearly) empty src/global directory to satisfy syncqt.
We cannot pass NO_SYNC_QT to qt_internal_add_module, because that
prevents the creation of qtwaylandglobal-config_p.h.

Fixes: QTBUG-88261
Fixes: QTBUG-91705
Change-Id: I776632a86ffe96886dc12f1f675f9ab56a2faf2a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2021-07-05 15:30:02 +02:00
JiDe Zhang
698bea8e9a Use QEventPoint::State instead of Qt::TouchPointState
Also fix compile warnings about -Wenum-compare.

Pick-to: 6.2 6.1 6.0 5.15
Change-Id: I5e94fc028c727b155d5db4c7def35d518c497c5c
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-06-25 15:31:12 +02:00
David Edmundson
778d4a7d65 Client: Drop use of hardcoded strings in interface comparison
Strings can have typos and is a point to introduce errors. By using
GeneratedClass::interface()->name we get some safety.

Behavior should not be changed by this patch.

Change-Id: Ic898178a6ee26ea601e905dabfe48f3bc90ed6a6
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-06-24 10:19:31 +01:00
Joerg Bornemann
60433781d8 Remove old configure-related files
Remove the configure.json and configure.pri files that
were used for the qmake-based configure.

Remove the .prev_*.cmake files that were a by-product of
configurejson2cmake.py.

Pick-to: 6.2
Task-number: QTBUG-89536
Change-Id: Ib9271b7f359af276b2df92ef4b5bc8f6bff21511
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-17 18:23:09 +02:00
Robert Griebl
90e5639701 cmake: be more flexible when creating Wayland client and server extension headers
This was hardcoded to QtWaylandClient/QtWaylandServer for cmake, while $$MODULE_INCNAME
was used in the old qmake world.

(this is an update to the previous commit, fixing the client side of things, plus adding
an override for both)

The header location will now default to the current Qt modules private include
dir (as it was in qmake times), but we now also have the ability to override
this default via WAYLAND_INCLUDE_DIR to deal with special cases like the
WlShellExtension (which is an own Qt private module itself)

Pick-to: 6.2
Change-Id: I4e96578a9a00598c236fcd22a460aeca4984baeb
Reviewed-by: Dominik Holland <dominik.holland@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-16 15:45:09 +02:00
Robert Griebl
7958ad1029 cmake: create Wayland extension headers in the correct module path
This was hardcoded to QtWaylandCompositor for cmake, while $$MODULE_INCNAME
was used in the old qmake world.

Pick-to: 6.2
Change-Id: I513423bbffb80a0f548c6145c5bf37f3930d7169
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-15 11:49:53 +02:00
David Redondo
19ca1a7a95 Hook up queryKeyboardModifers
Can be useful when upon enter a modifiers event is received but no key
event so no QKeyEvent is generated.

Fixes: QTBUG-62786
Change-Id: I30b57fc78ce6d54d8f644ca95ba40e7e26eb24ed
Reviewed-by: Marco Martin <mart@kde.org>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-06-14 13:55:01 +02:00
JiDe Zhang
c0138b02a2 Add BlankCursor for cursor names map
BlankCursor => "blank"

Pick-to: 6.1 6.0 5.15
Change-Id: I9337f0615f84bb82bc722d24416e97799309b3e5
Reviewed-by: Liang Qi <liang.qi@qt.io>
2021-06-11 08:39:33 +00:00
Alexey Edelev
3126be7231 Add the 'Private' suffix to the internal module names
Rename internal modules to adjust their names to the internal module
policy.

Change-Id: Ib9604c0b0dbd2a216d48df3797e912983f7e3c8f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-31 15:23:59 +02:00
Alexey Edelev
e970b7487a Replace AUTOMOC by qt_manual_moc in tests
AUTOMOC can not be used in Qt internal testing, since Qt::moc target
is not available at configure phase.
Replace it by the qt_manual_moc call.

Fixes: QTBUG-94085
Change-Id: I793091357d536612ae2a81032606be68dee3a6d2
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-05-29 12:34:35 +02:00
Povilas Kanapickas
2679eeaac9 Implement support for pointer gestures v1
Change-Id: Ie9ee615de123e6deab5b7a5081ca9bcf53399df7
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-05-28 22:53:32 +03:00
Povilas Kanapickas
ac704a5b90 Add protocol for pointer-gestures-unstable-v1
Task-number: QTBUG-92098
Change-Id: I3a46fcbe463f19521e6a3b0fc2d6c30e3ac93112
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-05-28 22:53:27 +03:00
Eskil Abrahamsen Blomfeldt
06906e0d11 client: Gracefully handle shutdown and window hiding
When a window is hidden or destroyed, the render thread may already
be rendering. We need to properly read-lock the surface pointer
when it is in use and exit when it becomes null.

Note that there is also a potential crash in the Mesa GL driver
where it keeps a proxy to the wl_surface, so if we delete this
while we are still rendering, it can crash inside the driver.
This is not addressed by this patch, and has not been reproduced
on any other drivers so far.

[ChangeLog][Client] Fixed a crash that could happen when hiding
or closing windows while Qt Quick was actively rendering on
a different thread.

Pick-to: 6.0 6.1 5.15
Fixes: QTBUG-91264
Fixes: QTBUG-90037
Task-number: QTBUG-92249
Change-Id: I029b123b83c58740321e8b90a463ced748d8bcf4
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-05-27 11:49:03 +02:00
David Edmundson
dbcc603faf Client: Disconnect registry listener on destruction
If a display outlives a QWaylandClientExtension and a new global is
announced we end up delivering an event to a now deleted extension which
will crash.

Change-Id: Idc0de40be61a2f7627ab4963e1fe29b22fbf3f04
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
2021-05-19 16:14:29 +01:00
Qt Submodule Update Bot
0ff3bf30d6 Update dependencies on 'dev' in qt/qtwayland
Change-Id: I445985530db8653f4dca46b59eea06b01bfd2878
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2021-05-18 14:09:08 +03:00
Kai Köhne
5e1bff9b99 Move qtwaylandscanner to libexec
This requires 7c7fda3a7e61f23 from qtbase

Fixes: QTBUG-93776
Task-number: QTBUG-88791
Change-Id: Ic7e0be2273739555593ada53d2c855fd4c37fa38
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-05-18 08:49:12 +00:00
Jan Grulich
ae254180ab Client: expose toplevel window state
QWaylandWindow has only basic information about window state, like if
it's active or maximized, but it has no information about tiling, which
can be useful for client-side decorations. We also need to bump version
of xdg-shell protocol we support, because additional states are not in
the version currently supported by QtWayland. It shouldn't be a problem
to increase the version as the new version adds just these additional
window states.

Change-Id: I4c46516d9c7296c69ea51a022b3bdb4ca06bef8d
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-05-14 14:29:03 +02:00
Albert Astals Cid
fdd4f1c92f Include locale.h for setlocale/LC_CTYPE
Pick-to: 5.15
Change-Id: Iced32a31a63cec71008549c1e0961d59ffc45a37
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
2021-05-12 16:50:10 +02:00
Vlad Zahorodnii
703af489cf Client: Announce an output after receiving more complete state
Output initialization is not atomic, meaning that the compositor may
process a wl_output bind request in one event loop cycle, and the
xdg_output_manager.get_xdg_output in another event loop cycle.

This means that xdg_output properties may arrive in another wl_output
done frame. Prior to xdg-output v3, that wasn't an issue because the
compositor is required to send an xdg_output.done event after sending
xdg_output properties.

Starting with v3, the compositor may choose not to send an
xdg_output.done event after sending xdg_output properties. Therefore,
as is, QtWayland may announce an output with bad logical geometry or
even worse without name assigned by the compositor.

Unfortunately, that breaks applications such as plasmashell. Plasma uses
output names as a criterion to determine what kind of contents should be
displayed on a particular output.

In order to fix the initialization sequence, this change makes every
QWaylandScreen track processed events. After all required events have
been received, the screen can be announced to the rest of Qt.

Change-Id: If5da747edd7af277ec1364cbea105c6994f47402
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-05-10 15:43:56 +03:00
David Edmundson
6a244c5e13 Port IVI Application test from shared_old
Change-Id: I65fbe66fe75fe4372852deadefea796576860d67
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-05-10 13:43:37 +01:00
David Edmundson
dd6ca292da Port fullscreen shell autotest away from shared_old
Change-Id: Ic6ef3b46fe6d6abf0f028389174fe4ac09dff60a
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-05-10 13:43:34 +01:00
David Edmundson
0988640184 Client: Set XdgShell size hints before the first commit
propagateSizeHints is only called in QWindow we have platform window and
minimumSizeHint is then sent. We also need to send existing hints when
we create the shell window.

Sending them when we apply configure is too late, we need these hints
available for the compositor to correctly configure the window.

Change-Id: I6cbb294b11db06ecd87535fa4816bb8ad34a29c6
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
2021-05-10 11:11:41 +01:00
David Edmundson
f3fcdc6bfd Simplify test cmake
In each test we were recompiling the shared mock compositor. This led to
a lot of difficult to maintain boiler plate as well as slowing down the
build.

This patch turns the shared component into an object library

Change-Id: I2460d3fec312a348fe633ac271f994dd36d564c4
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-05-10 10:07:31 +01:00
David Edmundson
3e502ff8d9 Client: Make tst_nooutput more robust
We had auto configure on, but also manually configured half of the
configure event by hand.

This patch changes it to all be manual

Change-Id: Id130d71585c0d8a94107702e470de201fe1a189c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-05-10 08:07:57 +01:00
Elvis Lee
b9a1fb393d Export wl-shell integration
Support wl-shell integration
as a module for external build

Change-Id: I6cd5e5c35ff1162943ffdcbe7ff834f30783e5a8
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-04-29 08:54:56 +09:00
Elvis Lee
5beb9d4e0d Export wayland-egl client hwintegration
Support wayland-egl client hwintegration
as a module for external build.

Change-Id: I3e82838d0cc89d4bb1435b835dc1e9b592319ddf
Reviewed-by: Elvis Lee <kwangwoong.lee@lge.com>
Reviewed-by: Jaeyoon Jung <jaeyoon.jung@lge.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-04-28 19:01:30 +09:00
Vlad Zahorodnii
2fca2ca03a Scanner: Remove global version check
libwayland-server ensures that the requested version is less than or
equal to the global version.

This change removes the global version check to simplify the generated
code and reduce memory usage footprint, however the latter shouldn't be
that noticeable.

Change-Id: Idd76098e588f3f4ca1be960d20a16994726702af
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-04-26 10:18:26 +02:00
Samuli Piippo
3d3a5afc68 Add missing define guards
Ammend 98c921c0e2250ce85ab3de05ea58e98587102ae3 to use m_composeState
only if xcbcommon is available.

Pick-to: 5.15
Change-Id: I48332b15def3282c5bda3e1c7c393ea7e9849cbe
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
2021-04-22 16:58:04 +03:00
Eskil Abrahamsen Blomfeldt
24f8a92cbc client: Fix frame callback leak when window unexposed
If we get a new update while already waiting for a frame callback
and the window is unexposed, we would previously destroy the
callback and issue a new one. But if the window is unexposed, the
compositor may accumulate these and answer all the callbacks when
the window is shown again. This may cause overflows and the client
to be killed by the compositor in some cases where the number of
pending updates is too high.

To avoid this, we skip requesting new callbacks if there is already
one pending and the window is unexposed. When the window is
re-exposed, the existing pending callback will be triggered anyway,
and until then there is no need to repeatedly verify that we
still cannot render.

One risk is that there may be compositors which never issues a response
to the callbacks requested while the window was unexposed. But that
would probably be in conflict with the specification and possibly cause
other issues as well. The patch was tested with Weston and Mutter, and
seems to improve behavior in both of these at least.

[ChangeLog][Client] Fixed a bug where Wayland clients would continuously
request frame callbacks while unexposed, which potentially caused crashes
on some compositors.

Fixes: QTBUG-81504
Change-Id: I16dbe51cc5a9acf1f49b4070af91e7f2c8996122
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2021-04-22 11:18:26 +02:00
Eskil Abrahamsen Blomfeldt
218a99d7bc Remove bogus warning about missing wayland-egl
For some reason, we always print a confusing message that
the wayland-egl backend is not built when configure is run.
The warning is incorrect, and since it is not worth the trouble
to find out why it isn't working, we just remove it.

Fixes: QTBUG-92925
Change-Id: I01e35f21180249c1ae0db73dc3541365fb2eff41
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2021-04-21 09:08:53 +00:00
Jan Grulich
5a8e861807 Client: get correct window content geometry
We have to apply geometry where we don't include shadows, because we
need them to be ignored in some scenarios. Also, with geometry being
already shrunk by the size of shadow margins, we have to avoid doing
it again, otherwise we can accidentally make our window smaller every
time we update its size or state.

Change-Id: I0e26ee1be8d918913125ee7f7c97de56ccc797cf
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-04-19 05:43:25 +01:00
Youngjin Kim
1f2c1062c6 Fix inconsistent window geometry on null window
Add virtual QtWaylandClient::QWaylandWindow::defaultGeometry().
So this method allows a client to set the desired default geometry.

Otherwise, if the geometry of the window is null, the window
with the hard-coded geometry size will be displayed for a while
when starting a client application.

Change-Id: I18c50f8f390c2b8e1a2c3d8e4641b896df4d6c3f
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-04-15 06:50:41 +09:00
Elvis Lee
0ccd3105ff Connect flushRequest after forceRoundTrip
If flushRequest is connected with aboutToBlock, the flushRequest
may consumes all events so that processEvents might be blocked in forceRoundTrip.

Change-Id: I12b2c506e8442bf0e75f6ab6e418d3e1eea6d68c
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-04-13 06:44:18 +00:00
Jaeyoon Jung
bffa397f68 Client: Allow inheritance of key translation
Use a virtual method keysymToQtKey for Qt key code translation, so that
it can be customized by a descendant class if needed.

Change-Id: I3b48346a63e2c6f134230fe15279faa95abe11a0
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-04-13 15:44:18 +09:00
Aleix Pol
98c921c0e2 client: Allow QWaylandInputContext to accept composed key combinations
At the moment, we are forcing user to choose to either compose or use
the text-input channel. This patch brings some of the QComposeInputContext
functionality in order to let applications understand dead key
combinations like they are supposed to.

Having it in QWaylandInputContext rather than in QWaylandInputDevice
should solve the problems 9a782df3e7f6f937a1bae3fa5e964a29fbe5980b had
with dd13698a730594d9f40baa367dcfe05bc23f1016, because we are doing it
in the input context rather than before. This way, if the user is
overriding the input method (e.g. by setting QT_IM_MODULE), all the key
strokes will still be properly forwarded to the module to use.

This in turn allows us to solve https://bugs.kde.org/show_bug.cgi?id=411729
and https://bugs.kde.org/show_bug.cgi?id=405388 since we don't need to
choose anymore between physical and virual keyboards anymore.

Pick-to: 5.15
Change-Id: I8601f5d7ae21edf4b3a1191fa75877286e505588
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-04-13 03:08:03 +02:00
Hyunkook Khang
7fa0a2e375 Fix touch being ignored when down and up are in the same frame
The Wayland protocol gives no guarantees about which events are part of
a frame, so handle the case where we receive wl_touch.down and
wl_touch.up within the same frame.

Fixes: QTBUG-89680
Change-Id: Ie0b9d2fb950fb0d9a6af8dd8ad2fa55a5efa71e6
Pick-to: 5.15 6.1 6.0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-04-12 08:51:20 +00:00
Weng Xuetian
c0f9fef33e Use qWarning and _exit() instead of qFatal for wayland error
This type of error is likely to happen upon system logout. qFatal would
trigger sigabrt and leave unnecessary coredump on the system. Using
qWarning here would make it consistent with xcb's io error.

Pick-to: 5.15 6.0 6.1
Change-Id: I571ba007bf2453486b81837cccdbefa5f181b63d
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-03-31 07:17:52 -07:00
David Redondo
515282115d Make addRegistryListener protected
Enables leaf classes that want to bind immediately to call it without
waiting for an event loop

Change-Id: I4a885959ef54ba12a2c46f3f1a668e8c0cf1d967
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-03-26 14:21:58 +01:00
Aleix Pol
8e16ebe3fb xdgshell: Tell the compositor the screen we're expecting to fill
The xdgshell protocol allows us to tell the output to fill. This makes
it possible to use fullscreen confidently on systems with multiple
screens knowing that our windows won't be overlapping one another by
calling setScreen accordingly before QWindow::showFullScreen.

Pick-to: 6.1 6.0 5.15
Change-Id: I757854c3698639472f3a25ef298ddcca031e1ed5
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-03-26 01:18:10 +00:00
Jungi Byun
597278685a Replace scale with devicePixelRatio for non-integer scaling
The 'scale' event from wayland cannot support non-integer scaling
which was originally supported in Qt.

As default, devicePixelRatio follows the 'scale' so that the high DPI
still works as the mechanism in Wayland. But if non-integer scaling
factor such as 150% is needed, it can be supported to override the
devicePixelRatio.

Change-Id: I63a04db27bd521264b6d0904e1ddd05a572dc970
Reviewed-by: Elvis Lee <kwangwoong.lee@lge.com>
Reviewed-by: Jungi Byun <jungi.byun@lge.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-03-25 15:30:21 +09:00
Jungi Byun
f0435ab1a4 Support handleFrameCallback to derived classes
The lambda expression doHandleExpose() is used in handleFrameCallback()
to deal with exposure.
In order to support platform specific implementation for frame callback,
make the method doHandleExpose() into a virtual protected member
doHandleFrameCallback() in QWaylandWindow.

Change-Id: I8b22d4a552c72db1620d606929005917588c680d
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-03-08 06:51:17 +09:00
Elvis Lee
8e336efb2d Handle registry_global out of constructor
Factory functions in QWaylandDisplay::registry_global() can be overridden.
Later, other classes instantiated in the registry_global can support
platform specific implementation with inheritance and some factory function.

Change-Id: I92ce574e049b8c91587687cc7c30611f3dfdbe56
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-03-04 09:06:12 +00:00
Jan Grulich
a02c408afc Client: get correct window content geometry
Window content geometry should not include invisible portions of the
decorations, like shadows. This is stated in xdg-shell specificification
and in the description for this method.

Change-Id: I444fe9e28f0f175d2051be5c704efa7658bd45fb
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-03-03 13:39:44 +01:00
Jan Grulich
e101ffce1d Decorations: add new argument to margins() to allow exclude shadows
We can already have shadows to be part of decoration margins, but we
need a way to also get size of shadow margins itself, because they
should be ignored for the purposes of aligning, placing and constraining
windows.

This change breaks API/ABI compatibility of QWaylandAbstractDecoration
plugin, however, as stated in the header file, it is a subject of change
and its API is not meant to be stable. Alternatively we can make this a
separate method.

Change-Id: Ib2c9982e16c4acb13a83757e6371022c0a89b74e
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-03-03 11:44:38 +01:00
Jan Grulich
4d666cd62e Get correct decoration margins region
Size we use to calculate margins region already contains size including
margins. This resulted into bigger region and not properly damaging
region we need to update.

Pick-to: 5.15 6.0 6.1
Change-Id: Id1b7f4cd2a7b894b82db09c5af2b2d1f1f43fa2a
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-03-02 09:16:35 +01:00
David Edmundson
37f04028ca Client: Rebuild generated files when source or QtWaylandScanner changes
Right now if one changes QtWaylandScanner you need to do a clean build
to see the changes.

Change-Id: I3fc9f37a25550880328363b07b1bb5713c8df2e6
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-03-01 22:15:50 +00:00
David Edmundson
d92e26205e Client: Send exposeEvent to parent on subsurface position changes
When a subsurface is moved, we need the parent window to commit to apply
that move. Ideally we want this in sync with any potential rendering on
the parent window.

Currently the code calls requestUpdate() which acts more like a frame
callback; it will only do something if the main QWindow considers itself
dirty.

We want to force a repaint, which is semantically more similar to an
ExposeEvent.

Fixes: QTBUG-86177
Pick-to: 5.15
Change-Id: I30bdfa357beee860ce2b00a256eaea6d040dd55c
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-03-01 10:07:56 +00:00
David Edmundson
51b6fa425e Client: Generate method to expose used version of a given proxy
Relying on the compositor version only works for the core protocols.
Using the version of our relevant object is more extensible and relies
on less caching.

Pick-to: 6.1
Change-Id: I1044e43a1e24a25359db95988c9956f4f1b5d35f
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-02-24 16:19:24 +00:00
Jan Grulich
9227c5d18d Translate opaque area with frame margins
The opaque area doesn't take window decorations into account, which may
result into possible graphical artefacts.

Pick-to: 5.15 6.0 6.1
Change-Id: I1606e8256e7e204dad927931eb1221b576e227fd
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-02-23 11:06:50 +01:00
Eskil Abrahamsen Blomfeldt
d56e534dba Fix sending input hints with new text input protocol
Using input method hints to request things like digits-only
etc. did not work with the specialized Qt input method for two
reasons: First of all the full state of the editor needs to be sent
to the keyboard when the focus object is set.

But even fixing this, it turned out that the recipient was not
actually registering the input methods hints, but just overwriting
the function argument with itself.

Fixes: QTBUG-91206
Pick-to: 6.0 6.1
Change-Id: I1b8a3e92cc912bc06b6a2a60f8ea280393cd226e
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-02-22 07:00:33 +01:00
Elvis Lee
1a1c264b0b Support platform specific implementation
QtWaylandClient can be inherited to support platform specific
implementaton.

Change-Id: Ie0f4aa28dbb2dcd6b1245cb14e23f3b45e687400
Reviewed-by: Elvis Lee <kwangwoong.lee@lge.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-02-17 19:47:51 +09:00
David Edmundson
487d305d2b Client: Connect drags being accepted to updating the source drag icon
Currently in a multi-process drag and drop when the other client accepts
a given mimetype for dropping it calls accept, which is received by the
client, but the drag cursor is never updated.

Instead the drag cursor was updated in the data_device_enter events
which only works if we are operating within one process.

The code existed to handle this existed but both the targetChanged
signal and the dragSourceTargetChanged were unused.

Change-Id: I443f31f1b2ef72d4b5eadaf7115f97544dac883a
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-02-15 10:15:42 +00:00
David Edmundson
9e9e338679 Client: Send set_window_geometry only once configured
The geometry only makes sense when a buffer exists, our currently send
value is somewhat meaningless, but till now harmless.

A specification clarification implies that it is an error if the
calculated effective window geometry is null, rather than just checking
the sent value. This is the case if set_window_geometry is sent before a
buffer is attached.

On our first configure call we enter resizeFromApplyConfigure which will
hit this path and send the initial state.

Pick-to: 5.15
Pick-to: 6.1
Pick-to: 6.0
Change-Id: Ib57ebe8b64210eae86e79dfdd6b5cb8a986b020b
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-02-15 10:15:10 +00:00
Joerg Bornemann
929f5fc2e8 Remove QMake project files
This includes removal of the corresponding .prev_CMakeLists.txt files.

Pick-to: 6.1
Task-number: QTBUG-88742
Change-Id: I57922bff138258f5b35d484caa4b00d84e924a06
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-02-11 16:43:47 +01:00
Zhang Liang
a79dbb8359 Fix: remove listener
Add the operation for removing the listener form listener list

Change-Id: Ief2ff1303b607eee499543303fe80e51f8f10cc5
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-02-02 15:47:07 +08:00
Ville Voutilainen
9fd8a5cfb0 Build fixes for GCC 11
Task-number: QTBUG-89977
Change-Id: I7e3d0964087865e8062f539f851a61f3df017dae
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2021-01-18 13:50:12 +02:00
Eskil Abrahamsen Blomfeldt
aa793867b0 Remove some dead code
The waitForScreens() function has not been used for a while,
so to avoid confusion around the different entry points to
event processing, we remove it.

Change-Id: I3a801492ab87b4835e0e1b3c9e264c29c1688c06
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2020-12-17 07:28:55 +01:00
Eskil Abrahamsen Blomfeldt
0936d81b79 Fix compilation after removing QEvent copy ctor
In 19f9b0d5f54379151eb71e98555b203ad6756276 in qtbase, the
copy constructors for QEvents were removed, so code using
this has to be updated.

Change-Id: I5798b240d79f78c47374d60947b1bc66598ff3b5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-19 09:18:48 +01:00
Roman Genkhel
e1c5ff6e70 Check pointer for null before use in ASSERT
Task-number: QTBUG-85195
Change-Id: I331e54f6e58aa9d536351a55223610c60b3cb414
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2020-11-17 20:47:56 +03:00
Morten Johan Sørvig
ad466182a7 Make setting QT_SCALE_FACTOR work on Wayland
Follow-up to b18aba6a428a6304c06c465ca5a2969b3cf9e31c,
fixes one additional case (Use of minimum/maximum size).

Fixes: QTBUG-87762
Pick-to: 5.15
Change-Id: I73e0df2529b0cadf25ad50ea7459cdbb92caf424
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-11-17 11:05:59 +00:00
Eskil Abrahamsen Blomfeldt
4db304cc9e Fix compilation after QFileInfo changes
The QFileInfo constructors were made explicit in
784a290c4b08e84d895a62dada5420a3b47dde48, breaking compilation
where the implicit construction was used.

Fixes: QTBUG-88565
Change-Id: Icc4c335ea5cbbd21f8a9027beb57823e233b253d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-17 09:06:26 +01:00
Eskil Abrahamsen Blomfeldt
f2bc2a7c19 Fix some compile warnings
QTouchEvent::touchPoints() is deprecated and replaced by just
points(), and there is a new value in Qt::TouchPointState.

normalizedPos() is replaced by normalizedPosition().

And QVariant::type() is deprecated.

Change-Id: I4a4eea2775030f67ad12488df25d4859099c1783
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-11-17 07:10:32 +00:00
Morten Johan Sørvig
b18aba6a42 Make setting QT_SCALE_FACTOR work on Wayland
QWindow geometry accessors return geometry in device
independent pixels. Normally this coordinate system
is equivalent to the Wayland native coordinate system,
but this is not the case when QT_SCALE_FACTOR is set.

Replace QWindow geometry calls with the helpers from
QPlatformWindow which return geometry in the native
coordinate system:

QWindow::geometry() -> QPlatformWindow::windowGeometry()
QWindow::frameGeometry() -> QPlatformWindow::windowFrameGeometry()

Task-number: QTBUG-87762
Fixes: QTBUG-88064
Change-Id: I8c96237b49c754bb978f1739d090962be770c271
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-11-16 11:40:49 +01:00
Vlad Zahorodnii
f73b8a94f4 Scanner: Avoid accessing dangling pointers in destroy_func()
Usually, the object associated with the resource gets destroyed in the
destroy_resource() function.

Therefore, we need to double-check that the object is still alive before
trying to reset its m_resource.

Pick-to: 5.15
Change-Id: I26408228f58919db17eb29584a1cbd4a9427d25c
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-11-13 14:14:23 +02:00
David Edmundson
19281f9c3b Client: Drop XdgShellV5 and XdgShellV6
Both of these are deprecated given this is now formalised as the final
xdg-wm-base. This final release has been out for several years and all
main compositors (kwin, sway, mutter) have dropped or are dropping
legacy support.

tst_nooutput is moved to stable XdgShell.

Change-Id: I46a011502dfec6d4a215c3b22d03e8ceebed46c3
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-11-11 08:38:10 +00:00
Eskil Abrahamsen Blomfeldt
edbc9697b6 Stop depending on private API in user-facing cmake code
The qt_parse_all_arguments() macro is not available as part of the
public API, but it was used to generate code for extensions, which
users need to be able to do. The result was that top-level builds would
work because they could access the functions, but when our examples
were built as stand-alone, it failed to find the function.

The fix is just to copy-paste the contents of the macro.

Fixes: QTBUG-87445
Fixes: QTBUG-87446
Change-Id: Id5a583358be4163d3cdab72d7c23804f66f45500
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-30 09:39:15 +01:00
Alexandru Croitor
afe107fb13 CMake: Add versionless function names
Task-number: QTBUG-86827
Change-Id: I4b1931ca63c3d589c8167d04a1cd3712f8ba30d6
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-26 13:00:39 +01:00
Alexandru Croitor
e48005a356 CMake: Make qtwaylandscanner depend on QtCore only
It doesn't use any Gui classes at the moment.
It also ensures a target dependency cycle is not created on the
default_qpa_plugins custom target when the QT_QPA_DEFAULT_PLATFORM
cache var is set to 'wayland'.

Change-Id: I8958e5b993ad40294abf49f633d1ef31b6c633bb
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2020-10-26 11:53:18 +01:00
Aleix Pol
108be7810d Issue set_opaque_region on opaque surfaces
The application will tell Qt whether the background is transparent
through either Qt::WA_TranslucentBackground or QQuickWindow::setColor.
These will set a QSurfaceFormat.
This change checks the QSurfaceFormat and issues the opacity information
so we can properly implement culling optimizations in the compositor.

Pick-to: 5.15
Change-Id: I4f7562467449eac7931f3011d4b835934212adad
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2020-10-20 16:17:22 +02:00
Aleix Pol
a0a17c1886 Address WlCompositor::compositor_create_region in tests
It was not properly marked as override and would not get called.

Pick-to: 5.15
Change-Id: Ib80c916c65534ddff918ac06bbe52d88e19d9ff4
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2020-10-20 14:49:19 +02:00
David Edmundson
5b3bda7f0a Client: Advertise all supported mime types
Qt has some internal mime types that can be translated to known types.
For example the mime type application/x-qt-image Qt can convert to any
supported image format.

The data_source_send method already converts (via
QWaylandMimeHelper::getByteArray)

However we previously only advertised the list of mimetypes explicitly
set by the application.

This brings us in line with the X11 QPA.

Fixes: QTBUG-87657
Pick-to: 5.15
Change-Id: Ia09c0cbc1f0997552bd253e79d6715ebcafee0a1
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-10-19 12:39:10 +01:00
Aleix Pol
19483db52c Implement CoreProtocol::compositor_create_region
Otherwise tests using it crash.

Pick-to: 5.15
Change-Id: Id2ce98ed7c975144728be7566e20b6ea08fa9150
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2020-10-15 16:13:12 +02:00
Vlad Zahorodnii
7bf4c434a4 Scanner: Generate code that destroys inert resources
In rare cases, the compositor may need to destroy its private data
associated with a wl_resource object. For example, one such case may
arise when an output has been disconnected and the corresponding
QWaylandXdgOutputV1 object needs to be destroyed. Another case is
where some resource has become inert.

If the QWaylandXdgOutputV1 object has been destroyed and there are
still wl_resource objects associated with it, the compositor will
crash due to a segfault when somebody calls xdg_output::destroy().

With this change, qtwaylandscanner will generate code that handles
destruction of inert resources behind the scenes.

Pick-to: 5.15
Change-Id: I0532f783ae53cc7861e0f08433dc2407aa9c7953
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2020-10-12 16:00:59 +03:00
Vlad Zahorodnii
e956efdcfa Scanner: Generate code that cleans up m_resource
The object that owns the resource will not be necessarily destroyed in
the destroy_resource() function. One such case may arise if the
compositor wants to animate the disappearing of a window, in that case
we want to keep client buffer data around even after the wl_buffer
resource has been destroyed.

If the compositor accidentally accesses the destroyed resource, it'll
most likely crash because of SIGSEGV. Speaking from my experience, such
crashes are far from being fun to debug.

With this change, qtwaylandscanner will generate code that cleans up
m_resource when the associated resource has been destroyed. It can be
useful for the purpose of preventing accessing already destroyed data.

Note that we want m_resource to be valid when the destroy_resource()
func is called because the compositor may need it in order to properly
perform cleanup, for example send a wl_pointer::leave() event, etc.

Pick-to: 5.15
Change-Id: I82dab3b7eae8c282fdbad689af49622350b6c867
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2020-10-12 14:23:23 +03:00
Aleix Pol
5c4f0dea27 Implement MockRegion
If we don't mock regions, we get a crash every time that a client calls
createRegion.
So far regions are untested.

Pick-to: 5.15
Change-Id: I83f20b879ece5cefcf2039d369034516df6a6a62
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2020-10-09 13:34:58 +02:00
Paul Olav Tvete
e800b14c8c Fix race condition on frame callback
If the frame listener callback is moved to a different queue while the
frame event is being processed, the event will not get delivered. (It
will not even show up in the WAYLAND_DEBUG output.) This will cause
waitForFrameSync() to hang until it times out.

To avoid this, perform the move just after the callback has been
created.

This exposed an issue with single-threaded rendering, where a new
update would be started from inside the callback, resetting
mWaitingForFrameCallback before waitForFrameSync could react to it.
This caused all rendering to freeze. To avoid that problem, do not
deliver update requests directly from the frame callback.

With the callback always on a separate queue, we then have to make
sure that queue is also dispatched during the main event loop,
otherwise the events may not be processed. To do this, we need a
mutex lock. But it turns out that we no longer need a global mutex
lock as long as the frame events are being dispatched on their own
queues, but can manage with per-window locks instead.

A final thing needed is to make sure the frame callback does not
request additional updates while we are already waiting for the main
thread to process the last one. This is to avoid flooding the main
event loop with events, when the main thread is processing them at
a slower pace than the frame rate.

Fixes: QTBUG-83263
Pick-to: 5.15
Done-with: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Change-Id: I0db9da64fc8ced147177391c2a7999c4cc7a0d58
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2020-10-07 11:38:43 +00:00
Eskil Abrahamsen Blomfeldt
40206410da Re-enable tst_nooutput
The dependencies update has gone through, so the test
should now pass again.

Fixes: QTBUG-86698
Change-Id: I23babc4a5c3cae0bff5ba371e9703c976536f4ec
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2020-10-01 12:28:54 +02:00
Alexandru Croitor
142bd4c562 CMake: Regenerate projects to use new qt_internal_ API
Modify special case locations to use the new API as well.

Task-number: QTBUG-86815
Change-Id: I2ba7753b64f3d88332e919dc90c98e252e20dd98
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-01 12:09:59 +02:00
Eskil Abrahamsen Blomfeldt
f88ad7944f Fix compilation after mime data API changes
Follows 848927b688d4709d0b71590518e2c32fe7866147 in qtbase,
where the signature of retrieveData_sys() was changed.

Fixes: QTBUG-87003
Change-Id: I8b88c8f9547e599328f40345a9fbf57c07ec31a4
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-30 04:28:57 +00:00
Peter Seiderer
4fe2d5d2c8 fix libdrm related configure test failure
Fixes:

  Project ERROR: Test config.qtwayland_client.tests.dmabuf-server-buffer tries to use undeclared library 'drm'
  Project ERROR: Test config.qtwayland_compositor.tests.dmabuf-server-buffer tries to use undeclared library 'drm'
  Project ERROR: Test config.qtwayland_compositor.tests.dmabuf-client-buffer tries to use undeclared library 'drm'

Task-number: QTBUG-83303
Change-Id: I3970f4e3855fcfa760493631a14adb6a16950aa9
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Reviewed-by: Heikki Halmet <heikki.halmet@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-09-24 12:42:20 +02:00
Joerg Bornemann
f1b5619ca0 Re-visit the xkbcommon dependency
QtGui doesn't expose xkbcommon as public dependency anymore.
QtGuiPrivate, however does now, but only in the CMake build.

Fix the qmake build by adding an explicit xkbcommon dependency to
client.pro, like it's done for the compositor.

Commented out the explicit xkbcommon dependencies in the CMakeLists.txt
files of client and compositor.

Mark the XKB packages as optional, such that qtwayland can actually be
built if the feature xkbcommon is OFF and no libxkbcommon-dev package is
installed.

Change-Id: Ia1c7a8333dc8a93b4924e03f7f2284a709a9d65b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-22 14:43:53 +02:00
Alexandru Croitor
769bef69c8 CMake: Record QtWaylandScannerTools as a tools package dependency
The change uses new API introduced in qtbase, to register
QtWaylandScannerTools as a tools package dependency, ensuring that
the proper host prefix manipulation is done to find the host package.

This fixes the QEMU CI standalone test building by using the host
qtwaylandscanner.

Task-number: QTBUG-83968
Change-Id: I67facb32e1a1e33197090fde324755c0fc880684
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-09-17 12:03:29 +02:00
Lars Knoll
9659ddb38a Update dependencies on dev in qt/qtwayland
Add one moc include to make things compile after
the changes in qtbase.

The nooutput test fails with this update because
high-dpi is now enabled by default. When running
with a placeholder screen, we get a scale factor
of NaN because the default logicalDpi()
implementation divides by physical size, which
is 0x0 in the case of the placeholder. We
temporarily disable the test in order to get the
update in.

Task-number: QTBUG-86698
Change-Id: I474f6970186e93905332c679f2cec5fea459de64
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-16 15:28:22 +02:00
Joerg Bornemann
8abcf3fa90 CMake: Explicitly search for XKB
...like we do for X11 in 5e927fb8d6b376cb41cf516781a84fb47cebb584.

Change-Id: Ib058b6d9fc3a8d6b27327794aba9b2f3dd828bcc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-16 15:07:45 +02:00
Alexandru Croitor
ae42ed7cd3 CMake: Make sure test blacklists are found
Some of the qtwayland tests are failing on qemu configs and are thus
blacklisted. When the tests were built with CMake, the blacklist file was
not found.

This is due to the custom QCOMPOSITOR_TEST_MAIN function which does not
provide the location of the test source folder, and
thus the QTestPrivate::parseBlackList -> QTest::qFindTestData call
fails to find black list file.

Bring the custom test main function in line with what the other QTest
main functions do, which is call QTEST_SET_MAIN_SOURCE_PATH.

Note in qmake builds this was not necessary, because the way the
source and build folders are computed for tests is slightly different
from the CMake way. I don't recall the exact details, but
basically CMake builds need this extra information that is set by the
QTEST_SET_MAIN_SOURCE_PATH call.

Task-number: QTBUG-83968
Change-Id: Ia4742488097a65f18594881c89af48c9d621e6e1
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-09-15 16:10:24 +02:00
Alexandru Croitor
5e927fb8d6 CMake: Explicitly search for X11 with proper dependency tracking
Replace the hardcoded find_package(X11) with qt_find_package in both the
compositor and client projects.
This should ensure proper dependency tracking.

Calling qt_find_package(X11) is now necessary, because QtGui doesn't
publically link against X11 anymore, which means we have to do it
explicitly for qtwayland. The relevant qtbase change is
69004cb2900dcfc530e1e2efb783f559661a8a50

The calls need to be protected by an if(NOT TARGET) to prevent
configuration issues in static builds, where the dependency does get
propagated.

This amends commit dfaf374a3d8d34b9aa90bfc4c5e074f9fd8b9981.

Change-Id: Ia39e1e78cd0af386d7b48cd1922887289823c1fa
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-09-15 10:40:52 +02:00
Alexandru Croitor
42d9e19e40 CMake: Add checks that the wayland scanner targets are found
There was an issue when cross-compiling Qt tools with Yocto, that the
dependency between QtWaylandScannerTools and WaylandScanner was not
registered, leading to failures at build time, try to run an
executable called "Wayland::Scanner".

Explicitly check that the targets exist, and fail at configure time in
case they don't exist.

Task-number: QTBUG-83968
Change-Id: I19ece78b77619761394d047f15cd3a7a37fb0cbf
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-09-11 09:54:57 +02:00
David Edmundson
af89d09f92 Client: Expose XdgShell native resources
Many new specifications now rely on passing xdg_surface/xdg_toplevel as
arguments to other protocols.

wl_shell is currently exposed through native resources but xdg-shell
related classes were not.

Fixes: QTBUG-81479
Change-Id: I2023f39ad6813ff58e8a86d739f307d791794b16
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2020-08-26 16:43:35 +01:00
David Edmundson
e1f73494ca Client: Fix scroll direction with touchpads
Wayland axis events and QWheelEvents are opposite way rounds. This was
handled for the case of discrete events, but not continuous events.

This leads to touchpads moving the wrong way round compared to other
clients.

Change-Id: Iee4f5c620940a491949d4039cb3ac70649d83a2b
Pick-to: 5.15
Task-number: QTBUG-85767
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2020-08-26 16:07:08 +01:00
David Edmundson
90de870987 Client: Initialize mScale on creation instead of on show
At the time of creating a QPlatformWindow we will have a QScreen
assigned. It may not be the right one until we get a screen_entered
event, pointing instead to the primary screen.

When we get the screen_entered event we get the correct scale and call
handleWindowScreenChanged. However if it's the same screen as before
QWindowPrivate::setTopLevelScreen will no-op because from it's POV the
screen hasn't changed at all.

This leaves the window having the scale change without any notification.

This is notable with QQuickWidget which creates an FBO very early on
before the window is shown. This would then use the devicePixelRatio of
1 as it is currently unset and then not get any change notification.

Change-Id: Ia7e4072e0bd900abc558bf8930fef4e1e7d2c553
Pick-to: 5.15
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2020-08-26 15:49:16 +01:00
David Edmundson
5f7efad86e Client: Add warning about private headers to vulkan header files
Pick-to 5.15

Change-Id: Ie13fb1ba31efd8e12fd502b3f37363ed341be2d6
Reviewed-by: Kai Uwe Broulik <kde@privat.broulik.de>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2020-08-26 14:21:13 +00:00
Eskil Abrahamsen Blomfeldt
6578795ab5 New input method protocol for use with Qt clients
We introduce an alternative input-method protocol, which
is a one-to-one mapping to Qt's input method API. Input
methods such as the virtual keyboard's hunspell
integration is quite sensitive to the inner workings of
the input method handling, both in terms of when state
is updated and which updates are delivered when.

With a one-to-one mapping we are able to match these
expectations and keep a well-synchronized state.

Task-number: QTBUG-85135
Task-number: QTBUG-85134
Change-Id: Id69c22a7b0885ea59f39fdcc8d663749af56c7ce
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2020-08-26 08:49:12 +02:00
Lars Knoll
a8b91863d3 Compile against latest qtbase
Change-Id: I6111cd2e280a7cff610d3f89d51fb3964d61b51f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-08-24 17:40:08 +02:00
David Edmundson
6d8b4bbadb Client: Send subsurface expose event when toplevel is configured
If a subsurface is set to be visible on the cilent side before the top
level is configured it will do not create an exposeEvent and map a
buffer as we fail the check in isExposed() where we check the parent.
This is correct behavior.

However, when the toplevel receives an applyConfigure from the shell
client we need subsurfaces to update accordingly.

This fixes a race where subsurfaces are not shown with slow compositors.

Change-Id: Icd156e7655d5b25535acc4d2fe77c31e19ebfa32
Pick-to: 5.15
Fixes: QTBUG-86176
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2020-08-21 15:15:35 +00:00
Eskil Abrahamsen Blomfeldt
8631b43a2d Add API for selecting supported wl_shm formats
We would always reported all formats we could convert from
as supported on the wl_shm protocol. This would sometimes
cause clients to pick formats that required internal conversion
when creating OpenGL textures from the images. To avoid
this, we default to only supporting the RGB32 and
ARGB32_Premultiplied formats (which are required and advertised
automatically) and if the user wants to add additional formats,
we now have a additionalShmFormats property for this.

[ChangeLog][QtWaylandCompositor] The compositor will now by
default only advertise support for the required wl_shm formats.
Additional formats can be added to the list by setting the
additionalShmFormats property on the compositor.

Fixes: QTBUG-77531
Change-Id: Ibd5d5be2a37968353c00308abbfff7ca6f8d310d
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2020-08-21 07:09:11 +02:00
Tor Arne Vestbø
74d7982b94 Update to match qtbase changes to platform headers
Change-Id: I8e39d87361728c81b526f1ad89b45136500c9913
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2020-08-19 14:58:10 +02:00
Samuel Gaist
ea199834ce Fix qt_attribution.json files by replacing newlines with \n escapes
In their current state theses files contains invalid json. While they
are parsed successfully by qtattributionsscanner, they cannot be loaded
by libraries such as Python's json module.

This patch fixes this.

The output generated by qtattributionsscanner stays the same.

Pick-to: 5.15
Change-Id: I661d9b6f8a956a33b301fe58add5910d6de293f1
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2020-08-17 20:09:18 +00:00
Friedemann Kleint
7544734a33 Adapt to recent qtbase changes and update dependencies
- moving linuxaccessibility/xkbcommon/eglsupport/glxsupport to QtGui
 - event refactoring

Task-number: QTBUG-83255
Change-Id: Ic82ee6ef5652413781468edb58c601ee7dce2e3b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-07-29 13:09:05 +02:00
Alexandru Croitor
1d5d2b6670 CMake: Regenerate projects
We need the qt_add_tool changes to successfully configure qemu builds.
The rest of the changes are just to be in sync with the .pro files.

Change-Id: I64e92edc2486a71c88bd964a07adf502481b200d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-07-09 14:33:53 +02:00
Paul Olav Tvete
d2688a83a1 Fix inconsistent signedness in qtwaylandscanner
Use uint32_t everywhere for id. This is what libwayland does.

Fixes: QTBUG-73098
Change-Id: Ie9564e59001cd9b29481d982b3136a4f31ece717
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-07-09 12:29:10 +02:00
Paul Olav Tvete
bae4e9528a Use --strict option for wayland-scanner
Make protocol definition errors build errors.

Task-number: QTBUG-73100
Change-Id: I1987bb93117f3bd017449f47eeb7e272597563dc
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-07-09 12:28:54 +02:00
Paul Olav Tvete
0815723d6d Stop using deprecated wayland-scanner argument
The argument "code" is deprecated. Use "public-code" instead.

Task-number: QTBUG-73099
Change-Id: Idc8dca127581e07b81d7174ece3312c27b6ba9db
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-07-09 12:28:36 +02:00
Paul Olav Tvete
7eea720dbd Use wl_surface.damage_buffer on the client side
Prefer the newer, recommended damage_buffer when the compositor
supports it.

Fixes: QTBUG-74929
Change-Id: I9107966910b616a666931404a7b41bfac14c22c0
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-07-07 12:55:48 +02:00
Eskil Abrahamsen Blomfeldt
4189b0b2a2 Remove deprecated code
XdgShellv5 and XdgShellv6 have been deprecated in
the compositor since 5.15, and wl-scaler since 5.13.
These are now removed.

Since the qwindow-compositor has not been updated
for a long time, it depends on the outdated protocols.
This change removes it, since it no longer represents
best practices. This means we will be missing a proper
C++-based compositor for now, so we will have to
create a new one later.

Change-Id: Icc6ef97c17e553f266c4145abeef26ddd631d6bf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2020-07-07 09:29:06 +02:00
Paul Olav Tvete
0143b0dac9 Remove checks for old Wayland versions
Now that the minimum libwayland version is 1.15, there is no point
in checking whether the version is greater than 1.10.

Task-number: QTBUG-73636
Change-Id: I75a97bec7e464aa6b04e21d1c23566d17ac7684a
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-07-06 10:39:07 +02:00
Paul Olav Tvete
71eb32d328 Update libwayland requirement to 1.15.0
[ChangeLog] libwayland 1.15.0 is now required.

Fixes: QTBUG-73636
Change-Id: I585bb80c7d14ebfceb623b55cf7959121121599f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-07-03 11:28:23 +02:00
Lars Schmertmann
a15ab03734 Add ; to Q_UNUSED
This is required to remove the ; from the macro with Qt 6.

Task-number: QTBUG-82978
Change-Id: Ia626b9fbc2e4215cb9232ef9bcb71742d62dff4e
Reviewed-by: Liang Qi <liang.qi@qt.io>
2020-06-30 10:44:12 +02:00
Shawn Rutledge
2b827691dc Replace calls to deprecated QEvent accessor functions
Several event accessors were deprecated in
qtbase/24e52c10deedbaef833c0e2c3ee7bee03eacc4f5.

Replacements were generated by clazy using the new qevent-accessors check:
$ export CLAZY_CHECKS=qevent-accessors
$ export CLAZY_EXPORT_FIXES=1
$ ../qt6/configure -platform linux-clang -developer-build -debug
  -no-optimize-debug -opensource -confirm-license -no-pch QMAKE_CXX=clazy
$ make
$ cd ../../qt6/qtwayland
$ find . -name "*.clazy.yaml"
$ clang-apply-replacements .

Task-number: QTBUG-20885
Task-number: QTBUG-84775
Change-Id: If822ba409f974f737dc46ac31f6e8e92cc1603cc
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-06-29 14:21:40 +02:00
Jide Zhang
a695c7fbc8 Add spaces around '+'
Like most other Qt coding styles, the necessary spaces should be added
to the sides of the '+'

Pick-to: 5.15
Change-Id: I6fdbc6b24861e7a75633354a0ded636b1a38cd21
Reviewed-by: Liang Qi <liang.qi@qt.io>
2020-06-29 09:03:31 +00:00
Shawn Rutledge
08a3e9eb8d Declare QWaylandDisplay::findExistingCursorTheme noexcept
Fixes error: exception specification in declaration does not match
  previous declaration

Amends c962b8c2df8e8a2cbbb7fc4eceebc37bcf3506b9

Change-Id: I7e27ffd5bb3aa4c71680809268d86ba25242833a
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2020-06-26 18:42:59 +02:00
Friedemann Kleint
8deb43d138 Adapt to moving of UNIX services/themes into QtGui
Task-number: QTBUG-83255
Change-Id: I4770b796eb90c1ff76db940cd0cda44ea47648fa
Reviewed-by: Liang Qi <liang.qi@qt.io>
2020-06-26 10:46:22 +02:00
Shawn Rutledge
f4807a0e1d Adapt to new QPointingDevice API
QTouchDevice has been replaced with a more general QPointingDevice.

All input devices need detailed information and need to be registered
via QWindowSystemInterface::registerInputDevice().  This patch is not
doing that yet; it's just enough to get qtwayland to compile again.

Done-With: Liang Qi <liang.qi@qt.io>
Change-Id: Id3a2e475ed07294a1977004fc72b11e466acc216
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-06-26 10:46:20 +02:00
Alexandru Croitor
01c959c74e CMake: Unify "wayland components" qt_find_package() calls
So that the top-level call in src/CMakeLists.txt finds all the
components, rather than doing it separately in each directory.

This should prevent issues with dependency tracking of found packages
even after the revert of dd7e40b1086020f6a054957f4972720cd6849280 in
qtbase which is found at 8ddd3ee60bff1197b251feadf871fdaeb995ef3b.

Amends a9430f98b399ed39d67ba28544568b898ec55392

Change-Id: I05eef9db2de30a61b1aee532edc331b33fc027fb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Simon Hausmann <hausmann@gmail.com>
2020-06-16 21:22:04 +02:00
Liang Qi
fb8a7a484f Update dependencies on 'dev' in qt/qtwayland
Remove FontDatabaseSupportPrivate/fontdatabase_support-private
in the libraries dependency. The libraries were removed in qtbase in
6be9830d865be32f224e15d13ddefd9c7e176553 and the functionality is now
in QtGui.

Remove PlatformCompositorSupport mentions, it was removed in qtbase
in 7172b5112e5dbf0cb63dec68d2f916a323748aa1, and functionality moved
to QtGui.

Add explicit package dependency on OpenGL, in case if qtdeclarative
modules are missing, so that qtwayland can still be built without
qtdeclarative.

Change-Id: I5e8ec4cddd293e52c288ba629e6ba954c689a803
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-06-16 10:45:07 +02:00
Karsten Heimrich
132579d38c Qt6: Port QtWayland from QStringRef to QStringView
Task-number: QTBUG-84319
Change-Id: I5dc2f4506c149e5f2793cd7cab083278b93a980e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-11 16:55:37 +02:00
Friedemann Kleint
9ef67d0769 Adapt to moving EventDispatchers to QtGui
Task-number: QTBUG-83255
Change-Id: Iea32600c1d2443c86723653a4fb8b568363cd796
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-06-11 16:55:34 +02:00
Jarek Kobus
b4542740df Use QList instead of QVector
Task-number: QTBUG-84469
Change-Id: I4bc7b2eb2913fc828f09f96e21480b76cabf8656
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-08 08:12:48 +02:00
Alexandru Croitor
6ea7ae3c19 CMake: Regenerate configure.cmake files
This adds the required qmake mixing informaiton.

Change-Id: I5732611edfa4bc8f9038f1ad80df00bcb4da6bb2
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-06-04 22:27:35 +02:00
Tor Arne Vestbø
212b040408 Adapt to QPlatformBackingStoreOpenGLSupport removal
Change-Id: Ib655030a51d9f4eb1fa111d7cf8d0215decc5780
Reviewed-by: Johan Helsing <johanhelsing@gmail.com>
2020-06-03 11:53:29 +02:00
Tor Arne Vestbø
c587035d51 Adapt to QtPlatformCompositorSupport removal
Change-Id: Ic85f91d64c625a7196694cb49ff19df0661d5cbc
Reviewed-by: Liang Qi <liang.qi@qt.io>
2020-06-03 11:53:28 +02:00
Alexandru Croitor
e4512b858c CMake: Regenerate projects
Change-Id: I51a365ef29277bfcb3a62d04954dbe109ab6eac7
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-05-26 17:47:21 +02:00
Alexandru Croitor
0d36b9c7d0 Adapt to removal of vulkan_support in qtbase
QtVulkanSupport module has been removed and its content was merged
into QtGui and QtOpenGL in 7a1650e34331f87bab5a9372087d2a1135f9f63a
in qtbase.

Change-Id: I33b567208aebfeb15350ea088cb7fcd092e2a48a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-05-26 13:53:52 +02:00
Marc Mutz
c962b8c2df QWaylandDisplay: replace a QMap<pair<QString,int>, pointer*> with a std::vector<{QString, int, unique_ptr}>
The vector is sorted, so lookup performance is the same, or
better. Insertion performance is worse, of course, at least in big-O
terms, but probably not in practice.

But now the good part: saves a stunning 7.2KiB (0.6%) in text size on
optimized AMD 64 Linux GCC 9.1 builds.

Change-Id: Ie604f83d7d51111430db1d0bb89d8cc3a52301bf
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-18 16:30:14 +02:00
Qt Forward Merge Bot
3addd499bd Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: Ie2b6b40e3ad1e753f051a12c0296206cc884352b
2020-05-14 21:06:48 +02:00
Qt Forward Merge Bot
e0a79f8b29 Merge remote-tracking branch 'origin/5.15.0' into 5.15
Change-Id: I7341fbfbe7c3eeae44a7fea0bf534fda1180ac51
2020-05-14 14:09:27 +02:00
Tony Sarajärvi
f5d3beded9 Blacklist animatedCursor in SLES
Task-number: QTBUG-78317
Change-Id: Ic2fdbf98dc744c659091f46b33de8e8a34ed8cb1
Reviewed-by: Heikki Halmet <heikki.halmet@qt.io>
2020-05-11 09:27:51 +00:00
Shawn Rutledge
4e78f559be Remove uses of QScreen::orientationUpdateMask
It has been removed in qtbase 3e12951c0b35041920989d6089ddb6c2f5c2d3d1.

Task-number: QTBUG-35427
Task-number: QTBUG-38576
Task-number: QTBUG-44569
Task-number: QTBUG-51012
Task-number: QTBUG-83055
Change-Id: I3ec0907185b237c329f4ec34148b19c5a7706c22
Reviewed-by: Liang Qi <liang.qi@qt.io>
2020-05-08 17:54:34 +02:00
Liang Qi
159ffc775b Merge "Merge remote-tracking branch 'origin/5.15' into dev" 2020-04-29 13:53:45 +02:00
Liang Qi
a9430f98b3 Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
	tests/auto/client/xdgoutput/tst_xdgoutput.cpp

Regenerated CMake projects.

Removed duplicate wayland source in
tests/auto/client/xdgoutput/xdgoutput.pro. It's still
referenced via the included shared.pri file. Regenerated
the CMake project to adapt to that. Otherwise the CMake
project fails to configure due to duplicate rules with
a error like the one below

CMake Error at src/compositor/Qt6WaylandCompositorMacros.cmake:13 (add_custom_command):
  Attempt to add a custom rule to output
    tests/auto/client/xdgoutput/wayland-xdg-output-unstable-v1-server-protocol.h.rule

Also use a workaround fix for configuring CMake standalone tests
due to regression introduced by
dd7e40b1086020f6a054957f4972720cd684 in qtbase.

Change-Id: Ib364b851a1fa828c153efbf8653c9e4ef5e618cd
2020-04-29 13:51:58 +02:00
David Edmundson
1a7dedc2d1 Client: Don't send fake SurfaceCreated/Destroyed events
QPlatformSurface relates to the platform window, not the wl_surface.
The events are already emitted by QPlatformWindow on create/destroy.

To preserve compatibility for a previous KDE version it was faked to
emit the events when the wl_surface is created/hidden to keep behavior.
This is no longer necessary, and it has caused multiple errors, the latest
being a crash when switching between sub-menus with the Sway compositor.

[ChangeLog][QPA plugin] QWaylandWindow no longer sends fake SurfaceCreated/Destroyed events.
Use expose events to be notified when a Wayland surface appears.

Task-number: QTBUG-76324
Fixes: QTBUG-81952
Pick-to: 5.15
Change-Id: I2f003bc9da85f032a0053677fd281152099fc9eb
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2020-04-28 10:33:22 +00:00
Eskil Abrahamsen Blomfeldt
29fa4de2f4 Client: Make frame back callback timeout configurable
To avoid rendering when windows are minimized, we try to detect
this case by checking if 100 ms passes after an update before
any frame callback arrives. Wayland expects to drive the rendering
through frame callbacks, while Qt expects to be informed when a
window is no longer visible and will run a tight, vsynced render loop
until it gets the appropriate event. This mismatch causes issues,
and the timeout is an attempt to avoid actively rendering to a hidden
surface by detecting the missing callbacks.

It causes problems on embedded, though, when a device is so
busy that the timeout happens even when the window is visible.

So we introduce a way to configure the timeout. Either increase
its duration if you can guarantee a certain minimum time between
events even with high load, or set it to 0 to disable it completely.
(at the expense of drawing to invisible windows).

Note that this is required for fixing a critical memory leak that
happens when using Wayland on embedded.

This was mistakenly pushed to 5.12 branch, so it will not be
automatically merged upstream. Therefore we have to
cherry-pick it.

[ChangeLog][Client] Added support for QT_WAYLAND_FRAME_CALLBACK_TIMEOUT
environment variable, which can be used to disable or change the
internal frame callback timeout. If you see windows that stop rendering
or minimize on heavy load, then try setting the variable to 0.

Task-number: QTBUG-82914
Reviewed-by: David Edmundson <davidedmundson@kde.org>
(cherry picked from commit 0a0e0eb8dca699858435dec5194b0b8b6ebd3cf8)
Change-Id: I2aeeecb0fab8f7be9b838e477c88eae22b322d75
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
2020-04-28 10:31:04 +02:00
Janne Koskinen
be03178c4f Fix leaking of callback timers
Use two timers to create timeout trigger for framecallback.
Removes multiple timers approach that is subject to race conditions.

This was mistakenly pushed to 5.12 branch which will not be
automatically merged upstream, so it has to be cherry-picked.

Fixes: QTBUG-82914
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit d18c29931b0bc889fff66bdbde89133544ba0529)
Change-Id: I258c0c08f0ac5803192fc0024e40ba72e72c37a8
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
2020-04-28 10:30:26 +02:00
David Edmundson
85f4f2827b Client: Reset wl_egl_window before wl_surface
Semantically we want things in this order as wl_egl_window_create takes
a reference to the wl_surface. Teardown typically is the opposite of
construction.

This brings us in line with GTK which also tears down in this order.

This fixes a repeatable crash when using Nvidia's EGLStreams and closing
a window.

Change-Id: I356dfbba9a7315717c8ecdc7023ca7b047622697
Reviewed-by: Frederik Gladhorn <gladhorn@kde.org>
Reviewed-by: Johan Helsing <johanhelsing@gmail.com>
2020-04-23 09:49:31 +01:00
Qt Forward Merge Bot
377871d8e5 Merge remote-tracking branch 'origin/5.15' into 5.15.0
Change-Id: I09245b4d620fdf75cbee512d6c95aab1b1d54f99
2020-04-23 09:32:43 +02:00
Thiago Macieira
849d741b21 Fix GCC 9 warning about redundant std::move use
qwaylandcursor.cpp:254:21: warning: redundant move in return statement [-Wredundant-move]

Change-Id: I9709abb1c3734e10a7defffd1607e1b3ed279d32
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2020-04-22 14:19:21 -07:00
Allan Sandfeld Jensen
1bef0aa9b8 Don't force gamma-correction off
The freetype backend can now do selective gamma-correcting, but need
to have a useful gamma-value.

Fixes: QTBUG-83636
Change-Id: I89e99d0a63b75d15d70763ee0c2459caa761beee
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-04-21 10:40:17 +02:00
Mårten Nordheim
88eb97dd0a Update connects to QSocketNotifier::activated
The int-overload will in some cases truncate the descriptor.
So it's being replaced. On Linux it won't truncate, so the slot can stay
as int, but we still update which signal to connect to.

Task-number: QTBUG-70441
Change-Id: I516a453c381e8d29464febabfd69c788e58db5fe
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-04-21 07:23:56 +00:00
David Edmundson
592cfb27f8 Client: Remove recursion in data offer retrieval
A loop functions just as well is more readable and uses less stack
memory.

Change-Id: I6f6c6b7b8047c42080fb8b9e0bc3eae96f8872ab
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
(cherry picked from commit 97c1e5337e7e214c4ada98e1cc360b7e674996aa)
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-04-16 12:39:08 +00:00
Alexandru Croitor
58b9cfd916 Fix qtwaylandscanner package dependencies
Use the new API provided in qtbase, to register a package dependency
between the client module and the QtWaylandScannerTools package.
Do the same for the compositor module.

Also register a dependency between the QtWaylandScannerTools package
and the WaylandScanner package.

Also fix the tests condition to check the correct _FOUND variable.

Change-Id: Id961a365715cef2d7d0b8a54ca9000dc3890ffd7
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-26 09:57:26 +00:00
Alexandru Croitor
6f9b27769f CMake: Regenerate and adjust projects after merge
Some of the changes that were needed
- adjusted wayland macros due to changed target names for plugins
- a few direct moc file includes, to get rid of compilation errors
- Threads::Threads linking for a few tests
- a few special cases for QT_FOR_PRIVATE handling because pro2cmake
  doesn't handle those correctly at the moment (they map to
  PRIVATE_MODULE_INTERFACE rather than PRIVATE_LIBRARIES)
- just regenerating all projects

Change-Id: I418ce91b1c69c7388d41eb22b94a93a9e80fa732
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-26 09:57:22 +00:00
Alexandru Croitor
b27b0ac173 Merge remote-tracking branch 'origin/dev' into wip/cmake
Change-Id: Ia76896a4d06240ccc3d95ba478b6ce273c7a0be2
2020-03-26 10:15:35 +01:00
Kai Koehne
c78ea023d4 Fix invalid json in qt_attribution.json
Amends 4d844d364045977

Change-Id: Ifec3dc5d8698229cc0c2f375eebd5a4ebfd62d35
Reviewed-by: Johan Helsing <johanhelsing@gmail.com>
2020-03-19 10:53:00 +01:00
Simon Hausmann
8d8e4f3ffb Fix build after event API changes
Some deprecated functions were removed in dev.

Change-Id: Iad9910051efe0a499f0e0a4f2e151c39ddd0fcd0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-16 13:06:13 +00:00
Simon Hausmann
38ab2bf15f Fix build after header changes in qtbase
QPainterPath is not implicitly included anymore.

Change-Id: I5a7a7c9a69f7cdee04c5ca7798811daac15b7bd5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-16 13:06:09 +00:00
Simon Hausmann
613d0b6603 Fix build after header changes in qtbase
QTouchDevice is not implicitly included anymore.

Change-Id: I4fcfdb70e1850da7243b520df8b2d1deba2e7424
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-03-16 13:06:02 +00:00
Allan Sandfeld Jensen
ef26bf8ff5 Fix incomplete QPainterPath
Fixes: QTBUG-82789
Change-Id: I8cab4edfac68aec81bc86cfdf022c3600f7a32a8
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2020-03-10 13:14:48 +01:00
Samuli Piippo
ecd7d9658d Test the EGL wayland platform extensions before using them
The Khronos headers may be recent enough to have the ifdefs but
implementation might still be missing on some platforms.
Don't use the extensions unless the configure test passes.

Change-Id: I23129115729567fa92bc23da099d27df598fc206
Reviewed-by: James McDonnell <jmcdonnell@blackberry.com>
2020-03-05 08:19:05 +02:00
Edward Welbourne
f5e071ee2c Use Qt::SplitBehavior in preference to QString::SplitBehavior
The Qt version was added in 5.14 "for use as eventual replacement for
QString::SplitBehavior." Move another step closer to that goal.

Change-Id: Ie19f7580d75694982ac26c08ad5aabb73d830494
Reviewed-by: Johan Helsing <johanhelsing@gmail.com>
2020-02-28 15:35:54 +01:00
Johan Klokkhammer Helsing
9b50fed3c4 Client: Delete decoration object when frameless window hint is added
We don't want windows with FramelessWindowHint to have a
zxdg_toplevel_decoration_v1 object, because that allows the compositor to
force server-side window decorations.

We already have code in place that avoids creating the decoration object when
the window is created. However, if the frameless window hint is added after
the window has been shown, then the decoration object has already been created.

The protocol states that if a decoration object is destroyed, the window will
switch back to a mode without any server-side decorations on the next commit...
so this is what we do in this patch.

Unfortunately, there is no clean way to handle the case when the hint is
removed while the window is visible since the protocol explicitly forbids
creating toplevel decoration objects for surfaces with committed buffers.

Discussion is ongoing as to whether this should be fixed in the next version of
the protocol: https://gitlab.freedesktop.org/wayland/wayland-protocols/issues/9

If we want to work around it, it is perhaps possible to destroy and create a
new wl_surface, but ideally, it will be fixed in the next version of the
xdg-decoration protocol and we can just wait for that.

Task-number: QTBUG-80702
Change-Id: I7e76c05fc3629f1fbbba1d18482808fe588e3878
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-02-27 14:55:19 +00:00
Johan Klokkhammer Helsing
75fd4b4669 Client: Workaround for QPlatformWindow::setVisible(true) being called twice
Fixes a crash.

Otherwise we created two shell surface objects in some cases.

Change-Id: Ieded56261061da6acf27ccabba81c8f578ca1596
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2020-02-27 15:16:55 +01:00
Johan Klokkhammer Helsing
a23d0f4587 Client tests for xdg-output unstable v1 version 3
Change-Id: If6d7547c14dfaf06532a83ab2fbda4d0198837dc
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2020-02-27 08:05:04 +01:00
Johan Klokkhammer Helsing
d4027bc3fe Move XdgOutput mocking to shared folder
Change-Id: Ia4fe187d33ddfd25a87dac8567143de6466c75a2
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-02-27 08:04:52 +01:00
David Edmundson
97c1e5337e Client: Remove recursion in data offer retrieval
A loop functions just as well is more readable and uses less stack
memory.

Change-Id: I6f6c6b7b8047c42080fb8b9e0bc3eae96f8872ab
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2020-02-20 16:31:35 +02:00
Johan Klokkhammer Helsing
f8e2c2fb47 Fix compile errors in tests
const qualifiers made default assignment operators invalid.

Change-Id: I8b22a04f6e2f3b9b76a971b0a59f5fdce589c8e5
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2020-02-19 12:39:54 +01:00
Johan Klokkhammer Helsing
e8247e5eb5 Inject OpenGL dependency for backing store
The backing store no longer has OpenGL support by default, so we need to enable
it.

Task-number: QTBUG-74409
Change-Id: Ie132dae523db86091134279ade61cffe2ff10a73
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-02-19 09:57:46 +01:00
Aleix Pol
ea3a3638e6 Make generated files more resilient to crashes
If m_resource is not initialized when calling a send_* method it will
simply crash. This change checks for it beforehand so we get a warning
instead.

Change-Id: I601f9070a35a1b3e595567991f7e54e9a6572c2d
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2020-02-14 13:47:54 +01:00
Johan Klokkhammer Helsing
b74257332f Client: Don't allow decorations for frameless windows
This only fixes it for when Qt::FramelessWindowHint is set appropriately before
the window is shown.

[ChangeLog][QPA plugin] Windows with Qt::FramelessWindowHint no longer
create zxdg_toplevel_decoration_v1, as that allowed compositors to force
server-side decorations.

Fixes: QTBUG-80702
Change-Id: I47a582a59f6682a57128c0c9d4e4b9a6181925a4
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2020-02-13 09:03:00 +01:00
Marc Mutz
f6155a7622 QWaylandCursorTheme: replace a QMap with a C array
The QMap's key is an enumeration with small values (<= 33, as of this
writing), and while the range has a hole, it's not a terribly big one.

So, instead of using a QMap, just use a C array of mapped_type, using
the key as an index into the array. This gives a 'map' with zero
memory allocations.

It also saves a bit more than 700B in text size on optimized Linux
AMD64 GCC 9.1 builds.

Change-Id: If538ba80075f1bbdffd82b070e871391e6a5a6d1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-02-11 02:05:59 +03:00
Johan Klokkhammer Helsing
84209cf53b Client: Implement QPlatformWindow::startSystemResize
Task-number: QTBUG-73011
Change-Id: Ife0d9949b4d4dd7e6f16d3de88d0cb4bf4991e09
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2020-02-05 08:50:56 +01:00
Johan Klokkhammer Helsing
37b79a5968 Client: Update to new signature for startSystemMove()
In a319f4a5, we temporarily disabled the override to let qt5.git update, now we
add it back with the new signature. This means QWindow::startSystemMove now
works for Wayland.

Task-number: QTBUG-81751
Task-number: QTBUG-73011
Change-Id: I1459300d6f7fb77a9ae07bb4f5c2b80722f9b02c
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2020-02-04 11:23:39 +01:00
Qt Forward Merge Bot
4a47f124f5 Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: I064b614b3390d9b744afb3ac437096109b53b1d5
2020-02-01 03:03:20 +01:00
Johan Klokkhammer Helsing
a319f4a597 Client: Temporarily disable QPA startSystemMove
The signature of startSysteMove has changed, remove the override temporarily so
qt5.git can update. Then we can add the correct override back afterwards.

Fixes: QTBUG-81751
Change-Id: I4ef9aec1e8299e853be4ef868ecfc3a374ae6f27
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2020-01-31 11:54:35 +01:00
Johan Klokkhammer Helsing
3a6859e808 Fix build: Add dependency on OpenGL module
Several of the QOpenGL* classes we depend on has moved to QtOpenGL, add
the dependency and fix the include paths.

Task-number: QTBUG-74409
Change-Id: Iab7949dd67befaa71cf2cfa041771e93f4e47160
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-01-30 15:11:21 +01:00
Qt Forward Merge Bot
6c26a60a72 Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: Ibd911372386f9f5fddb13afa05b84af6fe422fdd
2020-01-18 03:05:18 +01:00
James McDonnell
d1d0e2d6b0 Enable QtWayland for QNX
Make EGL 1.5 with EGL_PLATFORM_WAYLAND_EXT a requirement for QNX and
add some EGL 1.5 code alternatives.  Avoids the need to deal with
incompatibility problems between the QNX native display/window type
and Wayland display/window type.

Change-Id: Ib26a020e1f8c7f570c6af08697d8c8153c887294
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Dan Cape <dcape@qnx.com>
2020-01-13 11:50:21 -05:00
Johan Klokkhammer Helsing
84549ae23d Client: Upgrade to xdg-output-unstable-v1 version 3
[ChangeLog][QPA plugin] xdg-output-unstable-v1 version 3 is now supported.

Change-Id: I054b2946e86175eabe76731bac94e5f287c4ee58
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2020-01-13 12:56:29 +01:00
Jarek Kobus
98e42661d5 Don't use deprecated QMatrix class anymore
Task-number: QTBUG-46653
Change-Id: I038a370ca8af642605709fa5ffdb1c619c60433b
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2020-01-10 13:55:04 +01:00
Johan Klokkhammer Helsing
174a93750a Update protocol for xdg-output-unstable-v1
Change-Id: I7d7a2fdbd1f44469b90c467c9490448c13025fa5
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2020-01-09 16:56:47 +01:00
Paul Olav Tvete
cb4ccdac86 Merge remote-tracking branch 'qt/5.15' into dev
Change-Id: Id0bb84667482232cb648f4984e9f9e2ea4c360c6
2020-01-09 16:48:18 +01:00
Johan Klokkhammer Helsing
850506e125 Fix various issues in qt_attribution.json
freedesktop.org is moving over to GitLab, so let's update the urls.

Some entries were also missing a DownloadLocation, or didn't link to a single
version (which they're supposed to according to the documentation). So fixed
those as well.

Also, a couple of spelling fixes.

Change-Id: I37f5365368bc0d97420488c6d62b25adc26590f5
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2020-01-09 15:22:39 +01:00
Johan Klokkhammer Helsing
7c181d3733 Update protocol for linux-dmabuf-unstable-v1
Just updates the text of the protocol, no new functionality.

Change-Id: I08a09b2a3d37f61fc28967fbb1306f35a2921f0a
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2020-01-09 15:22:30 +01:00
Johan Klokkhammer Helsing
03414a616b Update protocol for xdg-shell stable to version 2
This is just the protocol, it doesn't implement any new interfaces or behavior.

Also update the project url, xdg-shell is now part of wayland-protocols, not
Weston.

Change-Id: I719cc99fc2c59af9abfc0c9abcb9c1daf9b43c74
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2020-01-09 15:22:23 +01:00
Johan Klokkhammer Helsing
ece34c57f8 Update to latest release for xdg-shell-unstable-v6
These are just textual changes in the protocol, so shouldn't change anything
except the comments in the generated code.

Change-Id: I0c93f593a171b0af3c9a812c6a45c3b1416b42f6
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2020-01-09 15:22:13 +01:00
Aleix Pol
f31330eeac Add a comment at the top explaining where the generated file comes from
It's useful to have the source of the generated file on top when
reaching it from the IDE. Also it is useful to explain that it's a
generated file at all.

[ChangeLog][qtwaylandscanner] Include a comment on top explaining what
xml file is being represented.

Change-Id: Ie0584295791f246b0e8c83e0afd3a521f6bdbb2e
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2020-01-08 16:13:12 +01:00
Johan Klokkhammer Helsing
4d844d3640 Client: Add basic support for tablet-unstable-v2
[ChangeLog][QPA plugin] Added support for drawing tablets through the
tablet-unstable-v2 protocol.

Adds support for the basic one tablet, one tool, no pads scenario.

Besides the auto tests, I tested with a Huion Kamvas Pro 16 with a simple
pressure sensitive pen with two buttons. As far as I can tell, it works the
same way as on xcb on Sway and Gnome Shell.

Also tested on a Wacom PTZ-630 with a mouse, art pen, airbrush and a stylus.

Mapped the distance event to QTabletEvent::Z and slider to
QTabletEvent::tangentialPressure.

For now we send QTabletEvents even when there's a mouse or finger on the
tablet. Those should ideally be sent as QMouseEvents/QTouchEvents, but that's
out of scope for this patch, but at least we will send synthesized mouse events
if the tablet events are not accepted.

Change-Id: I93291ffa5f00fa2bb8533eddd8d873b84a3386b8
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-01-08 15:33:50 +01:00
Paul Olav Tvete
8abd3e5f55 Don't use deprecated handleMouseEvent()
The new version takes the event type and the button responsible
as arguments. This commit adds logic to figure those out when
mapping touch events to mouse events.

Change-Id: Iadd1cf33aed12a05fcd28c74e2439ac8ac00f632
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2020-01-08 14:47:56 +01:00
Paul Olav Tvete
196c2e3fa8 Fix compiler warnings
Change-Id: Ie0bed19704bed89044d3cf25e7aaa1f740a4b39a
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2020-01-08 12:12:44 +01:00
Qt Forward Merge Bot
2fb685b292 Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: I9ee503ea5150a80b1fd748b841b99521d323bcd9
2020-01-07 03:04:11 +01:00
Johan Klokkhammer Helsing
6111649b41 Client: Don't use deprecated handleMouseEvent version
The new version requires the button that caused the event, as well as the event
type. Instead of adding a conversion functions to and from
QWaylandInputDevice::Type to QEvent::Type, just use QEvent::Type directly, as
there is one-to-one mappings for all the event types we need.

Fixes: QTBUG-80044
Change-Id: I0f6e0e8e7f2e026a1d601f86e819affe0570a1b2
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2020-01-03 23:47:02 +01:00
Johan Klokkhammer Helsing
5220e49295 Stop using modern C++
Fixes compilation errors with c++11.

Fixes: QTBUG-81024
Change-Id: I13ae380a122a2d52b7b362a7a39e661a22c74afc
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-12-31 10:37:31 +00:00
Johan Klokkhammer Helsing
84c2b4802f Client: Add QWaylandWindow::mapFromWlSurface
Qt window coordinates start inside the decorations, while wl_surface
coordinates start at the first pixel of the buffer. Potentially, that would be
in the shadow, although we don't have those. So for now, it's the first pixel
of the decorations.

Change-Id: Idccf8a359035f5477d6bc9e2e03a0e9fafe16971
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-12-30 12:33:29 +01:00
Liang Qi
b21eacfa57 Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts:
	.qmake.conf
	src/client/configure.json

Change-Id: I6afd4de5bcca36bebb7bfb479f8237a12e18dd5b
2019-12-30 11:46:46 +01:00
Jan Alexander Steffens (heftig)
85d216ad0f Drive cursor animation with a timer
Using only wl_surface_frame callbacks to update the cursor does so much
more often than needed. In addition, at least GNOME and Weston fire the
callback for the cursor surface immediately, which ends up updating the
cursor at over 3000 Hz here.

Use wl_cursor_frame_and_duration to drive a single shot timer. This
function is also guaranteed to return 0 for single frame cursors, so we
can avoid starting the timer at all.

We wait for both the surface frame callback and the timer to fire before
updating the cursor for the next frame of animation. This reduces our
update rate to the frame rate of the cursor or the rate requested by the
compositor, whichever is lower.

Change-Id: I10277460ebe9b547ebaf7f73424b9ef17614107f
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-12-17 12:02:23 +01:00
Johan Klokkhammer Helsing
fbc93070ad Client: Fix inverse repeat rate implementation
The rate from wl_keyboard.repeat_info was used as if it was an interval. Fixed
by converting from key strokes per second to milliseconds per key stroke.

This fixes a regression, as repeat rate used to be hard-coded to something
sensible before.

[ChangeLog][QPA plugin] Fixed keyboard repeat rate being set inversely, so
higher rates would actually result in fewer characters per second, and vice
versa.

Fixes: QTBUG-80613
Change-Id: Ie783b90cba13dde6f37c0cd1be584d352cddfe7c
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-12-17 09:30:48 +01:00
Jan Alexander Steffens (heftig)
2f1b67c17b Client: Fix detection of linux-dmabuf
Change I84c8c1008724b49b6bedb4fc3ef398e292f1c6c7 fixed the tests in
compositor/configure.json but missed the test in client/configure.json.

Change-Id: I65ad424406438baa74ca80a9418e133510142118
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-12-15 16:30:03 +01:00
Ulf Hermann
2a13fba24b Wait for window.isExposed() in flushUnconfiguredXdgSurface() test
We generally don't expect the window to react synchronously, as shown in
other tests that already have the QTRY_VERIFY(window.isExposed()). Add
the waiting behavior to flushUnconfiguredXdgSurface() in order to avoid
flakiness.

Change-Id: I5824be0a806ec4bd0df30b3187a6549fd81d16be
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-12-12 12:14:40 +01:00
Qt Forward Merge Bot
1f54136d65 Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: I1f9418f4f5783291286417f6faf6277e0679007c
2019-12-10 03:03:32 +01:00
James McDonnell
7b3936cd06 Adjust the Wayland Vulkan configuration tests
Define VK_USE_PLATFORM_WAYLAND_KHR before the vulkan.h include so
the test will fail if the Wayland WSI header doesn't exist.

Require features.vulkan so that vulkan related code won't build
when --disable-vulkan is used.

Change-Id: I275efcb3e728b59c6f99598c235074b941f1fbf0
Reviewed-by: Dan Cape <dcape@qnx.com>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-12-06 13:35:38 -05:00
Johan Klokkhammer Helsing
d637993c5f Add client test for hiding the toplevel parent of a popup
This used to cause undefined behavior.

Task-number: QTBUG-80562
Change-Id: I0397b7b304f316616d2a713063bc5a634dc081bc
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-12-06 12:53:12 +01:00
Johan Klokkhammer Helsing
e86d199546 Client: Always close popups when hiding a window
It's not just popups that may have popups open on them. Always close open
popups when hiding a window to prevent dangling pointers.

[ChangeLog][QPA plugin] Fixed a crash when re-showing a popup after hiding its
parent.

Fixes: QTBUG-80562
Change-Id: I7cdac5c7a30e0add5ebf00259401e4d74626ce96
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2019-12-06 12:53:03 +01:00
Johan Klokkhammer Helsing
e3764dff85 Client tests: Fix missing frame event
Change-Id: I8bda37560ff8b3c97699831427b0a148f8a5970c
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2019-12-05 15:00:25 +01:00
Qt Forward Merge Bot
72ff196c47 Merge "Merge remote-tracking branch 'origin/5.14' into 5.15" 2019-12-04 14:32:28 +01:00
Johan Klokkhammer Helsing
5b53f5c762 Client: Add test for a compositor with no outputs
This needs to be a separate test and can't be part of tst_output because there
is special screen handling at platform integration initialization, which only
happens once per test process.

Task-number: QTBUG-79111
Change-Id: Iad9f98be6807c9071c783db1fa8e8c81a7de08be
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-12-04 11:42:42 +01:00
Qt Forward Merge Bot
063c48d8f4 Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts:
	src/compositor/configure.json

Change-Id: Id608424a63a4bcef4adb3f66d55a3cc32c86f2a2
2019-12-03 08:10:44 +01:00
Johan Klokkhammer Helsing
d9b7325cc0 Add client test for touch down and motion in same frame
Task-number: QTBUG-79744
Change-Id: Ibb8239b4f53a345105bee3cc7a0fb4b777cabf9b
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-11-29 11:27:55 +01:00
David Edmundson
b8b8c1ce5a Avoid animating single frame cursors
Currently to determine if a cursor is animated or not we check the
cursor theme delay.

This doesn't work in practice as by default many cursor themes have a
delay of 50 set even if they don't animate.

This comes from xcursorgen which specifies a delay of 50ms if there
isn't anything set in the config.
(https://github.com/freedesktop/xcursorgen/blob/master/xcursorgen.c#L92)

Given many themes will have a delay we should also check the number of
images in a given cursor.

In order to do that without a double lookup QWaylandCursor needed to
return the native wl_cursor, not wl_cursor_image and move the relevant
logic.

Change-Id: Ie782ace8054910ae76e61cab33ceca0377194929
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-11-28 13:01:19 +01:00
Johan Klokkhammer Helsing
7279debf1b Initial CMake port
The client, compositor, tests, plugins and examples now build.

There are still a few minor issues:

- The protocol source generation is a bit hacky.
- The tests for checking if building CMake projects don't work anymore as they
  have Qt 5 specific code. They have just been commented out for now.

Fixes: QTBUG-78177
Change-Id: Ie17cb05f0cdbd5b098970ce765adaeccf61a8fde
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
2019-11-26 11:29:29 +00:00
Qt Forward Merge Bot
4593b24945 Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: If5fcfe5252c1ac1db63ec77136b186a104280b57
2019-11-23 03:01:14 +01:00
Johan Klokkhammer Helsing
857cbf0779 Fix spelling of linuxaccessibility_support-private
Fixes issues with the cmake conversion tool.

Task-number: QTBUG-78177
Change-Id: I49edbcba7494d1916cf6bf976148c9433615d8a0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-11-18 08:53:09 +01:00
Johan Klokkhammer Helsing
3ba851c777 Client: Add test for removing and adding a screen at runtime
Task-number: QTBUG-79111
Change-Id: I4b8f08148850fe02972266936ba7d8d6ed1f36bb
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-11-12 13:35:23 +01:00
Johan Klokkhammer Helsing
b5f100975d Client: Support running with no screens
[ChangeLog][QPA plugin] The QPA plugin now supports running with no screens
attached. This is handled by adding a fake screen when the last screen is
disconnected, similarly to what the other QPA plugins do.

Fixes: QTBUG-79111
Change-Id: I4a0e023ae784217dd030f0c62f12487fdff4825c
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-11-12 13:34:05 +01:00
Qt Forward Merge Bot
1f79914369 Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: I9ad2f46e216c431c9388ad6b45848277ba481808
2019-11-12 03:05:13 +01:00
Qt Forward Merge Bot
f2e7a1ddd3 Merge remote-tracking branch 'origin/5.13' into 5.14
Change-Id: I24b2eade3e8946a654ef6cf3d02ea95255aa1c00
2019-11-12 03:05:02 +01:00
Qt Forward Merge Bot
058dc12df8 Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: Idf4c63d08423691afd8823c734ba79085aa9e14f
2019-11-09 03:05:28 +01:00
Johan Klokkhammer Helsing
51bf0a1d2c Merge remote-tracking branch 'origin/5.15' into wip/cmake
Conflicts:
	src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp

Change-Id: I6c6e05f76abcea8a315fe3ba471c4aa2139127b5
2019-11-07 15:34:19 +01:00
Johan Klokkhammer Helsing
bf1336af6a Fix race condition in tests on xdg_toplevel configure
Tests should not use non-direct connections, as that means tests can run when
the compositor is not locked.

Change-Id: I7b1f0e3bb866db540f72307ad96f778ec0edd7ee
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-11-07 15:01:42 +01:00
Johan Klokkhammer Helsing
9d186a4dd5 Fix touch being ignored when down and motion are in the same frame
The Wayland protocol gives no guarantees about which events are part of a
frame, so handle the case where we receive wl_touch.down and wl_touch.motion
within the same frame.

Fixes: QTBUG-79744
Change-Id: I5dd9302576d81da38e003c8e7e74da6a98def603
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-11-05 13:19:01 +01:00
Liang Qi
aab418b27b Merge remote-tracking branch 'origin/5.13' into 5.14
Conflicts:
	src/client/qwaylanddisplay.cpp
	src/client/qwaylandwindow.cpp

Change-Id: I30ddf5305b3087b93cf4d6e562fd0146dea61cc0
2019-11-05 11:35:46 +01:00
Johan Klokkhammer Helsing
41216bedd4 Add client test for subsurface with hidden parent
Task-number: QTBUG-79674
Change-Id: I451ee4423dee511f41070498a61167912920c086
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-11-04 13:41:11 +00:00
Johan Klokkhammer Helsing
8d409b0952 Client: Fix crash when showing a child window with a hidden parent
[ChangeLog][QPA plugin] Fixed a crash when showing a window with a hidden
parent.

Now we just avoid creating the subsurface, so nothing is shown. Seems to be
the same behavior as on xcb.

Fixes: QTBUG-79674
Change-Id: Ia46fcd9a0da5aad4704816a41515cb1e128ac65f
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-11-04 13:40:56 +00:00
Johan Klokkhammer Helsing
027f48b7d9 Add basic client test for subsurfaces
Change-Id: I1ef21287933a2afccad989f47e4fe59329b6f537
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-11-04 13:00:54 +01:00
Simon Hausmann
3909d1aaa9 Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
	src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp

Change-Id: I42733f5ad9429a5d2ff6c804eb1f3f2d50f50811
2019-10-31 14:42:48 +01:00
Simon Hausmann
a77043248c Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: I29524a74e495dd46c0dc5d0a0d10e41e55526f14
2019-10-31 12:37:35 +01:00
Johan Klokkhammer Helsing
5e5235e0e6 Client tests: Fix flaky deadlock
Sometimes the test would wait indefinitely in the compositor constructor, while
also waiting in the compositor thread for m_ready to become true.
m_ready is set to true in applicationInitialized(), which is supposed to be
called from the client thread after QGuiApplication has been created (and also
after the MockCompositor constructor has returned).

I.e. the problem is that the wake in MockCompositor::run may sometimes
happen before the MockCompositor::MockCompositor starts waiting.

Move the wake inside the pre-initialized compositor loop. Essentially waking
every 20 ms until the application is initialized.

Fixes: QTBUG-66570
Change-Id: Ia5eba5d08ce4d1d3eeca99eae6cfa7d9d4fd5a0b
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-10-31 11:17:00 +00:00
Johan Klokkhammer Helsing
d37d4cbb90 Merge remote-tracking branch 'origin/5.13' into 5.14
Conflicts:
	.qmake.conf

Change-Id: If2159587c5183fcf57558f045bd9af2f25c8289f
2019-10-31 11:15:47 +01:00
Johan Klokkhammer Helsing
68e70fd950 Set temporary XDG_RUNTIME_DIR for more tests
Some tests were left out when we switched to using a temporary XDG_RUNTIME_DIR.

Fixes: QTBUG-79652
Change-Id: I8208d63f3f6a937406d25b1a8cf3f5b0be04bc73
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-10-31 10:28:20 +01:00
Qt Forward Merge Bot
6eff8e011a Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: I25e65c392612cc1c379bd408adb60559b1d8a498
2019-10-26 03:06:44 +02:00
Qt Forward Merge Bot
2878e70241 Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: If09bb13aa7a0aadd5cfb8265166d3b9d1b22e2f1
2019-10-26 03:06:36 +02:00
Qt Forward Merge Bot
deef840f1f Merge remote-tracking branch 'origin/5.13' into 5.14
Change-Id: Ie283d8861ecf11f21621ab18efdc780143559b52
2019-10-26 03:06:28 +02:00
Johan Klokkhammer Helsing
a3e5de6c0d Client: Add Vulkan support for Wayland
Inspired by the xcb version.

hellovulkantriangle runs smootly, but freezes in some multi-monitor
setups.

[ChangeLog][QPA plugin] Added Vulkan support.

Fixes: QTBUG-78000
Change-Id: I8711b5b47e4b71cde78295aab9acb3f5945b141b
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2019-10-25 10:09:05 +02:00
Johan Klokkhammer Helsing
f8651a551d Fix QClipboard::ownSelection always returning false
It would return false regardless of whether we owned the selection.

Change-Id: I6df394d8dbceeccb6eb6d0670b4351af1a158491
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-10-25 09:20:00 +02:00
Johan Klokkhammer Helsing
94ea0eaf83 Fix missing emission of QClipboard::selectionChanged
And add a test to verify we've fixed it.

Change-Id: Ic6d5e64b3000444465935f7caf7e32ec9c4f1012
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-10-24 11:07:03 +02:00
Johan Klokkhammer Helsing
87b4273398 Client tests: Set WAYLAND_DISPLAY
The tests would previously fail if WAYLAND_DISPLAY was set to something other
than empty or wayland-0. For instance when running multiple compositors and
trying to run the tests, they would fail because they create a compositor on
wayland-0 (using wl_display_add_socket_auto()), but would try to connect to
wayland-1 due to the env var.

Change-Id: I7771d41737410d5c32f5a6db3de4987096cb4d22
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-10-24 09:29:16 +02:00
Johan Klokkhammer Helsing
37e0cd278a Add client test for clipboard when losing keyboard focus
Also, verifies that we fixed a recent bug about QClipboard::dataChanged not
being emitted when the clipboard is invalidated due to losing focus.

Change-Id: Ie92b618a4f673c21d6582979249700aef8785536
Reviewed-by: Pekka Vuorela <pvuorela@iki.fi>
2019-10-23 11:48:09 +02:00
Pekka Vuorela
7cc704a3a7 Signal clipboard change when focus lost clears the selection offer
Change-Id: I311a5d422f31347029795dbd2479a771ae93c01f
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-10-22 09:59:29 +03:00
Pekka Vuorela
eda76963a8 Fix url getting broken on openUrl
UTF-8 byte array cannot be split in random position and assume getting
valid content on resulting parts. Switched chunk size to be based
on characters, encoded size will vary but don't think that should matter.

Change-Id: Ic41ea16d2111b1620993b60fdbc6e739929f25d7
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-10-21 18:28:58 +03:00
Johan Klokkhammer Helsing
e38ac423a0 Client: Print a warning when trying to set clipboard without a seat
This warning can save some time when trying to understand why some
qtbase auto tests are failing on headless Weston (which doesn't have
seats at the moment).

Change-Id: I361546611d12bff8a465af5bb103f61e80d73a15
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-10-21 12:41:08 +00:00
Johan Klokkhammer Helsing
bd3dd42bd5 Merge remote-tracking branch 'origin/5.13' into 5.14
Conflicts:
	src/client/qwaylandwindow.cpp
	tests/auto/compositor/compositor/tst_compositor.cpp

Change-Id: Iacfcae577a4a99c847694ae3a2c6e3e9ae050817
2019-10-21 09:23:06 +02:00
Qt Forward Merge Bot
d91b1b2796 Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: Ie9d7d49216b7d03f83306cf06f6439080f3457a3
2019-10-19 03:02:23 +02:00
Johan Klokkhammer Helsing
da9d36b394 Client: Fix 100ms freeze when applications do not swap after deliverUpdateRequest
[ChangeLog][QPA plugin] Fixed a 100 ms freeze that would occur if applications
did not draw after receiving a deliverUpdateRequest().

QtQuick does this at the start of animations. This should get rid of those
backingstore warnings (and also remove a 100ms freeze before animations start
in those instances).

Fixes: QTBUG-76813
Change-Id: Id366bf4a14f402fa44530ae46e7b66d9988c14f6
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: John Brooks <john.brooks@qt.io>
2019-10-17 08:13:27 +02:00
Johan Klokkhammer Helsing
918cc075b9 Fix build: Use temporary directories for tests' XDG_RUNTIME_DIR
Using XDG_RUNTIME_DIR="." does not work after qtbase 5542785, and it was a
rather brittle solution anyway.

Fixes: QTBUG-79185
Change-Id: Iaf9ced66709cc6cbac8a2d54efc64e1a8c528561
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-10-14 13:18:34 +00:00
Qt Forward Merge Bot
9bc8d437d1 Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: Ia858f86e6a281f03bea17d0cc6bca300833ccda3
2019-10-12 03:07:23 +02:00
Johan Klokkhammer Helsing
553b673ec3 Merge remote-tracking branch 'origin/5.15' into wip/cmake
Conflicts:
	src/client/configure.json
	src/compositor/configure.json

Change-Id: If7d6d78d38bc2b6cc1deda389960b5b0c048e922
2019-10-10 08:34:43 +02:00
Johan Klokkhammer Helsing
f3552aebda Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: I45b8d2d8a6c512a38a6775bb0fe95358623cef99
2019-10-09 15:31:58 +02:00
Joerg Bornemann
5d83deaad2 Add missing config tests for wayland, glx, xcomposite
The intention of 9b228df was to inline all the tests and delete the rest.
Unfortunately, some tests were deleted without being inlined, which led to the
tests failing, which in turn led to nothing being built.

This was not detected by coin, as configure currently passes although nothing
is built.

Fixes: QTBUG-79057
Change-Id: Ib09538ebf4b2d369d0fc1087f4b8fbea93d8c5b3
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2019-10-08 06:37:34 +00:00
Paul Olav Tvete
7ddc7a34a4 Make qtwaylandscanner accept named arguments and add --add-include
Task-number: QTBUG-78177
Change-Id: I275cd815e0fe737af94fc46580ec9756eba54451
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-08 08:37:14 +02:00
Paul Olav Tvete
73c004699d Merge remote-tracking branch 'qt/wip/qt6' into dev
Change-Id: I8d16410f0c400ee685774722d210d6f5986de843
2019-10-02 15:59:44 +02:00
Johan Klokkhammer Helsing
b23bbe37d4 Merge remote-tracking branch 'origin/dev' into wip/cmake
Change-Id: I58395e0c31cfcd08bf799c3e069bbbed32709a3d
2019-10-01 16:39:33 +02:00
Kari Oikarinen
276a64e0f4 Remove unused member variable
Change-Id: I767ece2b090f95947fce34e743eec37299e62749
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-10-01 16:44:52 +03:00
Johan Klokkhammer Helsing
a5ecdff181 Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: I78da93b3045a65ae0024ac232b9eaa79bc1fe3e7
2019-10-01 15:33:50 +02:00
Qt Forward Merge Bot
9ad1924f55 Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: Iab50e5a4af2e2adc4dd40575b7039dadb6d514b5
2019-10-01 03:02:23 +02:00
Qt Forward Merge Bot
9ae85568d8 Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: Ib52352036df229b4047d0c19f713ae2436741993
2019-10-01 03:02:15 +02:00
Qt Forward Merge Bot
19660bcc51 Merge remote-tracking branch 'origin/5.13' into 5.14
Change-Id: Ie236fa47c23456b15414c3b3e89568b915979ebe
2019-10-01 03:02:06 +02:00
David Edmundson
235f8f12fa Client: Create context menu event when pressing the menu key
Effectively is a copy of the code in XCB. When the menu key is pressed,
a context menu event should be generated at the current cursor position.

The global position in the event isn't truly global as that doesn't
exist in wayland but should match client expectations.

Change-Id: Ib814883aba632ca5eec58730846e1762b680467f
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-09-27 23:35:46 +01:00
Qt Forward Merge Bot
0f2472eb8b Merge "Merge remote-tracking branch 'origin/5.13' into 5.14" 2019-09-25 13:12:37 +00:00
Johan Klokkhammer Helsing
f27301cc81 Merge remote-tracking branch 'origin/dev' into wip/cmake
Change-Id: I97ddf642ce133ffcb3ef96714cc71e6acd1692d5
2019-09-25 14:19:53 +02:00
Johan Klokkhammer Helsing
fab564c40b Configure: Remove libs.glx
libs.glx just checks if we can can link against x11 and gl, this should already
be covered by features.xlib and features.opengl.

Also, it probably makes sense to not build these plugins if Qt is configured
with no-feature-xlib.

Task-number: QTBUG-78177
Change-Id: I56ccdc80a4601ccbf03cc5e65abe0adb3a579f99
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-09-25 11:38:56 +00:00
Johan Klokkhammer Helsing
7c4b2334a3 Client: Don't crash with long window titles using UTF-16 characters
Previously, we set the max length in QString character length, which means
UTF-16 characters (of potentially three bytes) counts as one character. The max
limit of libwayland, however, is in bytes (and the string itself is converted
to UTF-8).

Fix it by dividing the character limit by three because in the worst case each
UTF-16 character will use three bytes when UTF-8 encoded.

Fixes: QTBUG-78478
Change-Id: Idf4721894e0fe6f3cd92bdc6ada7b0ea4199ea63
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-09-25 10:54:58 +00:00
Qt Forward Merge Bot
45d5480224 Merge remote-tracking branch 'origin/5.13' into 5.14
Conflicts:
	sync.profile

Change-Id: I6f6d44ec285d37e64e430303ef9a87ac7aaf3eb9
2019-09-24 10:27:35 +00:00
Qt Forward Merge Bot
0440281785 Merge "Merge remote-tracking branch 'origin/5.15' into dev" 2019-09-24 03:03:21 +02:00
Qt Forward Merge Bot
ce491542d9 Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: I3bbf053a35ceee52d9953a676bacec2b9299bad5
2019-09-24 03:03:15 +02:00
Qt Forward Merge Bot
46430bda8f Merge "Merge remote-tracking branch 'origin/5.14' into 5.15" 2019-09-24 03:03:13 +02:00
Qt Forward Merge Bot
c2bcb08f4e Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: If74515ed4f4de1bad1eca7b5cd4d5e9191197977
2019-09-24 03:03:07 +02:00
Johan Klokkhammer Helsing
79196d3877 Use new ifdef style for accessibility_atspi_bridge
Change-Id: I9537017198ef3be862b22b2ed893f9438dc92b65
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-09-21 06:52:11 +02:00
Johan Klokkhammer Helsing
6f83656747 Client: Test that wl_touch.up events don't split touch frames
We have a workaround for Weston not sending wl_touch.frame events after
the last wl_touch.up event. It calls Touch::touch_frame to generate a
fake event. The problem, however, is that it used to erroneously do this
on wl_touch.up events even when it was not for the last touch point.

This in turn, lead to extra frame events being inserted in the middle of
a touch sequence, effectively splitting up one touch frame into
multiple. Accumulated touch state would be handled prematurely,
preventing wl_touch.cancel from working correctly for instance.

This tests that we've stopped doing that.

Change-Id: Ic545bbb18c23b827e5fa07a642a374094d720dae
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-09-20 16:09:48 +02:00
Johan Klokkhammer Helsing
7dfa3f9d50 Fix wrong target name for tst_client_fullscreenshellv1
Task-number: QTBUG-78177
Change-Id: Id44794523511241b408e79383e438e52f769d62a
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-09-20 11:31:45 +02:00
Johan Klokkhammer Helsing
9b228df785 Convert most config tests to configure.json inline format
And remove the now unused entries in config.tests. Now only the wayland-scanner
test remains, as that uses qmake features that do not easily translate to the
inline format.

This makes it much easier to port QtWayland to cmake.

This also removes some config.tests that weren't used.

Task-number: QTBUG-78177
Change-Id: Ia21a0025f9fac45b9f4815ee0f196e9e5759cdc6
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-09-20 07:28:05 +00:00
Johan Klokkhammer Helsing
13055e46e3 Add client test for multi touch motion
Make sure touchPoint order doesn't change even though the compositor
event order does.

Task-number: QTBUG-77014
Change-Id: If6b8a930344836ca52cc12fe7f29c8ac863d81ba
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-09-17 09:51:45 +02:00
Jan Grulich
00a2ff93f6 Use QGenericUnixTheme to provide themes
This makes wayland platform plugin to use same platform themes as xcb
plugin, which also can load platform theme plugin for apps running in
Gnome.

Change-Id: I9f4e3504d153e26c5580d9e33443d8a11201cd52
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-09-17 06:49:34 +00:00
Liang Qi
36663a187d Blacklist tst_seatv4::animatedCursor() in b2qt
Task-number: QTBUG-78317
Change-Id: I66e35782470cedd4d3cfeed6ffdfd8d54bc0ba26
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2019-09-17 07:39:23 +02:00
Qt Forward Merge Bot
235308df7e Merge "Merge remote-tracking branch 'origin/5.15' into dev" 2019-09-17 03:07:29 +02:00
Qt Forward Merge Bot
5d790b82f6 Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: I416564cb07c9b3e9d88c7924abc44e3947b6ab4f
2019-09-17 03:07:23 +02:00
Qt Forward Merge Bot
e25bc957ff Merge "Merge remote-tracking branch 'origin/5.14' into 5.15" 2019-09-17 03:07:21 +02:00
Qt Forward Merge Bot
0d39c32532 Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: I1fdf822938737aebe0c13a2eba9e478ba8f8ba14
2019-09-17 03:07:15 +02:00
Simon Hausmann
95ce296968 Merge "Merge remote-tracking branch 'origin/dev' into wip/qt6" 2019-09-16 23:11:57 +02:00
Johan Klokkhammer Helsing
527a890cd3 Add client test for floating point touch
Task-number: QTBUG-77457
Change-Id: I49df80f3e00d349fed273363cd2625b841c085c5
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-09-16 15:36:42 +02:00
Johan Klokkhammer Helsing
582bdeb65c Merge "Merge remote-tracking branch 'origin/5.13' into 5.14" 2019-09-16 12:35:38 +02:00
Johan Klokkhammer Helsing
26fd653154 Merge remote-tracking branch 'origin/5.13' into 5.14
Conflicts:
	src/client/qwaylanddatadevice.cpp
	src/client/qwaylandinputcontext.cpp
	src/client/qwaylandinputdevice.cpp
	src/client/qwaylandwindow.cpp
	src/compositor/compositor_api/compositor_api.pri
	src/compositor/compositor_api/qwaylandquickitem.cpp

Change-Id: Ice0d8c7d869c9c46113d6ee6ba3adf895a71d58f
2019-09-16 08:17:12 +02:00
Andy Shaw
fe5f437f31 If egl_x11 is not available then don't turn on xcomposite-egl
Since xcomposite-egl depends on the egl_x11 feature in qtbase, then this
should be explicit.

Change-Id: Ic1dce9526fb50f6f56e18abd58b69bcaed6d204e
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-09-13 13:08:56 +02:00
Johan Klokkhammer Helsing
fea2383cf1 Add client test for floating point mouse press
Change-Id: Ia7cfb1bc86945e08a2ff2c794afb405110e819f9
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-09-10 14:22:53 +02:00
Johan Klokkhammer Helsing
c9994d46fe Client: Fix touch rounding errors
Touch now accounts for fractional input in the same way as for pointer
input.

Task-number: QTBUG-77457
Change-Id: I18e633bf7c7033187a641f757b8b24f52479971a
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-09-09 18:39:39 +00:00
Johan Klokkhammer Helsing
3b34e5f86d Client: Add test for starting a drag operation without input focus
This used to crash the client.

Task-number: QTBUG-76368
Change-Id: I855f3bda15b4b2bccbdb2aa8239e26c0eecf7cb3
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-09-09 20:00:43 +02:00
Qt Forward Merge Bot
0816fda053 Merge "Merge remote-tracking branch 'origin/5.12' into 5.13" 2019-09-08 11:32:22 +02:00
Qt Forward Merge Bot
7a7c60d4b6 Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I5d587b79b96d2b44f1975419a658c259c63fa30d
2019-09-08 11:32:16 +02:00
David Edmundson
dfe1739bda Client: Disable key repeating when rate is set to 0
From the docs of repeat_info:

"A rate of zero will disable any repeating (regardless of the value of
delay)."

Avoiding starting the initial timer effectively disables everything

Change-Id: I7489f61b2bc0e000efddb4255f1968072eeff2b8
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-09-08 08:11:46 +00:00
Qt Forward Merge Bot
66e0c33ac3 Merge "Merge remote-tracking branch 'origin/5.12.5' into 5.12" 2019-09-07 13:10:09 +02:00
Qt Forward Merge Bot
d9e2ca7e1e Merge remote-tracking branch 'origin/5.12.5' into 5.12
Change-Id: Ic73262146f51a9e7f4ffab46511654ad70c4f514
2019-09-07 13:10:03 +02:00
Qt Forward Merge Bot
44950f9b00 Merge "Merge remote-tracking branch 'origin/5.14' into 5.15" 2019-09-05 09:01:51 +02:00
Pavel Tumakaev
c3960e5997 Fix deadlock in QWaylandWindow::waitForFrameSync
Calling the QOpenGLContext::swapBuffers from
QGuiApplicationPrivate::processExposeEvent in some cases leads to
recursive calls of QWaylandWindow::waitForFrameSync. Since the
mWaitingForFrameCallback check in WaylandWindow::waitForFrameSync
is performed after the mutex is locked, the QMutexLocker tries to lock the
mFrameSyncMutex mutex in every recursive call, that leads to a deadlock.
This patch moves the performing of the mWaitingForFrameCallback check
before locking the mutex.

Change-Id: Ia2d834b7dd03fcd91bbe29a3a897b4db2d155527
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-09-04 14:38:29 +03:00
Johan Klokkhammer Helsing
1830187471 Client: Don't spam stderr about ignored window states
Since it is not supported by the protocol, neither we, nor the
application developer can do anything about it.

Change it from warning to debug so it only shows up when enabled.

Task-number: QTBUG-76061
Change-Id: I81420e0c72a9e9652f6592d65c70c7df1e5725b9
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-09-03 12:01:42 +02:00
Johan Klokkhammer Helsing
c357505f3a Client: Adjust for window border when setting text-input cursor rect
set_cursor_rectangle takes wl_surface coordinates, but we sent window
coordinates.

Fixes: QTBUG-77987
Change-Id: Ia0bf98f9749723128bec27c3c607d1ccde2d5fd3
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
2019-09-03 12:00:38 +02:00
Johan Klokkhammer Helsing
47340e8c6f Add client test for xdg-decoration-unstable-v1
And verify that we don't create decorations prematurely.

Change-Id: I621631f0c355529e5afb6a615f909f18c2a4b509
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-09-03 10:11:52 +02:00
Johan Klokkhammer Helsing
b3311946c2 Merge "Merge remote-tracking branch 'origin/5.13' into 5.14" 2019-09-03 09:11:32 +02:00
Johan Klokkhammer Helsing
b7aaa2782a Merge remote-tracking branch 'origin/5.13' into 5.14
Conflicts:
	src/client/qwaylandinputdevice.cpp
	src/client/qwaylandwindow.cpp

Change-Id: Ifd64debc484197829d2fe412afa98c29b382efa5
2019-09-03 07:24:14 +02:00
Johan Klokkhammer Helsing
f199375e5c Client: Fix crash on wl_pointer.up after destroying a window
When wl_pointer version 5 was implemented, we added a raw QWaylandWindow
pointer in QWaylandPointerEvent. This is a problem, because the events
are stored, and the window may be deleted in the meantime.

This manifested itself as flakiness in tst_xdgshell::popup() which is
now fixed.

Fixes: QTBUG-77976
Change-Id: If34eee0286d5a63734535d67503378516d5768c3
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-09-02 11:35:12 +02:00
Qt Forward Merge Bot
1a010d56e4 Merge "Merge remote-tracking branch 'origin/5.14' into dev" 2019-08-29 21:25:08 +02:00
Qt Forward Merge Bot
c9286ee0ab Merge remote-tracking branch 'origin/5.14' into dev
Change-Id: I79b13be3475d5d251144d7b3de93595ab8c656f9
2019-08-29 21:25:02 +02:00
Johan Klokkhammer Helsing
84acc4a4e9 Client: Refactor touch handling and fix various bugs
Rename mTouchPoints to mPendingTouchPoints, to clarify that they're the
accumulated state so far, which will be applied with the wl_touch.frame
event. QWaylandInputDevice::Touch::mPrevTouchPoints is no longer needed
and has been removed.

Fixes the following issues with the old approach:

- touchPointsReleased() only checked mTouchPoints, which was cleared on
touch_frame and populated again on touch_motion and touch_down, which
meant that it could return true even though there were still touch
points left. Leading to the workaround for missing wl_touch.frame events
on Weston being triggered to often.
- Touch focus was cleared on any wl_touch.up event, not just the last
one.
- The order of the touch events was not stable and relied on the order
of the events (QTBUG-77014).

Fixes: QTBUG-77014
Change-Id: Ic3ecdc87e77b0e0276afefd127ad2b965142cbd4
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2019-08-29 13:06:11 +00:00
Johan Klokkhammer Helsing
75ff7d01c5 Merge "Merge remote-tracking branch 'origin/5.12' into 5.13" 2019-08-29 15:03:23 +02:00
Johan Klokkhammer Helsing
090cf5c4b5 Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
	src/client/qwaylandinputdevice.cpp
	src/client/qwaylandintegration.cpp
	src/client/qwaylandwindow_p.h
	src/shared/qwaylandxkb.cpp

Change-Id: Ibac7998502351e93c71c9b786536298657afe3d0
2019-08-29 14:11:20 +02:00
Johan Klokkhammer Helsing
59486fdf3b Client: Don't freeze in QDrag::exec if there was no drag focus
002fade6 fixed a crash when starting a drag without a valid focus, but
there is still a problem, because QDrag::exec will never return because
it's waiting indefinitely in an event loop.

- QWaylandDataDevice::startDrag can now fail by returning false.
- When starting a drag fails, we cancel the drag through
QWaylandDrag::cancelDrag wrapped in invokeMethod.
- Also, don't unnecessarily create a data_source if we cannot start a
drag.

[ChangeLog][QPA plugin] Fixed a freeze that happened when starting a
drag-and-drop operation without a valid source surface.

Change-Id: Iea19b0c92c196a44d1274a966bee4ff519632d34
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-08-29 08:26:01 +00:00
Johan Klokkhammer Helsing
928a81ec13 Client tests: Set XDG_CURRENT_DESKTOP to avoid platform themes
If the client tests are run from within a desktop environment, the
XDG_CURRENT_DESKTOP variable may be set, causing the client to try to
load a platform theme for the user's desktop.

The tests, however, are running against a mock Wayland compositor, so
launching a platform theme that expects to connect to a certain
compositor implementation is probably not a good idea.

And furthermore, if the gtk3 platform theme is used, it will start
binding to interfaces and create wayland objects, confusing our existing
test code.

Setting XDG_CURRENT_DESKTOP to qtwaylandtests will prevent detection of
the (outer) desktop environment, making tests more predictable.

Change-Id: I57fa76e51cecdd0cbe8be6bd075ce67e9d2892bc
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-08-29 07:04:50 +02:00
Sona Kurazyan
93985ff126 Remove usages of deprecated APIs of QWheelEvent
- Replaced the usages of deprecated QWheelEvent::delta() and
  QWheelEvent::orientation() with QWheelEvent::angleDelta().

- Removed the tests for deprecated APIs.

Task-number: QTBUG-76491
Change-Id: I2f9a53d3236bce8ba6cee66ec1b0b933d50518aa
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-08-28 12:33:00 +00:00
Qt Forward Merge Bot
70b66cad43 Merge "Merge remote-tracking branch 'origin/5.14' into dev" 2019-08-28 07:37:35 +02:00
Johan Klokkhammer Helsing
68bbf5fd1c Client tests: Add test for a simple wl_touch tap
Change-Id: I35aec950da0ac0d10cf1fa0c4bc1f56ba232cf89
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-08-27 12:35:33 +02:00
Johan Klokkhammer Helsing
0d745e8b28 Client: Don't try to disconnect destroy handler from destroyed objects
Gets rid of warning about disconnecting null objects on application
exit.

Change-Id: Ie96d4321dfab113622d7059f6849acf15715dfa2
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-08-27 09:02:04 +02:00
Johan Klokkhammer Helsing
74e3dd6d60 Client tests: Add touch infrastructure and simple test
This doesn't test much, but adds the infrastructure needed for more
thorough tests later on.

More or less exactly matches the mocking for wl_keyboard and wl_pointer.

Change-Id: I563bb9be7ccaaf0aa83611e84d051cc307455ccb
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-08-27 08:47:23 +02:00
Kari Oikarinen
e1f3c4f867 Merge dev into 5.14
Change-Id: Iaf121f1db2fea08dd4ce16136b8d68c94b182084
2019-08-27 07:51:18 +03:00
Johan Klokkhammer Helsing
ae5db4fec1 Client tests: Fix incorrect test for keyboard capability
Change-Id: I4e35e86f489941dcce986ba416f3fe55d968d186
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-08-26 16:27:46 +02:00
Johan Klokkhammer Helsing
c0d8e3dc36 Client tests: Add missing cleanup for keyboards
Change-Id: Ia085dbe34b6e3b7cf83b4f55c265e12b1145ab8a
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-08-26 16:27:30 +02:00
Johan Klokkhammer Helsing
b36c46f2d6 Client tests: Remove redundant pointer helper function
Change-Id: If5d435a227b54f566f121331385e849b615fb615
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-08-26 15:55:26 +02:00
Johan Klokkhammer Helsing
464f33e5b4 Client tests: Upgrade tests to wl_seat v5
This means that pointer events need to be followed by frame events.

wl_seat version 4 is tested by the "tst_seatv4" autotest.

Change-Id: Ifa8e6d6edc998853be7cd901003e619029fc6f68
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-08-26 13:55:00 +00:00
Pier Luigi Fiorini
963829b27d Compositor: Add xdg-output unstable v1 support
We already have a client-side implementation in the QPA plugin,
and now we add the server-side implementation.

In order to have a nice declarative API, we let users create a
XdgOutputV1 instance and then associate it with the zxdg_output_v1
object when it is requested by the client.

If the user forgets to create XdgOutputV1 beforehand we post an error to
the client.

To anticipate protocol version 3, we send zxdg_output_v1.done when we
send wl_output.done.

The multi-output example is extended using this protocol.

[ChangeLog][Compositor] Added support for xdg-output unstable v1
Wayland extension.

Change-Id: I1ec5913d8330cc01d7d634d05a289f4dc8b4fd22
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-08-26 09:31:32 +02:00
Paul Olav Tvete
af6490a09c Merge "Merge remote-tracking branch 'qt/5.12' into 5.12.5" 2019-08-23 10:34:58 +02:00
Paul Olav Tvete
2bb9acf847 Merge remote-tracking branch 'qt/5.12' into 5.12.5
Conflicts:
	src/client/qwaylandwindow.cpp

Change-Id: I89fefe5bfc247eeaad3981850efa0faaab3cb145
2019-08-23 09:57:20 +02:00
Pier Luigi Fiorini
43a13f3d97 Client: Expose default input device through integration
Expose the whole default input device to clients.

[ChangeLog][QPA plugin] Expose default input device to clients
through the QPA API.

Change-Id: I2608178f8b0ac09f766434588a280bcc2b30627d
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-08-23 08:31:19 +02:00
Johan Klokkhammer Helsing
d87b6d8231 Client: Crash instead of exit when there's a wayland error
Qt applications should not call exit.

Task-number: QTBUG-75779
Change-Id: I91190b10f8c8e111996cd73283061e6ceaa6b1f6
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-08-22 11:59:48 +02:00
David Edmundson
b4ee20efff Client: Make handleUpdate aware of exposure changes
The wl_surface can be destroyed whilst a render is happening. Calling
wl_surface::frame after the window is reset can crash as wl_surface is
null.

Fixes: QTBUG-77747
Change-Id: I139a9b234cb6acba81d6c1d5fa58629904a25053
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-08-21 17:59:21 +01:00
Andy Shaw
f168c11529 Handle Key_Return explicitly instead of depending on the text
When Key_Return is sent from Qt VirtualKeyboard it will send it as \n
and not \r which means it will be interpreted as an unknown key. So since
we know it will be able to map it in this case, we explicitly account
for it so it can be mapped to the right key.

Change-Id: Id5d8d9653e78975203f80790b7a3d332f0e011fa
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-08-20 12:59:56 +02:00
Johan Klokkhammer Helsing
8b50d2c6cc Fix race condition for client buffer integration initialization
This race happened because QWaylandIntegration::clientBufferIntegration (which
lazily initializes the integration) was called from numerous places including
code that may run on different threads without any kind of syncrhonization.

An example of this is Qt3D, which indirectly and simultaneously calls
createPlatformWindow (from the GUI thread) and createPlatformOpenGLContext
(from its render thread), both of which needs to use the client buffer
integration.

In this patch, we fix it by first checking if the integration is initialized.
In that case, it's safe to use it. Otherwise we lock a mutex, re-check if
initialization has happened on another thread in the meantime, and then finally
we initialize it.

This way we should avoid the expense of mutex locking after initialization is
complete, while still staying race free during initialization.

Fixes: QTBUG-76504
Change-Id: I327840ebf41e014882cb659bc3e4fafb7bdb7a98
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-08-20 12:07:09 +02:00
Johan Klokkhammer Helsing
39b50c36bd Make it possible to build only the compositor module
Reduces unnecessary coupling between the compositor and client modules.

[ChangeLog][Compositor] The compositor module no longer depends on the
client module.

Change-Id: I108e56960835b6c31c450d5ae08a0a101af9422b
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-08-19 15:05:22 +02:00
Johan Klokkhammer Helsing
ec510cb38c Client: Emit wl_surface lifetime signals on QWaylandWindow
Recent changes in QtBase means QtWayland will have to follow the convention of
the rest of the QPA plugins and have QPlatformSurfaceEvent::SurfaceCreated and
SurfaceAboutToBeDestroyed follow the QPlatformWindow (QWaylandWindow) lifetime
and not the lifetime of wl_surface.

Some users were depending on those events to get notified about wl_surface
changes and used QPlatformNativeInterface in order to get the window's
underlying wl_surfaces in responses to the events.

The good news is that QPlatformNativeInterface is private (QPA) API, so we can
provide an alternative by exposing new private API, which is what this patch
does.

The QWaylandWindow::wlSurfaceDestroyed signal already exists in the dev branch
(introduced in 04be9cf380), so this is a backport of that signal as well as an
addition of a new QWaylandWindow::wlSurfaceCreated signal.

Task-number: QTBUG-76324
Change-Id: Ibc5748474cd52f5b9461fd1ad6cef973491174b1
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-08-19 14:13:50 +02:00
Paul Olav Tvete
4da93aa94f Merge "Merge remote-tracking branch 'qt/5.13' into dev" 2019-08-19 11:19:11 +02:00
David Edmundson
cb68cead89 Client: Fix large clipboard pasting
With the non-blocking file opening, when no data was available in the
pipe, read could return 0 even though we were not at the end of the
file. This resulted in truncated data when pasting the clipboard.

This patch uses select to block until a file is available, removing the
polling sleep. This means the file can be safely opened in blocking mode
whilst keeping the timeout feature allowing read to work as intended.

Change-Id: I936aa85e9f25197e7abe6fb3fa729b618c00924d
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-08-17 11:50:23 +02:00
Johan Klokkhammer Helsing
7163c286e4 Fix incorrect conversion to straight alpha pixel formats
Previously, QWaylandSharedMemoryFormatHelper::fromWaylandShmFormat(WL_SHM_FORMAT_ARGB8888) would
return Format_ARGB32, i.e. the non-premultiplied version, while, according to the wayland-devel
mailing list (https://lists.freedesktop.org/archives/wayland-devel/2017-August/034791.html), all
Wayland RGB-based pixel formats with alpha should have premultiplied alpha.

This patch makes sure we return the premultiplied variants for ARGB8888, as well as for ABGR8888.

Using a switch instead of the array also allows us more freedom to choose the preferred format in
other cases where multiple QImage formats map to the same wl_shm format.

While being wrapped and exported as QtWaylandClient::QWaylandShm::fromFormat (private API), this
conversion function doesn't seem to be used anywhere, so this patch shouldn't cause any changes in
behavior for projects that only use public API.

Change-Id: Ie09f9a339b4540dd0383a72b3c951eb8c93e3ab4
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-08-17 09:06:07 +02:00
Paul Olav Tvete
254c76aba1 Merge remote-tracking branch 'qt/5.13' into dev
Change-Id: Ief5f30fc1dbd0e6531b19e723057b06e9bd419b4
2019-08-16 12:10:28 +02:00
Pier Luigi Fiorini
0ac92cee76 Compositor: Add idle-inhibit unstable v1 protocol
Allows disabling of screen blanking on a per-surface basis.

[ChangeLog][Compositor] Added support for idle-inhibit
unstable v1 Wayland extension.

Change-Id: I3cd392f9e1bb3604691f2a496579aad3b87383b6
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-08-16 10:13:34 +02:00
Paul Olav Tvete
6a51c6eb73 Merge "Merge remote-tracking branch 'qt/5.12' into 5.13" 2019-08-15 11:06:53 +02:00
Pier Luigi Fiorini
48211e072e Test the exact window size
Make sure we test exactly the size we expect.
We used frameGeometry() to take client-side decoration margins into
account, but actually frameMargins() returns exactly that, this
means we can compute the actual size that we want to test.

Change-Id: I2f41ffdb2aa2e3a4253a1ff7038c4bc2e43cdf98
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-08-15 09:08:24 +02:00
Johan Klokkhammer Helsing
0b803993e7 Client: Add safer fromObject function to scanner
Makes the scanner produce generated static functions such as

QtWaylandClient::wl_surface *wl_surface::fromObject(struct ::wl_surface *object);

Which casts from the wayland-scanner generated types, such as struct ::wl_surface *,
to types types generated by qtwaylandscanner, but performs a check to see if
the listener is set to the wrapper class first (at least for interfaces with events).

This lets us easily fix crashes in a couple of places where we receive events
with wayland objects that we didn't create.

Also adds nullptr checks whenever we use the fromWlSurface() and fromWlOutput()
functions to handle failed conversions.

Task-number: QTBUG-73801
Fixes: QTBUG-74085
Change-Id: I9f33c31c7d1a939ccb3ebbbcb0eb67af10037237
Reviewed-by: Jaroslaw Kubik <jarek@froglogic.com>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
(cherry picked from commit c6476ae915b8ac64121d379274363227b1c300ff)
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-08-15 08:18:49 +02:00
Paul Olav Tvete
b58991121d Merge remote-tracking branch 'qt/5.12' into 5.13
Conflicts:
	src/compositor/configure.json
	sync.profile
	tests/auto/auto.pro

Change-Id: Ia6d1512aa9ad49ac7f92ae88f23026dc0ee2ccc5
2019-08-14 16:14:55 +02:00
Paul Olav Tvete
37377fc044 Backport texture sharing for NVIDIA
This commit backports the Vulkan server buffer and texture sharing code
from Qt 5.14 to Qt 5.12 as an opt-in feature. To enable, configure with
"-feature-wayland-client-texture-sharing-experimental
-feature-wayland-compositor-texture-sharing-experimental"

Contains code from the following commits:

Add server buffer integration based on Vulkan
(commit a998944b2035c80999db4c1d9f7666c87ba73a86)

Compressed texture support for vulkan server buffers
(commit 4f87adc442a318b9c05fc73ae1020d0df0dfded3)

Implement server-side toOpenGlTexture for Vulkan
(commit 19361e7259f04b08925b1e8e99faf9460770ee7b)

New texture sharing protocol and infrastructure
(commit b09e808bf222984196cebd4447880781e3265714)

Change-Id: I6c36ef7fddcd4db39e80d03a822d89f15eae3434
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-08-13 11:56:10 +02:00
Paul Olav Tvete
94b8d9deda Fix expose event compression
For shells that do not send configure events when exposed:
If setGeometry() was called before the window was initialized, Qt would
not mark the window as mapped, and the window would never become
visible.

Change-Id: Ic933cbbff20702424129c11264215181330cc7d1
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-08-13 11:54:41 +02:00
Liang Qi
cd834c5dcb Merge "Merge remote-tracking branch 'origin/5.13' into dev" 2019-08-13 09:56:22 +02:00
Liang Qi
dc66229bf5 Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
	src/client/qwaylandinputdevice.cpp

Change-Id: I20fb102162351b714855258175ed00437e55f072
2019-08-13 09:20:59 +02:00
Ville Voutilainen
f922bd5dda Fix GCC 4.8 build
Change-Id: I0a193ceaa1549c08acad02b59db62ae313d6b334
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-08-09 10:18:06 +03:00
Marc Mutz
738d8a57b1 QWaylandScanner: port from QList to std::vector
QList is going away in Qt 6, and CoW is not needed, as containers and
elements are only ever moved, not copied, and NRVO is in effect
everywhere.

Change-Id: Ie738da3619f0b8048fbd07e5911db0960133d553
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-08-03 22:12:42 +03:00
Marc Mutz
ff42bda500 QWaylandScanner: tidy up
This change

- standardizes on using boolean needsXy to handle join-style omissions
  of commas or newlines instead of inspecting the index of the element
  in various forms, which enables

- standardize on C++11 ranged for loops instead of indexed loops

- use braced initialization for structs, with designators, which are
  strictly a C++20 feature but are being used in QtWayland already, so
  should be safe (they originally come from C99).

Together, they make the code easier to understand, because the
variation of patterns used in the program is reduced.

Change-Id: Ib96620a9ecbe4ee47e59290ed758f0ec1bffcfd6
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-08-03 18:23:56 +03:00
Pier Luigi Fiorini
391a169ff9 Fix typo
Correct a typo introduced with 833e1cef.

Change-Id: I5c101e015c0fbd7de03d26ff3f8629418f070db2
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-08-03 16:16:37 +02:00
Qt Forward Merge Bot
2963028207 Merge "Merge remote-tracking branch 'origin/5.13' into dev" 2019-07-27 03:00:15 +02:00
Qt Forward Merge Bot
97bf425823 Merge remote-tracking branch 'origin/5.13' into dev
Change-Id: I64c1a5cabcdad4177aeac35bcd45a4cde8f60165
2019-07-27 03:00:08 +02:00
Marc Mutz
eb4198edf1 QWaylandScanner: add trailing commas to enumerations and braced initialization
This is allowed since C++11, and K&R C, resp., and doing so simplifies
the code.

Change-Id: I4bf5bc50b46c6b811ec386b92bfb0a7529a32645
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2019-07-25 17:18:44 +03:00
Pier Luigi Fiorini
d268aa90ec Fix use of private dependency
With 833e1cef, Linux SPI Accessibility bridge was added to
the Wayland QPA plugin, but this had a bad side-effect to
QtWaylandClient.

Linux Accessibility support is a private module, this means we have
to link to it with QT_PRIVATE not QT, otherwise CMake and pkg-config
files for Qt5WaylandClient will depend on it.

Change-Id: I6182267f97adc2cd5bd66895df148a6a45614f45
Fixes: QTBUG-76042
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2019-07-25 11:01:34 +02:00
Marc Mutz
4572d96714 QWaylandCursor: replace a static QMap with a C array
The content of the QMultiMap cursorNameMaps is static, so using a
dynamic container is overkill.

Replace the map by a (sorted) C array of struct {Key, Value}, and use
std::equal_range to find matching cursors. This also avoids the
creation of a QList on each call (due to the use of QMap:values()
instead of QMap::equal_range), as well as the creation of QByteArrays,
which the underlying wayland C API doesn't know about, anyway.

The entries were already sorted, so the initializer_list stays the
same. Add an assert that the list is ordered.

Since this is library code, don't use the attractive struct {
WaylandCursor, const char *name }, as that causes relocations that
delay the loading of the shared object, and make sharing of the data
between processes impossible. This wastes some memory, due to all the
NUL padding up to the common maximum, and the next alignment step, but
can be optimized later when someone writes a C++-only version of
Q_STRINGTABLE.

Even so, this saves 10.5KiB in text size on optimized AMD64 Linux GCC
9.1 builds.

Change-Id: I19fa1742e2fcaf9de74af1e5908e796b0588d507
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2019-07-23 14:37:00 +03:00
Qt Forward Merge Bot
d3ea4c8456 Merge "Merge remote-tracking branch 'origin/5.13' into dev" 2019-07-16 03:00:19 +02:00
Qt Forward Merge Bot
7bc96702f4 Merge remote-tracking branch 'origin/5.13' into dev
Change-Id: Id4304c7244dd1580d5bb18451e3dda5dabe6bcb3
2019-07-16 03:00:14 +02:00
Marc Mutz
afe5668bb6 QWaylandShmBackingStore: replace a QLinkedList with std::list
...and mark the module QLinkedList-free.

QLinkedList is going to be deprecated.

Change-Id: Ieb9efef24cd8677edc1262f22b7c6d41b6376347
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-07-12 09:45:12 +02:00
Qt Forward Merge Bot
a5801f3f36 Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
	.qmake.conf

Change-Id: I436405677453e7df43258363c0d5c88d7b3790d0
2019-07-11 11:31:26 +02:00
Marc Mutz
4d2c78dae4 Fix compilation with C++20
Implicit capture of 'this' in [=] is deprecated in C++20.

Fix by using explicit captures.

Change-Id: Ie3a94ec60d7c56b2856d201fa3d68d0670bdd7b9
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2019-07-08 17:22:27 +02:00
Qt Forward Merge Bot
a582ec32d1 Merge "Merge remote-tracking branch 'origin/5.13' into dev" 2019-07-04 15:53:12 +02:00
Qt Forward Merge Bot
7d4103d02e Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
	.qmake.conf
	src/client/qwaylanddatadevice.cpp

Change-Id: I1cc8640b68eba5dfb560749dfe679741ee62e6ad
2019-07-02 08:52:03 +02:00
David Edmundson
32b338a8dc Client: Reset frame callback timer when hiding a window
If we hide a window whilst a compositor has a pending frame to show,
it's possible the compositor will not render the frame and not return
the callback.

If this happens on the next window expose we can be left with
mFrameCallbackTimedOut still true causing isExposed() to remain false
and us to not send the next buffer when we later show the window again.

Change-Id: I507410415d1a930fd5fa736412055e68fdf6c1d3
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-07-01 11:13:55 +02:00
Sona Kurazyan
4179462550 Remove usages of deprecated QLatin1Literal
Task-number: QTBUG-76491
Change-Id: I8f96c049e134843e4eb2bffef6274497eca8b5cf
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-06-25 10:00:11 +02:00
Qt Forward Merge Bot
345f87d7da Merge "Merge remote-tracking branch 'origin/5.13.0' into 5.13" 2019-06-20 16:23:04 +02:00
Qt Forward Merge Bot
5397d1508a Merge remote-tracking branch 'origin/5.13.0' into 5.13
Change-Id: I3b0e0899cfcd738ddf45b4211f86e1079d6e4988
2019-06-20 16:23:04 +02:00
Johan Klokkhammer Helsing
26c5d5e62b Client: Fix stuttering when the GUI thread is busy
When we did invokeMethod for handling the frame callbacks, we had to wait for
the GUI thread to finish whatever it's doing before we would stop blocking.

Fix it by clearing the frame callback timer and stop blocking immediately,
while delaying the rest of the work until it can be run on the other thread.

Fixes: QTBUG-76397
Change-Id: I343e4feac4838926b4fa2ccac2948988bc6c3bb7
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-06-20 14:04:04 +02:00
Qt Forward Merge Bot
a571e4cebd Merge "Merge remote-tracking branch 'origin/5.12.4' into 5.12" 2019-06-17 12:33:00 +02:00
Qt Forward Merge Bot
718ca6e527 Merge remote-tracking branch 'origin/5.12.4' into 5.12
Change-Id: I7ad83f19cf9f47b40088a56d4182514bf5b83508
2019-06-17 12:33:00 +02:00
Qt Forward Merge Bot
f87f59d9e5 Merge "Merge remote-tracking branch 'origin/5.12' into 5.13" 2019-06-15 03:02:02 +02:00
Qt Forward Merge Bot
33d55cf2aa Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I3b4132c4824a5312e7af0ca5659bd34269cb02fe
2019-06-15 03:02:02 +02:00
Aleix Pol
002fade629 Don't crash if we start a drag without dragFocus
Sometimes origin will be nullptr, triggering a crash.

[ChangeLog][QPA plugin] Fixed a crash that sometimes happened when
starting a drag-and-drop operation.

Fixes: QTBUG-76368
Change-Id: I8f4e6b05f073644834c3c72a8307dac5b897f626
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-06-14 06:20:59 +00:00
Qt Forward Merge Bot
3d258a12af Merge "Merge remote-tracking branch 'origin/5.12' into 5.13" 2019-06-08 03:00:51 +02:00
Qt Forward Merge Bot
c296df9d56 Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: Ie2469da765326e1e2da35c0311c0405b0a691bfa
2019-06-08 03:00:51 +02:00
Johan Klokkhammer Helsing
1c59778c10 Client: Don't add all windows to activePopups
Neither Qt::ToolTip nor Qt::Popup are single bits in Qt::WindowFlags, and do in
fact include Qt::Window. This meant that when we or'ed them and did a bitwise
and with QWindow::type(), we would match more types than just Qt::Popup and
Qt::ToolTip. We would for instance get any Qt::Window as well, which meant the
main window would be added to activePopups, leading to strange things
happening, such as crashes and the main window closing unexpectedly.

[ChangeLog][QPA plugin] Fixed a crash when closing multiple popups at once.

Fixes: QTBUG-76124
Change-Id: I1a6a59e161a436604a7ac8ab824396481dc99a20
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
(cherry picked from commit 4a9a5e2f62935488b1eeb06cd5d69a168a5a9308)
2019-06-06 08:54:51 +02:00
Johan Klokkhammer Helsing
c6d679eabc Client: Don't add all windows to activePopups
Neither Qt::ToolTip nor Qt::Popup are single bits in Qt::WindowFlags, and do in
fact include Qt::Window. This meant that when we or'ed them and did a bitwise
and with QWindow::type(), we would match more types than just Qt::Popup and
Qt::ToolTip. We would for instance get any Qt::Window as well, which meant the
main window would be added to activePopups, leading to strange things
happening, such as crashes and the main window closing unexpectedly.

[ChangeLog][QPA plugin] Fixed a crash when closing multiple popups at once.

Fixes: QTBUG-76124
Change-Id: I1a6a59e161a436604a7ac8ab824396481dc99a20
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
(cherry picked from commit 4a9a5e2f62935488b1eeb06cd5d69a168a5a9308)
2019-06-06 08:53:52 +02:00
Johan Klokkhammer Helsing
4a9a5e2f62 Client: Don't add all windows to activePopups
Neither Qt::ToolTip nor Qt::Popup are single bits in Qt::WindowFlags, and do in
fact include Qt::Window. This meant that when we or'ed them and did a bitwise
and with QWindow::type(), we would match more types than just Qt::Popup and
Qt::ToolTip. We would for instance get any Qt::Window as well, which meant the
main window would be added to activePopups, leading to strange things
happening, such as crashes and the main window closing unexpectedly.

[ChangeLog][QPA plugin] Fixed a crash when closing multiple popups at once.

Fixes: QTBUG-76124
Change-Id: I1a6a59e161a436604a7ac8ab824396481dc99a20
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-06-05 14:12:55 +02:00
Marc Mutz
867af0f557 Eradicate Q_FOREACH loops [2/2]: non-trivial cases
This patch contains two changes where there is a non-neglible chance
that through some indirect call the container we iterate over could be
modified.

In the listener case, it's not impossible that a listener de-registers
when it's notified. So take a copy.

In the polish_objects case, the 'initialized' flag is set before the
loop starts, and the only other reference to polish_objects, in
addPolishObject(), does not append to polish_objects in that case, but
sends the polish event directly. So use a consume loop, to release the
memory and the QPointers once they're dealt with.

Change-Id: I63d32e8a298ed5e1a7d5446434c421df80c0c795
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-06-05 14:09:14 +02:00
David Edmundson
c2e19ca64e Avoid creating decoration whilst Xdg Decoration is pending configure
Currently even when we are on on a compositor with SSDs we always create
a decoration instance only to discard it.

Not only is this somewhat wasteful, it creates sizing problems as the
frame geometry changes, leading to constantly expanding windows on kwin.

This patch assumes that if we have a decoration manager we should have
no decoration until it is configured to do so.

This is safe because we request a mode in the constructor, a compositor
must reply with a configure event and we shouldn't be showing any
buffers until the first configure event is received.

Behavior without a decoration manager is unchanged

Change-Id: I72b2cf4423fe6461ba405612262f76cefe4d6201
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-05-23 12:10:46 +01:00
Johan Klokkhammer Helsing
84c3fcffd9 Client: Don't crash when the cursor theme fails to load
Fixes: QTBUG-75920
Change-Id: I29d84b487afb2a90b8a633abce2fcc39ca75adae
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2019-05-21 09:09:09 +02:00
Marc Mutz
0f80177d98 Use some qExchange()
This makes the code more compact and avoids any doubts regarding
accesses to the underlying container under iteration, if any.

Change-Id: I6cf8a6113f182ae5c4401cb44fce2a3904c67489
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-05-17 11:45:47 +02:00
Qt Forward Merge Bot
bbf8fc2222 Merge "Merge remote-tracking branch 'origin/5.13' into dev" 2019-06-11 03:00:05 +02:00
Qt Forward Merge Bot
2ce5094bda Merge remote-tracking branch 'origin/5.13' into dev
Change-Id: Ieab9f7c86371a7c047cf9b4a527fabcc541155e4
2019-06-11 03:00:05 +02:00
Marc Mutz
9f64f52e23 Eradicate Q_FOREACH loops [1/2]: trivial cases
In this patch, we port Q_FOREACH loops to C++11 ranged-for loops. All cases are
trivial in the sense that either the argument is already const or is trivially
marked as const, either by qAsConst(), or, in the case of rvalues, by storing
to a const auto temporary first.

In addition, all loop bodies are clear enough to confirm that the container we
iterate over is not changed under iteration. This does not exclude cases where
a loop is prematurely exited just after calling a modifier on the container, as
that is safe, if not especially elegant.

Change-Id: I87a63f07797437d421567d60e52305391a3c4f21
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-05-21 10:48:37 +02:00
Qt Forward Merge Bot
0899b4287b Merge "Merge remote-tracking branch 'origin/5.13' into dev" 2019-05-26 22:27:55 +02:00
Qt Forward Merge Bot
e7d95744f2 Merge remote-tracking branch 'origin/5.13' into dev
Change-Id: Idc8adeb6ac0698ef8f6fb0585916a6e53a53fcb7
2019-05-26 22:27:55 +02:00
Johan Klokkhammer Helsing
13ee0581fa xdg-shell v6 client test: use QTRY_COMPARE instead of QTRY_VERIFY
Change-Id: I5f04676e0090bcb849a765ae5365845f199de987
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-05-14 09:39:00 +02:00
Marc Mutz
6b761b7448 QWaylandDisplay: make hasRegistryGlobal() const-correct and take a QStringView
Also port a Q_FOREACH loop to C++11 ranged-for.

Change-Id: Ifde232a00e6abed285efaf146a48521c7df25378
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-05-17 10:56:26 +02:00
Johan Klokkhammer Helsing
72cae9c58c Client: Implement primary-selection-unstable-v1
[ChangeLog][QPA plugin] Added support for middle mouse pasting through the
primary-selection-unstable-v1 protocol.

Fixes: QTBUG-66008
Change-Id: I7c8fb9aa2c856f5b6794aeab1ee75d80cad05dcd
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-05-10 12:35:00 +00:00
Johan Klokkhammer Helsing
50d2c36a57 Remove Apache licensed Vulkan helper function
Use the QVkConvenience library instead.

Fixes: QTBUG-75108
Change-Id: I9687aec3e7b697b04e9cfa5638055132c617ad9a
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-05-10 12:18:03 +00:00
Johan Klokkhammer Helsing
8607ca5ca2 Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
	src/client/qwaylanddisplay_p.h
	src/client/qwaylandwindow.cpp

Change-Id: I50eb5c83a8b81e4bdb032b68d41f429b17d0a74d
2019-05-07 12:39:12 +02:00
Liang Qi
3eb4e7ca76 Merge "Merge remote-tracking branch 'origin/5.12' into 5.13" into refs/staging/5.13 2019-05-03 12:13:50 +00:00
Gatis Paeglis
f7eada4f19 client: reimplement QPlatformIntegration::possibleKeys()
This is required to trigger more complex shortcut sequences. For
example, with 'us' keyboard layout to enter '%' or '+' you have to
press 'Shift' button. Previosly the following shortcuts could not be
triggered:

'Shift' + '5'
'%'

'Ctrl' + '+'
'Ctrl' + 'Shift' + '='

The same function also ensures that these shortcuts work with non-latin
keyboard layouts.

Change-Id: Id50c7bb28cf76b9f7a861ced7894b2cacae6ed65
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-05-03 11:38:17 +00:00
Liang Qi
3560ffefd2 Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
	src/client/qwaylandwindow_p.h

Change-Id: Ic4104c48267d1682bb58d6b38afc833c39515eae
2019-05-02 16:52:15 +02:00
Johan Klokkhammer Helsing
4b40d01819 Client: Use a QWaylandSurface for pointer focus
Task-number: QTBUG-74373
Change-Id: Idfd94442ff542b81956d4852e07eb3b5dff80712
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-05-02 11:08:03 +00:00
Johan Klokkhammer Helsing
5d1b75d9c1 Client: Add support for animated cursors
[ChangeLog][QPA plugin] Added support for animated cursors.

Previously we would just show the first frame of the animation.

Fixes: QTBUG-48181
Change-Id: Ie06bff8950678b5ff7b7e2e50915c85905a1200b
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-05-02 11:07:43 +00:00
Johan Klokkhammer Helsing
c6476ae915 Client: Add safer fromObject function to scanner
Makes the scanner produce generated static functions such as

QtWaylandClient::wl_surface *wl_surface::fromObject(struct ::wl_surface *object);

Which casts from the wayland-scanner generated types, such as struct ::wl_surface *,
to types types generated by qtwaylandscanner, but performs a check to see if
the listener is set to the wrapper class first (at least for interfaces with events).

This lets us easily fix crashes in a couple of places where we receive events
with wayland objects that we didn't create.

Also adds nullptr checks whenever we use the fromWlSurface() and fromWlOutput()
functions to handle failed conversions.

Task-number: QTBUG-73801
Fixes: QTBUG-74085
Change-Id: I9f33c31c7d1a939ccb3ebbbcb0eb67af10037237
Reviewed-by: Jaroslaw Kubik <jarek@froglogic.com>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-05-01 13:54:40 +00:00
Johan Klokkhammer Helsing
7c682530d8 Client: Add test for surfaces created by application code
This used to crash the client.

Task-number: QTBUG-73801
Change-Id: I04d1c6fcc45b6d90f2ac28844e753da2cdf3ab08
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-05-01 13:54:34 +00:00
Johan Klokkhammer Helsing
3a3f3eb924 Client: Avoid unnecessarily redrawing decorations
Note: QWaylandAbstractDecoration::update() doesn't actually update anything, it
just sets a dirty flag, and this is done explicitly in the other cases when the
decorations need to be redrawn as well (title and icon changes).

Fixes: QTBUG-75377
Change-Id: I2e8bd3abd3664c741e69a3e83ebf409872ddf31a
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-05-01 13:54:25 +00:00
Johan Klokkhammer Helsing
e70fd9016d Client: Fix reverse screen order
[ChangeLog][QPA plugin] Fixed a bug where QGuiApplication::screens() and
primaryScreen() would return initial screens in the reverse order they were
added by the compositor. QGuiApplication::primaryScreen() will now return the
first output added by the compositor.

Calling forceRoundTrip in registry_global() meant it would call itself
recursively if there were additional wl_output events in the queue. This in
turn meant the screens got added in the reverse order. Instead we now add the
screen to a list of not yet initialized screens and add it properly when we've
received the required done events (wl_output and possibly zdg_output_v1).

This also has the added benefit of wl_output hot plugging not calling
forceRoundTrip().

Fixes: QTBUG-72828
Change-Id: I35c6959d6c219f65fd19d571a25b5a6cdb3f741b
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
2019-04-29 08:18:32 +00:00
Gatis Paeglis
9558d4f8ea drop qwaylandxkb and share the logic with X11
QtWayland can benefit from sharing code with X11.

This will fix issues that have been reported and fixed on XCB
a long time ago.

Task-number: QTBUG-65503
Fixes: QTBUG-71301
Fixes: QTBUG-66497
Change-Id: I09cbf8e1c9cf29e8d7f46b97bc2f11d6e91b61a5
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-04-25 07:00:09 +00:00
Johan Klokkhammer Helsing
0a42470475 Client: Full implementation for frame callbacks (second try)
The Wayland plugin now takes full control over delivering update request and
implement frame callbacks for both egl and shm.

[ChangeLog][QPA plugin] The non-blocking version of eglSwapBuffers is now used, if
supported. This fixed a bug where minimized windows would block the event loop.

[ChangeLog][QPA plugin] Windows that don't get frame callbacks from the
compositor within 100 ms are now set as not exposed. This should stop most
clients from rendering unnecessary frames to minimized or hidden windows.

Also, when we relied on the QPA version of requestUpdate, we would sometimes
deliver one update request while we were waiting for a frame callback. When we
implement the fallback timer ourselves we can make sure we only deliver the
fallback if there are no pending frame callbacks.

QtQuick and other applications often depend on blocking swapBuffers to throttle
animations. If the context's surface format has a non-zero swapInterval, try to
emulate a blocking swap.

Fixes: QTBUG-69077
Change-Id: I3c6964f31a16e9aff70b8ec3c5340e640a30fef2
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-04-24 12:09:30 +00:00
Gatis Paeglis
97232a3fd8 rework key handling
- Document the magical 8 keycode offset in QKeyEvent::nativeScanCode()

- Check if we are working with the expected keymap format.

- Rename sendKey() to handleKey() as that is typical naming convention
  for events that are passed to QWindowSystemInterface.

- WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP is in the bundled xml so use it
  in send_keymap()

- Rename toWaylandXkbV1Key() to toWaylandKey() as previous name was
  incorrect.

- Remove "Generic fallback" in keyboard_key() as it was non-functional,
  you can't expect any useful output when mapping scan code directly to
  Qt::Key. It was not working in 5.9 (did not check beyond that) and
  no one has complained. It is safe to assume that the fallback code path
  is dead and can be dropped. To use HW keyboard with wayland, you need
  to build with libxkbcommon. We require this on XCB since Qt 5.1.0, so
  it is not an unreasonable requirement for Wayland.

- Cleanup auto-repeat key handling.

- Cleanup "#if QT_CONFIG(xkbcommon)" checks.

Change-Id: Ie9fcc628621487fb58bc55dd595bf0d51eedfc92
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-04-17 06:28:58 +00:00
Gatis Paeglis
19c4ae1adc xkbcommon: replace deprecated APIs
See xkbcommon/xkbcommon-compat.h

Change-Id: I2a70e14481db227fc0be657fbcf4f6550d62e7e8
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-04-16 10:14:30 +00:00
Liang Qi
9f450e62b9 Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
	src/client/qwaylanddisplay_p.h

Change-Id: Ie84862aa41623c11abd8f882f428054f30062c77
2019-04-16 09:46:53 +02:00
Gatis Paeglis
90fe97b017 client: rework xkb context/keymap/state handling
- Use smart pointers from xkbcommon_support-private.

- Remove needless strdup() calls.

- Don't recreate context. And move it into qwaylanddisplay so it can
be shared in future between several keyboards. It contains things like
a logging level and include paths.

Change-Id: I5d1f667e710046e6b62aa2caf82fdb2decc24520
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-04-15 14:10:34 +00:00
Gatis Paeglis
9a782df3e7 client: rework input method handling
The existing solution was parsing compose tables on startup, it is
better to lazy initialize the compose table/state on a first key press,
instead of doing it on an application startup. This logic is inside of
the compose input plugin.

The existing code did not utilize correctly how Qt handles complex text
input. It used libxkbcommon-compose APIs to compose user input and then
passed the same input again to QPlatformInputContext (from
QWaylandInputDevice::Keyboard::sendKey), which was erroneous. This also
means that code was forcing "xkb compose", and did not respect QT_IM_MODULE
at client-side.

From commit that added compose key handling (dd13698a730594d9f40baa367dcfe05bc23f1016):

"We should expand on it in the future to handle things like resetting
the compose state on text field switching".

This is now handled by properly utilizing Qt IM framework.

Converted QWaylandInputDevice::Keyboard::sendKey into a class member function
to avoid adding one more arg (mXkbContext) to the already long argument list.
That whole function should be simplified, but that is out-of-scope for this
patch.

The reworked code uses qxkbcommon support library to reduce code duplication
between platforms and to unify behavior.

Some users might mistakenly think that this patch introduces a regression
with Qt on KDE, but it is actually a KWin/Wayland compositor bug:

https://bugs.kde.org/show_bug.cgi?id=405388

The work around on KDE is to use QT_IM_MODULE at client-side to select
input method, as KWin compositor over the wire  supports only the qtvirtualkeyboard
module. Setting this envvar is not someting out of the ordinary for users
on Linux. Input method handling at compositor-side is new feature and
clearly not very well supported yet.

Task-number: QTBUG-65503
Change-Id: Ie511d950396fa2fb6cbe6672996cee9791f3ab11
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-04-15 14:10:28 +00:00
Johan Klokkhammer Helsing
1751270076 Client tests: Fix tst_xdgShell::pongs when run as the only test
The shell integration is initialized lazily, so it's not possible to send ping
events to the client before the first window has been initialized.

This adds a simple window to the pong test.

Change-Id: I13b4a9cb802b7abe18bfc23cf8c75eb873ded3ca
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-04-11 13:59:10 +00:00
Johan Klokkhammer Helsing
95469e731c tst_xdgshell::showMinimized: Really make sure the window was created
The surface(), may be a leftover cursor surface from earlier tests. Check for
an xdgSurface instead, as those are verified to be cleaned up between tests.

Change-Id: I6a2b402130814e896d335787fcb90fd8d57cafb7
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-04-11 13:59:02 +00:00
Johan Klokkhammer Helsing
e61e037f4d Fix incorrect path to wl-eglstream-controller.xml
Change-Id: I1d4bceeb87b7e95b7b4b9c9885e06052bd7536e9
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-04-11 12:52:44 +00:00
David Edmundson
637e03a6f3 Client: Avoid shadowing QPlatformWindow::windowGeometry
windowGeometry is an existing method in QPlatformWindow with an entirely
different meaning to the newly added
QWaylandWindow::windowGeometry.

This led to the existing call in resizeFromApplyConfigure calling the
wrong method.

Change-Id: Ib344cf09178e77e5b4d5427325d840346663ec9d
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-04-11 12:51:52 +00:00
Liang Qi
e3a9660499 Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
	src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
	src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp

Done-with: Johan Klokkhammer Helsing <johan.helsing@qt.io>
Change-Id: Ia6fa28454f681b4965b5e18f635cb8c40da316f3
2019-04-10 11:38:16 +02:00
Johan Klokkhammer Helsing
b384628f8b Client: Make CursorSurface inherit from QWaylandSurface
QWaylandSurface has now been decoupled from QWaylandWindow so we can share some
implementation with it and get rid of a lot of duplication.

Task-number: QTBUG-74373
Change-Id: Ieb9aa3a5cf11abe381b7cf407122d3ca7a9251fc
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2019-04-10 07:25:42 +00:00
Johan Klokkhammer Helsing
24be607d50 Client: Remove QWaylandWindow wl_surface inheritance
...and introduce a client-side QWaylandSurface.

The goal of this is to remove the assumption that a QWaylandWindow maps 1:1
with a wl_surface and also to be able to share implementation with the cursor
implementation and other parts of the plugin that needs to use surfaces, but
are not QWaylandWindows.

QWaylandWindow and QWaylandSurface are still tightly coupled and a lot of the
implementation remains as part of QWaylandWindow, but I'm hoping to fix this in
later patch sets.

Task-number: QTBUG-74373
Change-Id: Ia5a192c8d133847336d266f63ec216fb3639b8c5
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-04-10 06:14:22 +00:00
Johan Klokkhammer Helsing
c6cb08225d Client: Don't be exposed if we want to create a sub or shell surface
Because some shells don't allow attaching buffers before configure, we need to
not be exposed until we know that we don't want a shell surface.

Change-Id: Ida7101a99f953d02cf6401e4ea8d28cfabd6e102
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2019-04-08 07:51:16 +00:00
Qt Forward Merge Bot
27a3fb344a Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I16bc2e214dda4c8d6c9fc3568af60068815fc558
2019-04-06 03:03:14 +02:00
Johan Klokkhammer Helsing
dfa4796eae Compositor: Don't require OpenGL to build the QML APIs
[ChangeLog][Compositor API] The compositor API now works without OpenGL support.

This makes the compositor API work with shared memory clients only. If OpenGL
clients connect they will currently punch holes in the compositor window, but
fixing that is out of scope for this patch.

Fixes: QTBUG-74896
Change-Id: I6c1ba82f28ba9edecf380e471124e15d16f9518e
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-04-04 12:10:05 +00:00
Johan Klokkhammer Helsing
2df3b8a814 Client xdg-shell v5: Fix crash when creating a popup without a valid parent
Fixes: QTBUG-72696
Change-Id: I43f0a02a4447238aa93142981d22597c452790fd
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-04-02 12:40:48 +00:00
Qt Forward Merge Bot
5de4be4185 Merge remote-tracking branch 'origin/5.13' into dev
Change-Id: I735eb66a8469216029a1225080f49bfdcd3f0732
2019-03-29 10:40:00 +01:00
Jesus Fernandez
544d5e1221 Fix build - screen maintenance functions moved to QWSI
This is an ammendment to 01e1df90a7debd333314720fdd5cf6cd9964d796 in
qtbase.

Task-number: QTBUG-74816
Change-Id: I493ff0f64f765683d2398c32626ada28d7f202b5
Reviewed-by: Liang Qi <liang.qi@qt.io>
2019-03-29 08:54:22 +00:00
Paul Olav Tvete
b09e808bf2 New texture sharing protocol and infrastructure
This adds a higher level protocol on top of the server buffer extension,
providing an easy way for Qt Quick applications to use the shared
textures.

[ChangeLog] Added protocol and Qt Quick image provider for sharing
textures in graphics memory between compositor and multiple clients.

Task-number: QTBUG-73822
Change-Id: Idc41b3479d6ca37be35d9ccd7b89e9994ff17f8f
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-03-28 14:40:19 +00:00
Paul Olav Tvete
4f87adc442 Compressed texture support for vulkan server buffers
Adding new virtual function createServerBufferFromData() to the
ServerBufferIntegration class.

Change-Id: I6009fd5aec07f1794431bd52ccd56cfae9d0f77b
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-03-25 09:08:51 +00:00
Kai Koehne
3d147d01e3 Fix compilation with QT_NO_WARNING_OUTPUT
Use qCWarning instead of qWarning if logging into a category. This
fixes compilation with QT_NO_WARNING_OUPUT, but in addition also
avoids unnecessary string formatting if the category is disabled.

Fixes: QTBUG-74359
Change-Id: I0e316a833f3f7d4a9122377a1154e739bcb080b1
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-03-22 14:14:19 +00:00
Paul Olav Tvete
dfd4633804 Merge remote-tracking branch 'qt/5.13' into dev
Change-Id: I3dc204fcaa71c01a80b0c622443012eb07964431
2019-03-21 11:57:15 +01:00
Paul Olav Tvete
a998944b20 Add server buffer integration based on Vulkan
Using NVIDIA's Vulkan/GL interop function: glGetVkProcAddrNV

[ChangeLog] Added Vulkan-based server buffer integration for
NVIDIA EGLStreams.

Change-Id: I500f80ff3b00a9585178976d8e400baa38e89ef6
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-03-18 12:40:16 +00:00
Qt Forward Merge Bot
5098f9f6e7 Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I6d63f7390a3d26ce8c63c8e5de63b673d6831395
2019-03-16 03:04:45 +01:00
Johan Klokkhammer Helsing
d749d553e4 Client: Make QWaylandWindow's wl_surface inheritance private
QWaylandWindow inheriting wl_surface is a leftover from the old days, and today
it is sometimes causing great problems. Especially on xdg_shell and other
shells where the wl_surface needs to recreated with a different role if the
QWindow::type changes.

This is currently worked around by calling reset() on the surface, which will
destroy the wl_surface, and emit some necessary events and signals.

However, much of the rest of the code still assumes that a QWaylandWindow maps
directly to a single wl_surface which won't change over the lifetime of the
QWaylandWindow.

Today, it would make sense to implement this with composition rather than
inheritance. This is a major undertaking and so this is the first small step;
hide the inheritance in QWaylandWindow's public API. This makes it much more
visible when and where the rest of the QPA plugin is using it, so we can
eventually move it into its own class later.

Task-number: QTBUG-74373
Change-Id: I257729e33c3a5368cef4bb1e16148ba392e65bd2
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-03-14 14:37:51 +00:00
Johan Klokkhammer Helsing
11e0fc58b6 Client: Fix incorrect damage region for window decorations
The previous implementation had gaps in several places.

[ChangeLog][QPA plugin] Fixed a bug where the window decoration's damaged area
didn't cover the entire decoration. This meant some compositors would not
redraw those areas.

Change-Id: Ic72663dde301936635b2a1cfa90570a53227e8ea
Fixes: QTBUG-74341
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-03-14 13:30:54 +00:00
Robin Burchell
df531a6f3c Client: Implement wl_pointer version 5
Version 5 adds frame events, which groups multiple pointer events together,
enabling diagonal scrolling, leave and enter without an intermediate state, and
together with the new axis_source, axis_discrete and axis_stop also adds what
needed to differentiate between wheel events and touchpad scrolling.

This patch adds scroll phases and pixel deltas to QWaylandInputDevice, and
makes sure handleWheelEvent is called accordingly.

[ChangeLog][QPA plugin] Pixel delta is now set for mouse scrolling events if
originating from an appropriate device such as a touch pad (requires compositor
support for wl_seat version 5 or later).

Fixes: QTBUG-69876
Fixes: QTBUG-63720
Change-Id: I094a1ef0365893bee135cae7e6df89fafdafa2f2
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2019-03-14 13:12:00 +00:00
Paul Olav Tvete
7f21a684f7 Guarantee compatibility for Qt's extension protocols
Spell out and formalize the policy that we have been following
since Qt 5.4: We don't break compatibility for our internal
protocols. Otherwise, it would not be safe to use a Qt client
with a Qt-based compositor.

Change-Id: I632e9fbb56095ab07560413977c79777ae9fdcd2
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-03-05 12:09:19 +00:00
Johan Klokkhammer Helsing
c104decfdd Client xdg-shell: Add test for switching popups
Task-number: QTBUG-73524
Change-Id: Ie9a13aeae52a7576699147e5515e2ed32a3a4d1c
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2019-03-05 09:57:26 +00:00
Johan Klokkhammer Helsing
7fa16ebff6 Client: Don't send illegal wl_pointer.set_cursor requests
When the cursor focus' wl_surface is destroyed, or the pointer leaves a
surface, we have to reset the enter serial to avoid sending illegal set_cursor
requests.

Change-Id: I0c886e4123acb4aebd325b07bf15b9d3fa8589da
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2019-02-27 14:05:12 +00:00
Johan Klokkhammer Helsing
ecd0d448fa Client tests: Add convenience for getting cursor surface
Let's simplify all those pointer()->surfaceCursor() calls.

Change-Id: I83c51f460fa2313a0b84c8c64509d48027156443
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2019-02-27 11:48:56 +00:00
Johan Klokkhammer Helsing
446a9753ab Client: Decrease buffer_scale for small cursor themes
Not all setups or themes have cursors with a matching DPI. In such cases,
wl_cursor_load_theme will then return a theme that is the closest resolution it
can get.

With the previous implementation, cursors themes without a high dpi version
would become become really tiny on high DPI displays.

This patch prevents it by setting a lower wl_surface.scale for those themes.

This also implements proper tracking of the cursor surface's entered outputs
(i.e. if the entered surface is destroyed, the scale is reset, and similarly
the following sequence of events should also be handled:

    wl_surface.enter(wl_output@1)
    wl_surface.enter(wl_output@2)
    wl_surface.leave(wl_output@2)

In the old implementation, we would be stuck with the scale from wl_output@2,
but now we now should correctly get the scale of wl_output@1.

[ChangeLog][QPA plugin] Cursors on high DPI screens are now scaled up if the
cursor theme does not have an appropriate high resolution version.

Change-Id: Ic87d00e35612b5afdf8c2e3a4463fcfef1f1f09d
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2019-02-27 11:48:30 +00:00
Qt Forward Merge Bot
6c3658b413 Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I4c99725971d7c15448ca3f01306ae869af9ef057
2019-02-26 03:02:32 +01:00
Liang Qi
f07397208c Fix the build with -no-gui
Change-Id: I9ff6ac4e33e89691e06965515a54e91a831b7a0a
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2019-02-25 08:37:10 +00:00
Johan Klokkhammer Helsing
de2fd1db6b Client: Add test for wl_data_offer leaks
Also refactors the mocking code for data device manager and implements its
isClean method to verify there are no leaks after each test.

MockCompositor::DataDevice now persists across get_data_device requests.

Task-number: QTBUG-73825
Change-Id: Ib5866e0c54d021e12557f9a96f27950010f2611b
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-02-20 14:13:13 +00:00
Johan Klokkhammer Helsing
04be9cf380 Client: Don't leak wl_data_offers
[ChangeLog][QPA plugin] Fixed a leak of wl_data_offers.

Data offers would previously leak when a surface with keyboard focus was
destroyed... or if it was hidden... or if it changed type, and so on.

Make keyboard focus follow a wl_surface instead of a QWaylandWindow.

This also fixes a couple of other minor issues, such as the mRepeatTimer not
stopping when a wl_surface was destroyed.

Ideally, we would have a QWaylandSurface class separate from the
QWaylandWindow, but that's out of scope for this fix.

Fixes: QTBUG-73825
Change-Id: I56e502512c3959e3fcdb63744adc4a7698e3d53d
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-02-20 14:13:05 +00:00
Qt Forward Merge Bot
48696dd85e Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: Ifb1c6c64abbb5c453092eeb1aff91572b57de410
2019-02-16 03:01:33 +01:00
Johan Klokkhammer Helsing
a5bcdd0f86 Client: Refactor cursors and fix various bugs
This patch is mostly a cleanup to prepare for implementations of
xcursor-configuration, but also fixes a couple of issues.

Most of the logic has now been moved out of QWaylandDisplay and QWaylandCursor
and into QWaylandInputDevice and QWaylandInputDevice::Pointer. QWaylandDisplay
now only contains mechanisms for avoiding loading the same theme multiple
times.

There is now only one setCursor method on QWaylandInputDevice, accepting a
QCursor and storing its values so changing scale factor doesn't require calling
setCursor again. QWaylandInputDevice::Pointer::updateCursor() is called
instead.

Cursor buffer scale is now set according to enter/leave events of the cursor
surface itself instead of the current window, this fixes incorrect buffer
scales for cursors on windows that span multiple outputs. The window buffer
scale can still be passed into the seat as a fallback until the first enter
event is received.

This also fixes a bug where the QWaylandBuffer of a bitmap cursor could be
deleted while it was being used as a cursor.

[ChangeLog][QPA plugin] Fixed a bug where the DPI of bitmap cursors were not
sent to the compositor, leading to the compositor incorrectly scaling the
cursor up or down.

[ChangeLog][QPA plugin] Fixed a bug where bitmap cursor hotspots were off when
the screen scale factor was different from the bitmap cursor device pixel
ratio.

Task-number: QTBUG-68571
Change-Id: I747a47ffff01b7b5f6a0ede3552ab37884c4fa60
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-02-15 09:12:35 +00:00
Johan Klokkhammer Helsing
e1eec68742 Client xdg-shell: Fix crash when switching popups
The call to flushWindowSystemEvents() sometimes caused new popups to be shown
in the middle of hiding another. I.e. if multiple events show and hide
surfaces, they would be shown/hidden in opposite order of their corresponding
events. QMenus sometimes suffered from this (can be seen with the qopenglwidget
example from qtbase).

When the flush was added 5 years ago in 70c578cb5, it was to "reduce the
chances of seeing a bad frame". I don't see any rendering artifacts, though,
and I can't find any bug report on it. So let's hope it's safe to remove the
hack.

[ChangeLog][QPA plugin] Fixed a crash that sometimes happened when switching
popups.

Also adds more info to the workaround warning message that appears when a popup
grab is attempted and there already is another grabbing popup that is not the
parent.

Fixes: QTBUG-73524
Change-Id: Ibfcbb48c4bbe295c2be1a30add2d7e05cad398c5
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-02-12 10:27:57 +00:00
Paul Olav Tvete
843c98d2d2 Fix race condition in autotests
The QVector m_surface is modified in both threads.

Change-Id: I1818a5e1307d191f1613513b86703eaa7bda3c6e
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-02-12 08:11:08 +00:00
Qt Forward Merge Bot
ecf297ac72 Merge remote-tracking branch 'origin/5.13' into dev
Change-Id: Ib616603daf31bbfa24812f4194b0789731b8d9a2
2019-02-09 03:01:15 +01:00
Johan Klokkhammer Helsing
49fc676e8b Client xdg-shell: Add test for tooltips on popups
This used to cause protocol errors.

Task-number: QTBUG-71734
Change-Id: Ic937210fc42c93f1d411fb0fb4f269de01f07b5b
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-02-06 15:30:23 +00:00
Johan Klokkhammer Helsing
9d84dc61ba Client test: Prefer UTF-8 when ASCII is also available
[ChangeLog][QPA plugin] Fixed a bug where pasting from the clipboard would
prefer ASCII over UTF-8, causing loss of special characters.

The bug was fixed in QtBase, this is just the test.

Task-number: QTBUG-54786
Change-Id: Ibe08bf455ad0be8fdd7a3e082dec6131f19c25d6
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-01-30 15:02:44 +00:00
Johan Klokkhammer Helsing
4aa82cf999 Add client test for data device
Change-Id: Id89ec40a3f484808385401829a09a43781a1bed7
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-01-30 15:02:31 +00:00
Johan Klokkhammer Helsing
d2c9c5537d Client tests: Add simple test for keyboard press
Change-Id: Ib28be5277af9145834c7808f993c747e21845616
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-01-30 14:35:10 +00:00
Johan Klokkhammer Helsing
f91e358902 Client: Fix incorrect decoration size when QT_SCALE_FACTOR is set
[ChangeLog][QPA plugin] Fixed a bug where window decorations were to small for
for the content when QT_SCALE_FACTOR was set.

Fixes: QTBUG-72993
Change-Id: I1ed26e038c27f7c4454a6bcc04f0849e4af789e7
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-01-30 14:34:31 +00:00
Johan Klokkhammer Helsing
db7724afe3 Add deprecated support for wl_scaler
[ChangeLog][Compositor] Add deprecated support for the deprecated wl_scaler.

Some clients are stuck on the unofficial Weston protocol wl_scaler instead of
the standardized and stable wp_viewporter. This implements optional support for
wl_scaler.

This patch has been written to be easily removable in Qt 6, and touches a
minimal amount of other code.

The implementation can be tested using the new manual test compositor:
tests/manual/wlscaler.

Weston 1.11.1 has a demo client named weston-resizor, which can be used to
test. Note that although newer versions of Weston also have weston-resizor,
those versions use wp_viewporter instead of wl_scaler, so you really need
1.11.1 or earlier to test.

Fixes: QTBUG-69635
Change-Id: Id572e28044cd764eaf63b1259a92bc589711c39d
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-01-24 06:31:16 +00:00
Liang Qi
35463d211f Merge remote-tracking branch 'origin/5.12' into dev
Conflicts:
	.qmake.conf
	src/3rdparty/protocol/qt_attribution.json
	src/client/qwaylandintegration.cpp

Change-Id: I475889f2817c7094b68a2948fdd34ddf8b0c486f
2019-01-22 13:01:10 +01:00
Johan Klokkhammer Helsing
738130c024 Update wayland.xml to version 1.16.0
Now that we've stopped including the system libwayland protocol headers, i.e.
wayland-client.h and wayland-server.h, it should be safe to update the protocol
definitions to the latest version.

Note that this just updates the protocol definition, the implementations for
the various interfaces are still using the old versions.

Change-Id: I961e762553756e11e4c5b33c74101f0c16661232
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-01-21 11:39:14 +00:00
Johan Klokkhammer Helsing
b3b101ae80 Skip flaky tests
It seems clients are sometimes sending more geometry events than needed,
causing the tests to fail. Skip the tests for now to make builds pass again.

Fixes: QTBUG-73130
Change-Id: Ia9f82ddd3561d84119dc4d9f8ef15ebc48964148
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-01-18 10:37:29 +00:00
Johan Klokkhammer Helsing
3187836ad3 Client: Implement xdg-output-unstable-v1 version 2
Adds handler for the new name event and updates tests accordingly.

This means QScreen::name() will now typically return strings like: "VGA-1",
"WL-1", "DP-2", "HDMI-A-1" instead of "Screen25", "Screen26", "Screen27" etc.

Change-Id: I3d5748a2fd0d772e2344ac53f0ed808790a84ba5
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-01-17 10:55:28 +00:00
Johan Klokkhammer Helsing
8c1ecf0196 Client: Add tests for xdg-output-unstable-v1
Change-Id: I4b460bd1e5ac8541dcbf9afb2782187218d257e1
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-01-17 09:12:05 +00:00
Pier Luigi Fiorini
9860fc8f6f Clean up .gitignore
Ignore more files resulting from the build process.

Glob all scanner generated files, and add exceptions for pregenerated files.

Change-Id: Ica60951356bdc145ebd66f5e6fc6bf4e23f2aa72
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-01-17 07:50:02 +00:00
Johan Klokkhammer Helsing
badf0575a2 Client: Add wl_output tests
Also removes overlapping old tests and adds a (currently failing) test for
QTBUG-72828.

Task-number: QTBUG-72828
Change-Id: Id93d5872ed1c4f181935c1e493e9d8d0ae9cfaf3
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-01-17 07:21:17 +00:00
Johan Klokkhammer Helsing
c34abdb08b Member init for some variables that are not covered by constructors
Where it makes sense, default init variables to sensible values

Change-Id: Ie2aa6ab79a6a3c8322bb0ff804f340f7ffd1c1d1
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-01-16 12:51:44 +00:00
Pier Luigi Fiorini
6c71a283d8 Client: Test for xdg surface window geometry
Change-Id: I2f336a81682317b1f7dc939d911906b4db60a386
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-01-15 10:50:23 +00:00
Pier Luigi Fiorini
a9c9f52620 Track changes to window geometry for xdg-shell and xdg-shell-v6
Send window geometry every time the window is resized.

[ChangeLog][QPA plugin] Send window geometry every time the
window is resized.

Change-Id: I8f3824c31455345be2b582e7d3a55077b47851b6
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-01-15 10:04:02 +00:00
Johan Klokkhammer Helsing
8d23c3b5b8 Client: Test for xdg toplevel min and max size
Change-Id: I60605f494eebfde9a7737911eefe69a93041ced5
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-01-15 08:35:59 +00:00
Pier Luigi Fiorini
3572bcb831 Set size hints for xdg-shell and xdg-shell-v6
Send minimum and maximum size hints to compositors.

[ChangeLog][QPA plugin] Implement minimum and maximum size in
the xdg-shell and xdg-shell-v6 shell integrations.

Change-Id: I631c3348c8333d7a246b21228a92c436f5adb5dc
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-01-15 08:12:07 +00:00
Johan Klokkhammer Helsing
516c75d5d0 Client decorations: Show menu on right click
[ChangeLog][QPA plugin] A window menu is now shown when the window decorations
are right-clicked (if supported by the compositor).

Change-Id: I13bf0c8cd91a6e5a3b44e47114dfdc2ff0e97f3a
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-01-14 08:08:32 +00:00
Johan Klokkhammer Helsing
ff9e5830d3 Revert "Client: Full implementation for frame callbacks"
This caused regressions because QtQuick depends on swapBuffers for throttling
animations. We probably need to emulate a blocking swapBuffers and continue
after a timeout, but until we have a patch for this, revert this to avoid
releasing a regression.

This brings back the bug with a frozen event loop when a surface is waiting for
a frame callback, but this is preferable to a regression.

This reverts commit 24ef6801e42b15be0f31860476199106c69e15d6.

Fixes: QTBUG-72578
Change-Id: If6435a947aae5e9fd775404649a392bfafe9130a
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-01-08 11:57:53 +00:00
Paul Olav Tvete
3877eac8a4 wl_eglstream_controller implementation for NVIDIA
This adds a new client buffer integration: wayland-eglstream-controller,
which contains the EGLStream logic from wayland-egl, and additionally
uses NVIDIA's wayland-eglstream-controller protocol to avoid the issue
where the stream is not ready at the time of first buffer attach.

This is not enabled by default. Can be used like this:
QT_WAYLAND_CLIENT_BUFFER_INTEGRATION=wayland-eglstream-controller ./pure-qml

Fixes: QTBUG-71697
Change-Id: I73bb2a8fe9852afe1b5807cbb8c35dc4c7624dad
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2019-01-08 11:57:40 +00:00
Liang Qi
0552060620 Merge remote-tracking branch 'origin/5.12' into dev
Conflicts:
	src/client/qwaylandinputdevice.cpp

Change-Id: I4f985d6e47b4199a940ff1cd40e65165c28e49b2
2019-01-03 13:20:55 +01:00
Johan Klokkhammer Helsing
d812e2ea35 Client: Don't assume windows have surfaces in QWaylandInputContext::update
Fixes: QTBUG-72751
Change-Id: I6018a34d4a4cfcbdef5d6cd05d2d4ef12846efea
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2019-01-03 09:05:02 +00:00
Johan Klokkhammer Helsing
c09a3a27b6 Client: Fix incorrect damage for decoration edges
[ChangeLog][QPA plugin] Fixed a bug where surface damage for window decorations
was outside the surface.

Fixes: QTBUG-72818
Change-Id: I32d00174f1c308952a98bdb55731eb77be54f331
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-01-03 09:04:20 +00:00
Johan Klokkhammer Helsing
08c6462d1b Client: Fix various input related crashes for events without focus
Some compositors fail to send wl_pointer.enter events before button and axis
events. This led to nullptr dereference crashes.

[ChangeLog][QPA plugin] Fixed a crash caused by compositors sending incorrect
pointer events.

Fix it by adding nullptr checks before trying to access the pointer focus in
case the compositor didn't send enter, or if something deleted the surface
(it's a QPointer).

This means we are now silently ignoring events for misbehaving compositors
(which is probably not optimal), but I don't see how we can easily distinguish
between a missing enter and a deleted QWaylandSurface without adding more
bookkeeping overhead.

Ditto for wl_keyboard.

Fixes: QTBUG-72235
Change-Id: I4bfaa3da4ebae37b059e1e450975566559edf40b
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-01-02 11:48:01 +00:00
Johan Klokkhammer Helsing
dffa087e47 Compositor: Implement support for the viewporter extension
[ChangeLog][Compositor] Added support for the viewporter Wayland extension.

Change-Id: I1d33652fab6ff18da4ae1ae3497f0ca43517420a
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2019-01-02 10:44:40 +00:00
Johan Klokkhammer Helsing
ac1d9c43e6 Client xdg-shell: Fix protocol error for tooltips on popups
[ChangeLog][QPA plugin] Fixed a protocol error that used to happen when closing
a menu with an active tooltip.

Fixes: QTBUG-71734
Change-Id: I784fef08494fabaa4debea11f51116cf9de1f86e
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-12-26 09:22:05 +00:00
Liang Qi
d2d02aa281 Merge remote-tracking branch 'origin/5.12' into dev
Conflicts:
	README
	src/hardwareintegration/client/xcomposite_share/xcomposite_share.pri

Change-Id: I7cbbf39916821f0f1749e3ccab3151f68f4aa1ac
2018-12-22 18:53:35 +01:00
Gatis Paeglis
433901b37d remove stray Q_UNUSED call
The variable actually is used.

Change-Id: I758c35e49b5c9f861ae40c34dcd4fa60d85361ae
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-12-17 09:07:13 +00:00
Andreas Cord-Landwehr
30e8e15355 Compositor: Implement linux-dmabuf-unstable-v1
[ChangeLog][Compositor] Added support for linux-dmabuf-unstable-v1.

Implement client side DMABUF buffer sharing support by supporting the
linux-dmabuf-unstable-v1 (version 3) protocol. For enabling DMABUF,
set the following environment variables for the compositor:

QT_QPA_PLATFORM=eglfs
QT_WAYLAND_CLIENT_BUFFER_INTEGRATION=linux-dmabuf-unstable-v1

The current implementation supports the following DRM buffer formats:
- RGB and RGBA
- YUYV

This implementation requires Mesa with the following patch applied.
Otherwise, textures are not updated. The patch is contained in Mesa 18.1.5.
See https://patchwork.freedesktop.org/patch/238080/

Fixes: QTBUG-66288
Fixes: QTBUG-67845
Change-Id: Id4d90337dbe0be956b0f964426ebed3f281c6c30
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-12-13 17:09:13 +00:00
Johan Klokkhammer Helsing
24ef6801e4 Client: Full implementation for frame callbacks
The Wayland plugin now takes full control over delivering update request and
implement frame callbacks for both egl and shm.

Fixes two bugs:

[ChangeLog][Client] The non-blocking version of eglSwapBuffers is now used.
This fixed a bug where minimized windows would block the event loop.

Also, when we relied on the QPA version of requestUpdate, we would sometimes
deliver one update request while we were waiting for a frame callback. When we
implement the fallback timer ourselves we can make sure we only deliver the
fallback if there are no pending frame callbacks.

Fixes: QTBUG-69077
Change-Id: I2d3a6896c32e63d8520b57448a3601a817816a91
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-12-13 15:56:11 +00:00
Johan Klokkhammer Helsing
ed34fa051d Client tests: Add simple test for mouse click
Change-Id: I2eb9bf8aa03e8df61a26d26da061f4030d8de0be
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-12-13 14:39:34 +00:00
Johan Klokkhammer Helsing
98b7643fdd Client: Clarify warnings about unexpected enter/leave events
With the previous wording it was a bit unclear whether this was a client
problem or not.

Also adds logging category.

Change-Id: I61084c0b2c7f17408575d1d4b6cc7809c4c6d99d
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-12-11 15:47:01 +00:00
Johan Klokkhammer Helsing
f6dd4ab120 Create a new type of mock compositor for client tests
There are a number of issues with the current client testing:

- Adding new compositor functionality is cumbersome (need to add compositor
  send method, command, implementation, not to mention creating new wrapper
  objects.
- Customizing available globals and their versions is not possible and would be
  hard to implement. I.e. how to test that functionality works with old and new
  versions of an interface? Handle globals being destroyed. We did this with
  wl_output, but it was painfully cumbersome.
- Hard to verify that the compositor state is clean between tests. It is
  currently done in some tests, but requires boiler plate code which needs to
  be added and maintained for each test.
- In general lots of boiler-plate for new tests. (We have to have separate
  tests as long as Qt has global/static state. I.e. if one shell extension has
  been initialized, we can't deinitialize and initialize another one, so tests
  have to be separate.)
- Dispatching server events tied to the client event loop sometimes makes it
  hard to write tests without deadlocks.
- Abstraction, encapsulation and automatic behavior that can't be disabled
  makes it hard to test low-level functionality like surface exposure.

So, in an attempt to mitigate these issues, I wrote a new testing framework.

- Compositor dispatch is running continuously in it's own thread, access to
  compositor state is guarded by a mutex on the compositor, locking this will
  make dispatching stop, so the test can safely access internals. Although a
  bit cumbersome at first this makes it much easier to directly use server
  protocol commands from the test itself, i.e. no need to create commands for
  every single thing we want to test.
- The CoreCompositor::exec template method can accept a lambda that will be run
  with dispatching stopped. It can also return a value, conveniently letting us
  safely extract or modify compositor state from tests.
- This framework also takes full advantage of the qtwaylandscanner, using
  wrapper classes for everything, reducing boiler plate considerably.
- The compositor parts are designed to do as little as possible automatically,
  but still provide easy ways to enable common functionality, like releasing
  buffers automatically, configuring shell surfaces etc.
- Compositor globals are pluggable, use add<GlobalClass>() and
  remove<GlobalClass>() to add new global interfaces. I.e. easy to create a
  compositor with or without data_device_manager for instance.
- DefaultCompositor provides a sensible default set of functionality and
  convenience methods for most test-cases. Custom ones can still be made by
  inheriting from CoreCompositor directly instead or by removing or adding
  globals to DefaultCompositor.
- Globals have an isClean() method. Implement it to verify that the client
  didn't leave any objects lying around from the previous test.
  CoreCompositor::isClean calls isClean on the globals so a single call is all
  that's needed.

In short, we've traded mock compositor encapsulation and thread safety
guarantees for less boiler-plate, easier and more convenient access to
internals.

Anything accessing compositor state should go into a exec() call, or through
the wrapper macros QCOMPOSITOR_VERIFY and QCOMPOSITOR_COMPARE (or the TRY
versions). I've also tried to make the compositor print warnings if compositor
state is accessed in an unsafe way.

The mock compositor is currently built once per test due to CI limitations
(same thing as with the old tests).

Change-Id: Ia3feb80ce175d3814292b7f4768a0cc719f8b0e8
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-12-11 15:46:49 +00:00
Gatis Paeglis
f1e49d9309 use new feature name xkbcommon_evdev -> xkbcommon
The xkbcommon configure logic was refactored in
qtbase/c3a963da1f9e7b1d37e63eedded61da4fbdaaf9a.
For more details see the relevant commit.

Change-Id: Ic1aa26846ab8266c589f6e92dc8b81aba36df58a
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-12-05 15:44:31 +00:00
Liang Qi
6297c0aa7f Merge remote-tracking branch 'origin/5.12' into dev
Conflicts:
	src/compositor/compositor_api/qwaylandquickitem.cpp

Change-Id: I5e01a0731e880e3eb8eab349043756a5993e3050
2018-12-05 11:36:44 +01:00
Johan Klokkhammer Helsing
a3e23fe560 Scanner: Add include for QList
QList is not included when built with QT_NO_QOBJECT defined.

Change-Id: Iaf8874583e81b08a49ec246a5de0b62803c8ed7e
Reviewed-by: Sami Nurmenniemi <sami.nurmenniemi@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2018-12-05 09:53:52 +00:00
Qt Forward Merge Bot
59bfa12e20 Merge remote-tracking branch 'origin/5.12.0' into 5.12
Change-Id: Ica38060e6d624a7534660eabec604f6795970c95
2018-12-05 09:20:49 +01:00
Ville Voutilainen
130a6d7e60 Fix compilation with gcc 4.8
GCC 4.8 doesn't like QPointers in signal connections.
Also, Default Member Initializers for aggregates
are C++14, so we need to write a constructor to make
a class with DMIs work in C++11.

Change-Id: I567c60a8081fa2f268517ec747bd6534674bcce5
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-12-04 10:25:05 +00:00
Qt Forward Merge Bot
e61b0530f4 Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: I29192963efa6753a4cf222a3aec92ab400deb2f0
2018-12-04 03:01:19 +01:00
Sergio Martins
5dd5935989 Fix unused variables, in preparation for adding warning_clean
The QByteArray one seems like an actual bug.

Change-Id: I11de9c7a10cdd3e70f9f6af18bcce3bd3bf54320
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-11-30 11:37:53 +00:00
Qt Forward Merge Bot
84a3f82b28 Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: I224c25d20f58723d085e4ee340744d1c7af67933
2018-11-24 03:00:23 +01:00
Johan Klokkhammer Helsing
29707d3476 Client: Fix incorrect enter serial in set_cursor
Change-Id: Ibeacc5218acbd6003b85811a175ed00fd62a4b51
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-11-21 13:39:36 +00:00
Johan Klokkhammer Helsing
a800b2951e Client: Don't create cursor surface until we can set its role
We can't set the cursor role until we have gotten an enter event, so
wait with creating the surface until we want to set the role for the
first time.

Makes testing easier since we don't have to deal with role-less
surfaces that may or may not be the cursor surface.

Change-Id: I99803d9b0b5933a271b6b1d56f74d4ff79813e40
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2018-11-21 12:20:58 +00:00
Johan Klokkhammer Helsing
a544de1bc0 qtwaylandscanner: Generate Resource::object without interface prefix
This allows writing template functions like this

    template<typename return_type>
    return_type *fromResource(struct ::wl_resource *resource) {
        if (auto *r = return_type::Resource::fromResource(resource))
            return static_cast<return_type *>(r->object());
        return nullptr;
    }

Letting us easily cast a wl_resource to a wrapper type, i.e.:

    wl_resource *resource = ...
    auto *surfacePrivate = fromResource<QWaylandSurfacePrivate>(resource);

This can hopefully let us reduce some boilerplate in the future.

Change-Id: I41630f35b3472baa39d88d89c1c6503cc0e6584a
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-11-21 12:18:00 +00:00
Qt Forward Merge Bot
e4c13a174a Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: I6cc70da737d07a87e2b396e35f64adfeffc565bd
2018-11-17 03:03:06 +01:00
David Edmundson
3684b83589 Client: Rename m_topmostPopup to clarify its goal
This is used when creating new grabbed popups to ensure they are only
created on the topmost grabbing popup as per the specification.

Non-grabbing popups don't have this restriction.

Change-Id: I8e2b8cd0f091688c847f81f2e5d33ce2f0df96a1
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-11-14 19:52:50 +00:00
David Edmundson
27d39e7b3a Client: Don't require an input device for non-grabbing popups
It's valid to create a non-grabbing XDG-popup, such as a tooltip, before an input event.

The current guard should only apply for grabbing popups, otherwise tooltips created early
are turned into XDG-toplevels resulting in incorrect positioning.

Change-Id: I5bb59a68964ef2375c81e8b4e1a73361b9d2cbcc
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-11-14 19:52:45 +00:00
Paul Olav Tvete
70b5d99bc2 Only print deprecation warning when using deprecated shells
Avoids printing deprecation warnings for shells that are available by
default but not actually used. In particular, avoids warning about
wl-shell when using ivi-shell.

Change-Id: Id075e97572e6ec876ad24f369808c61a479e9b07
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-11-07 12:59:23 +00:00
Pier Luigi Fiorini
237f8b94e5 Client: Add fullscreen shell integration
[ChangeLog][QPA plugin] Added support for fullscreen-shell unstable v1.

The fullscreen_shell_unstable_v1 interface displays a single surface
per output and it is used for nested compositors, where each output
is rendered in a surface that is then displayed by the main
compositor.

For example weston could be the main compositor and a QML compositor
could be launched as a client using this shell integration to
display it inside weston.

Change-Id: I037679a283ff03cb4bdf4b3fed59945090ec9250
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-11-05 07:51:14 +00:00
Johan Klokkhammer Helsing
e82a4695d2 Scanner: Assert resource in destroy handlers
Change-Id: I8e32b267a4cc5a4cfc462f7819a378573e179134
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-11-02 08:52:47 +00:00
Johan Klokkhammer Helsing
2f72ea6d82 Client: Use logging category for chosen shell integration
Nothing is wrong, so we shouldn't pollute stderr.

Change-Id: I05538c8e5199f97ebb1a1233e866f3a93179b799
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-11-02 08:52:31 +00:00
David Edmundson
e6d55239c4 Client: Explicitly send expose window on first configure
Before 46aece51330b6f9b5b4bfd68a5b3b183dc5b1c38 we would always call
QWaylandWindow::applyConfigure which in turn sends an expose event.

Without that clients do not commit their initial buffer.

This adds back the expose event on the first received configure.

Fixes: QTBUG-71509
Change-Id: Ica39bb23245957948e1e1f75caf4f16f7b086ef7
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-10-31 13:03:30 +00:00
Qt Forward Merge Bot
572f479787 Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: I1d9281750b06f7584e55759994dc6fcbcc5b2455
2018-10-30 03:03:23 +01:00
Oswald Buddenhagen
c03495c90e Merge 5.12 into 5.12.0
Change-Id: Ic7b7999f42b1867982b9410efb5224d68e9443f8
2018-10-30 00:50:22 +01:00
Johan Klokkhammer Helsing
f033e17099 Client: Fix fullscreen regression on wl-shell
The code for isNormal was wrong, so set_toplevel (which clears fullscreen
state) would be sent unless the window was both maximized and fullscreen. Fixed
it and made it a little bit more readable.

Change-Id: Icaa52d3a058df064a0bd1164119af3f511cb4220
Fixes: QTBUG-71350
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2018-10-28 09:15:07 +00:00
Johan Klokkhammer Helsing
52c9c71d91 Client: Don't spam expose events
Only send expose event when the geometry actually changed.

Change-Id: Ic06986ce5d11e0ff7a842303f57093b8ff25b9f6
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2018-10-26 11:05:07 +00:00
Johan Klokkhammer Helsing
46aece5133 Client: Don't attach buffers to unexposed windows
QBackingStore::flush is sometimes called with an unxeposed window, in that
case, don't attach the buffer to the wl_surface immediately, as that causes
protocol errors with xdg_shell.

Flushed buffers are instead stored until we get the first configure event.

[ChangeLog][QPA plugin][xdg-shell] Fixed a bug where buffers were sometimes
attached and committed before the first configure event, causing protocol
errors.

Fixes: QTBUG-71345
Change-Id: If9409d97bd25f6b13940c56141920a664c349c8e
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2018-10-26 11:05:00 +00:00
Johan Klokkhammer Helsing
3b4dd0f24b Client: Set key repeat rate and delay from the repeat_info event
[ChangeLog][QPA plugin] Clients now follow the keyboard key repeat delay and
interval configured by the compositor.

Change-Id: I8a88d341a2bb648d70f95494fe19e941273ae31b
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-10-17 14:24:46 +00:00
David Edmundson
833e1cef06 Load the Linux SPI Accessibility bridge
This is mostly a copy of XCB's atspi brige loading, only it creates the
original QPlatformAccessility() instance if the atspi bridge is not
available, to match the current behavior.

This also moves accesibility module to be lazy-loaded to match both Mir
and XCB QPAs.

Change-Id: I7b7ccadbec3760ab8a9449124db0db3f28c1f355
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2018-10-15 14:32:43 +00:00
Qt Forward Merge Bot
9d082d91f3 Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: Ib4c65db63c2f3119fc7c157d4353c4e0ecebefb0
2018-10-09 15:30:02 +02:00
Johan Klokkhammer Helsing
6f183c7db7 Client (xdg-shell): Only restore normal size when not maximized
kwin and perhaps other compositors sometimes send questionable configure events
with state set to maximized and size == {0,0}.

Previously, we would then restore the m_normalSize, which would give us a
maximized window with the size of a windowed (normal) one.

A size of zero usually means that it's up to the client to decide, which makes
sense for non-maximized windows, but not so much for maximized ones. This is
what the protocol spec says about the maximized state:

    The surface is maximized. The window geometry specified in the configure
    event must be obeyed by the client.

It's fixed in the dev version of kwin, but until then, let's be on the safe
side and only resize the window if things make sense.

[ChangeLog][QPA plugin] Fixed a bug where maximized windows would resize to
their unmaximized size if the compositor sent an invalid configure event.

Change-Id: I2371b29c82426ac48cd1c18c14c3dd0fe4f2250e
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-10-09 07:00:31 +00:00
Johan Klokkhammer Helsing
e71099c07e Client: Fix cursor size becoming bigger and bigger when switching screens
cursorSize was a static which was multiplied with the dpr each time
loadCursorSize was called resulting in a bigger and bigger cursor size.

Fix it by making the static constant.

Change-Id: Ie23cf0cc0d6c13721feecebe214d7c794be35077
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2018-10-08 14:01:06 +00:00
Johan Klokkhammer Helsing
d78e0e3457 Fix compilation with libwayland < 1.10 (again)
wl_proxy_marshal_constructor_versioned was added in libwayland v1.10.0, use the
old way with wl_proxy_marshal_constructor for older versions instead.

Change-Id: I4514212e0b44ecbf200769759667186f71b279b6
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-10-05 11:57:38 +00:00
Johan Klokkhammer Helsing
702fa089af Remove wayland-client.h include
Change-Id: I44df8aa9117e12280f6397f7d75dc10959905302
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-10-03 10:06:37 +00:00
David Edmundson
b25af2c768 Avoid spurious move events after configure call
Whilst wayland can't actually move the window in a QWindow::setGeometry
call the previous behavior was to keep it so that it appeared to the
client that it had moved.

The new behavior is non-consistent, QWindow::setPosition will update
QWindow::position until the first configure call is received at which
point it will move back to 0,0. This then generates a QMoveEvent for the
window that hasn't moved.

This patch keeps the QWindow::position consistent with the user request
and doesn't generate move events.

Change-Id: Ifb1433b3902d44c1b2e43036bc1805a6e00128fb
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-10-03 08:37:49 +00:00
Johan Klokkhammer Helsing
e7c0cbac89 Don't include system versions of wayland protocol
wayland-client.h and wayland-server.h includes protocol generated for the
version of wayland.xml corresponding to the libwayland version. This becomes a
problem when we want to support a version of wayland.xml that's newer than the
system libwayland.

The solution is to include wayland-client-core.h and wayland-client-server.h
instead. These headers don't include any wayland-scanner generated code, so we
can safely compile and link code generated against the version of wayland.xml
that we ship.

[ChangeLog] Code generated by qtwaylandscanner now includes
wayland-client-core.h and wayland-server-core.h instead of wayland-client.h and
wayland-server.h. This might break source compatibility for code using custom
wayland extensions.

Fixes: QTBUG-70553
Change-Id: Ice0cdb60ecc4f936acc0e158b96f7978549f62c1
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-10-03 08:36:56 +00:00
Johan Klokkhammer Helsing
f086d96035 Client: Remove failing assert on compositors without wl_data_device
Some compositors don't advertise wl_data_device_manager support, and the client
has no control over this, so the assertion doesn't make sense. Returning
nullptr in that case should be fine.

Change-Id: If0b145326d074ea4ebf8f5a12654962d56012a2d
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-10-03 06:32:49 +00:00
Qt Forward Merge Bot
72b789765e Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: I66c91dfde14a7c252a02777cfcf0396b1d05e854
2018-09-25 03:00:56 +02:00
Johan Klokkhammer Helsing
fc7eaa1ece Client: Make features for shell integrations
[ChangeLog][QPA plugin] Shell integrations are now features that can be enabled
or disabled at build time.

Change-Id: I1c48bb5d444074ac25331cb1ca8a9f49ebcd9805
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-09-21 07:39:26 +00:00
Paul Olav Tvete
5efef3d981 Add server buffer integration using Linux dma-buf
Fixes: QTBUG-70494
Change-Id: Iaa4990fe9d39a1f9fb81f5e5f19039aa2e52dcac
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-09-21 07:00:59 +00:00
Johan Klokkhammer Helsing
088dc0556d Decorations: Don't depend on wl_shell
[ChangeLog][QPA plugin] The private window decoration API method,
QWaylandAbstractDecoration::startResize, now takes Qt::Edges argument instead
of a wl_shell_surface_resize enum. This will break window decoration plugins
written for older versions of Qt Wayland.

Change-Id: I4fc9aab949e91efd48a4943f8e116f51dfc373b8
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-09-20 09:31:08 +00:00
Johan Klokkhammer Helsing
2f9379552c Don't use members of wl_resource
When we switch to only including core wayland headers, wl_resource will be an
opaque type. Use the getters and setter functions instead.

Task-number: QTBUG-70553
Change-Id: I7d84d48a4ee3586f231a331cd15716686dcee775
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-09-18 12:13:30 +00:00
Qt Forward Merge Bot
6252a08923 Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: I27420ad626a0c6a18b9a11c6ffdc102006fe78e0
2018-09-18 03:00:45 +02:00
Johan Klokkhammer Helsing
6513ac8582 Update xdg-shell-unstable-v5.xml
The old xdg-shell-unstable-v5.xml was malformed, and was missing some
<description> tags.

The updated version passes wayland-scanner run with --strict. Hopefully we can
start to use it soon.

Otherwise, it's just documentation fixes.

Change-Id: Id28ad7196643156cd22407e12ed7ff1e7fb34ce6
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-09-17 10:39:48 +00:00
Johan Klokkhammer Helsing
f27a3ff689 Revert "Upgrade wayland.xml to version 1.10.0"
Since we're using the deprecated ways of including wayland (wayland-server.h
instead of wayland-server-core.h), we can't upgrade wayland.xml to a version
that's newer than the system libwayland. Our minimum supported version is 1.6.

This reverts commit 1d51503daead2e09cc2526a0114bedd4669c1d3f.

Fixes: QTBUG-70528
Change-Id: I102cb215a40a1aaaeba6f463200eefc3be653c52
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-09-17 10:38:06 +00:00
Johan Klokkhammer Helsing
014ea9cdc4 Remove ifdefs for unsupported libwayland versions
The ifdefs were for version 1.2.0.

Change-Id: Ie58745c7cf4c0fba45bc5203d24e9913d3a8b8ce
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-09-17 08:20:31 +00:00
Johan Klokkhammer Helsing
d95ba68c14 Remove unnecessary function declaration
Change-Id: I55a7b579babfa99707e3e4b4cf15c34f48459825
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-09-17 08:19:10 +00:00
Johan Klokkhammer Helsing
082922b4c3 Don't include wayland-client-core.h
It requires libwayland 1.8 and we're supposed to support versions as old as 1.6

Task-number: QTBUG-70528
Change-Id: Iff4c2542d103d53aba8db99ecceddfccb79cfcb6
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-09-14 14:00:17 +00:00
Johan Klokkhammer Helsing
c8d10612b0 Add missing Q_UNUSED
Change-Id: I7e6b4460aac92cb9669ac1d0d0f4785a8444925d
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-09-14 13:58:46 +00:00
Johan Klokkhammer Helsing
e784fb8d14 Don't try to use wl_proxy_get_version with libwayland < 1.10
The pregenerated header for xdg-shell was generated using wayland-scanner 1.13
which uses wl_proxy_get_version which was introduced in 1.10.

Change-Id: I19507ff6e543d4b0aa53e0d022d680090c34ab50
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-09-13 13:23:49 +00:00
Johan Klokkhammer Helsing
6f0c854a3f Client: Clean up hardware integration initialization
If QT_WAYLAND_DISABLE_HW_INTEGRATION is set, clients no longer bind to the
qt_hardware_integration interface.

[ChangeLog][QPA plugin] The environment variables,
QT_WAYLAND_CLIENT_BUFFER_INTEGRATION and QT_WAYLAND_SERVER_BUFFER_INTEGRATION,
now takes precedence over what is communicated through the
qt_hardware_integration wayland interface.

Change-Id: Iff68ccc151781c3c2ad6def8497bca65e89a0b20
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-09-11 10:50:07 +00:00
Qt Forward Merge Bot
f2d2a4c3c2 Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: I40724946222f7e51b3cf36a2ce1cd60d7801f41a
2018-09-11 03:01:14 +02:00
Johan Klokkhammer Helsing
a9f0ac5e33 Create feature wayland-shm-emulation-server-buffer
And make OpenGL a requirement, in order to make builds without OpenGL work
again.

Fixes: QTBUG-69779
Change-Id: Iff1153b0aaca8e115f47c59c2ceb028e638e3fe9
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-09-10 08:01:59 +00:00
Johan Klokkhammer Helsing
108bd7ca26 Prefix and suffix server buffer integrations
[ChangeLog][Compositor] Features for server buffer integrations have
been renamed. "drm-egl-server" is now "wayland-drm-egl-server-buffer"
and "libhybris-egl-server" is "wayland-libhybris-egl-server-buffer".

Change-Id: I06a9d1b1c9219c88045fe966be134ff072cd756e
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-09-10 08:01:55 +00:00
Johan Klokkhammer Helsing
8f582e8e0b Client: Remove unused constructor for xdg-shell v5
Change-Id: Idcb2220237b3dba0a296fbb9a86497a3d0022d5f
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-09-06 06:40:37 +00:00
Johan Klokkhammer Helsing
c1df229b5d Client: Use customized version of generated files for xdg-shell-v5
Check in qtwaylandscanner and wayland-scanner generated files with renamed
symbols to avoid conflicts with xdg-shell stable.

When this was done on the compositor side, we thought we didn't have to do it
for the client side because the conflicting symbols are used in separate
plugins. Turns out this breaks static builds, though.

Task-number: QTBUG-69896
Change-Id: I461df8e136b741063eafe13e858734a3aafdf020
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-09-05 11:23:24 +00:00
Johan Klokkhammer Helsing
b70ab36e1c Client: Deprecate xdg-shell-v5 and wl-shell
[ChangeLog][QPA plugin] Deprecated the shell integrations for
xdg-shell-unstable-v5 and wl-shell. The stable version of xdg-shell
should be used instead.

Task-number: QTBUG-68838
Change-Id: Iab89059ec13efc2f72c3317a26439d7683e03e79
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-09-05 06:52:30 +00:00
Qt Forward Merge Bot
315e731aae Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: Ib137a0ec79dd9f0bbbbe24daafef881a096b2c47
2018-09-04 03:00:30 +02:00
Johan Klokkhammer Helsing
db0838a117 Compositor: Fix nullptr dereferences in fromResource functions
If there was no resource for the given wl_resource*, don't try to dereference
it.

Change-Id: I3a27a5805699148bb26029e8b4179042c3c1117a
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-08-29 12:55:22 +00:00
Johan Klokkhammer Helsing
3c4ea05c75 Scanner: Don't crash when calling fromResource with nullptr
Change-Id: I85c17e50cf917a51e74fa03fcdc647def6e4bdfd
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-08-29 12:55:06 +00:00
Johan Klokkhammer Helsing
f746be7c7f Client: Fix regression; drawing decorations of active windows as inactive
We can't trust QWindow::isActive, because it relies on focusWindow, which may
be updated too late, and there might also be multiple active toplevel windows
at once on Wayland. Even though Qt doesn't support multiple seats, we should
still draw the decorations of active windows correctly.

This implements QPlatformWindow::isActive and uses it in the decorations.

Change-Id: I34d79b354e2d26694533e2319a26f24085212243
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-08-28 07:00:44 +00:00
Qt Forward Merge Bot
f63bc9c023 Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: I5cc539cf5d956ac02c754b56c4f24af163a47f33
2018-08-28 03:00:51 +02:00
Qt Forward Merge Bot
326ab57d25 Merge remote-tracking branch 'origin/5.11' into 5.12
Change-Id: Ib6d23655a5c9ee059a9560e862d38746f508caee
2018-08-25 03:01:39 +02:00
Qt Forward Merge Bot
27d64cde97 Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: I47695924b086a2814b532622d96df3096bc1b309
2018-08-21 03:00:39 +02:00
Johan Klokkhammer Helsing
059debd75a xdg-shell stable: Make sure popup parent is topmost popup when grabbing
Avoids protocol errors on Weston, gnome-shell and wlroots-based compositors.

This is the same fix as 2987de95, but for the stable version of xdg shell.

Change-Id: Ic998fb920a8b1b131e42833a61e663704c8663e4
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-08-17 15:22:12 +00:00
Johan Klokkhammer Helsing
4a6cf17488 Compositor API: Add xdg-decoration unstable v1 support
And add an example with server-side window decorations.

Task-number: QTBUG-69934
Change-Id: Ic3984b50cf7574cae5135dea51eb4b1c80bb45a7
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-08-17 14:41:05 +00:00
Robin Burchell
1d51503dae Upgrade wayland.xml to version 1.10.0
Change-Id: I85b58ca9d14a1d37959475b05e0be8c9c8721186
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-08-17 14:39:03 +00:00
Johan Klokkhammer Helsing
e581d7dda4 Client: Clear entered screens when resetting window
Previously, windows that were hidden and shown again would have the old list of
entered screens. Aside from occasionally getting the current screen wrong,
this also polluted the log with bogus warnings about unexpected enter events.

This problem could be seen quite easily by opening, closing and opening a menu.

[ChangeLog][QPA plugin] Fixed a bug where a window that was hidden and then
shown on different screen would still think it was on the first screen.

Change-Id: I1b27433ea6607a218384d814ae4c16b9c4395948
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-08-17 14:30:01 +00:00
Johan Klokkhammer Helsing
c2f156e27b Client: Implement xdg-decoration-unstable-v1 for SSD support
[ChangeLog][QPA plugin] Added client-side support for the
xdg-decoration-unstable-v1 Wayland extension. Qt clients will now let the
compositor draw the window decorations if configured through this extension.

Note: The env var QT_WAYLAND_DISABLE_WINDOWDECORATION is still supported, but
works on a higher level, and for all shell integrations, while xdg-decoration
only works with xdg-shell stable.

Task-number: QTBUG-69746
Change-Id: I9dd0331bbd8d624c6be54ed23ee3b96446d5820d
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-08-14 08:16:22 +00:00
Johan Klokkhammer Helsing
87752e03d2 Compositor: Use customized version of generated files for xdg-shell-v5
Checking in wayland-scanner and qtwaylandscanner generated files with renamed
symbols to avoid conflicts with xdg-shell stable.

Task-number: QTBUG-66784
Change-Id: I1b1a055d3be12bfa7d16e7bb7209e96497cbf28c
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-08-14 08:16:02 +00:00
Qt Forward Merge Bot
98c6cbdf79 Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: Ia9584a185a3d7a68a4333890ade535585ba33fee
2018-08-14 03:00:30 +02:00
Giulio Camuffo
b21ecf062a Client: Return a fixed value for the logical screen DPI
[ChangeLog][QPA plugin] Font and UI scaling is now based on the screen scale
factor rather than the physical DPI. The logical DPI is set to 96 unless
overridden by the the environment variable QT_WAYLAND_FORCE_DPI, which may be
set to a specific DPI or to "physical" to get the old behavior.

Change-Id: Ife417bf5537b0f6c9ecceffea46937951770b150
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2018-08-13 08:22:13 +00:00
Johan Klokkhammer Helsing
0848300f0b Client decorations: Don't spam mouse leave events
Previously, we would send one leave event each time the mouse was moved on the
decorations.

Change-Id: I57bd6e57261447db8a8c5ab45dc8f3fdfed33a49
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-08-13 07:49:35 +00:00
Johan Klokkhammer Helsing
ee24f1a145 Client: Log configure states to logging category
States are not visible in WAYLAND_DEBUG output since array values are not
printed there. Logging the states to the Wayland QPA logging category gives us
a convenient way of seeing what states are configured.

Change-Id: If71c6df3180eba3f8efb08135a67b417940c3ffe
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-08-09 10:51:33 +00:00
Johan Klokkhammer Helsing
83abc8bf60 Convert qtwaylandscanner into a class
Encapsulate what the scanner needs of functions and state into a class,
Scanner, instead of keeping everything in the global namespace.

Change-Id: Idd4b412bb7f709f24c86abe82b135c09b7985878
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-08-09 07:15:28 +00:00
Johan Klokkhammer Helsing
0f9595ae09 Client: Fix memory leak for xdg_popup and xdg_toplevel
Change-Id: I561e2af0cdc812ea4f499525b4af0a4ab7ad8182
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-08-08 11:53:39 +00:00
Johan Klokkhammer Helsing
fc8cf44263 Client: Don't leak toplevels for xdg-shell-unstable-v6
Change-Id: Ifd6d4956eeed663e45219b428dfe562e7a82e626
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-08-08 11:23:34 +00:00
Paul Olav Tvete
019427b9ae Don't commit same buffer multiple times
In Qt we call flush() when we think the window might need to be
updated. It is also possible to trigger a flush while painting.

Two fixes:

1) If there are attempted flushes between beginPaint() and endPaint,
queue them up, and do them in endPaint().

2) Make sure we only commit the buffer once: after that the
compositor owns the buffer, and it can repaint on its own.

Change-Id: Ibf61068fa95760eb67dbc0b1d0534854114ea528
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-08-08 10:44:40 +00:00
David Edmundson
8ce206f324 Add XdgOutput client support
XdgOutput is an extension of wl_output with the benefit of having the
logical size of a screen as an explicit parameter, instead of clients
inferring it from modeSize / scale. This is useful as it allows
compositors to implement fractional scaling whilst clients can still
fill the screen.

In the future XdgOutputV2 will support a more useful name and ID that
we can use.

[ChangeLog][QPA plugin] Added support for xdg-output-unstable-v1

Change-Id: I2e1e64ad6cb497a1cbb7b7b170f28ac92231c2c4
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-08-03 11:28:51 +00:00
Qt Forward Merge Bot
ba565ba388 Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: I4c25009c207ab36219976e75343a9b6398d3a42d
2018-07-10 03:00:32 +02:00
Paul Olav Tvete
7023f9de85 Proper naming for backingstore logging category
The logging category is exported, so the name should be
specific.

Change-Id: Iffdc89875ef9e3091009780edc614fee10c05532
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-07-09 10:39:00 +00:00
Johan Klokkhammer Helsing
4d87e7e34b Draw disabled text color for inactive window decorations
Task-number: QTBUG-68834
Change-Id: Iced478d12b56fc360c0d824cf5876855d887f9a2
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-06-29 10:15:17 +00:00
Johan Klokkhammer Helsing
9706945157 Send damage for window decorations
Compositors that only update damaged regions would show the old content of the
decorations.

[ChangeLog][QPA plugin] Fixed the window decorations sometimes not updating on
some compositors.

Change-Id: I75ab40e159bf165152a58e438dd7f70e7f9e9b22
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-06-29 07:29:09 +00:00
Liang Qi
f6fd704557 Merge remote-tracking branch 'origin/5.11' into dev
Conflicts:
	src/client/qwaylandxdgsurface.cpp
	src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgsurfacev5.cpp
	src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
	src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6_p.h

Done-with: Johan Klokkhammer Helsing <johan.helsing@qt.io>
Change-Id: Ia39be6254a95af1c4efa831358cc06a697da3423
2018-06-28 20:56:59 +02:00
Daniel d'Andrada
ede3963eba Implement QWaylandXdgSurface::xdg_surface_close()
Change-Id: Ia2f708fc668a802f4468efd0765f36aab0944e10
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-06-28 11:11:12 +00:00
Johan Klokkhammer Helsing
3e66edd846 Client: Fix cursor hotspot on high-dpi
QWaylandInputDevice::setCursor(wl_buffer, QPoint, QSize, bufferscale) assumes a
hotspot and a size in surface coordinates, while wl_cursor_image uses pixel
coordinates.

Divide by bufferScale to get the correct values.

This breaks hidpi cursors on kwin 5.13.1 and earlier, where buffer scale for
cursor surfaces are ignored.

Change-Id: I7c86bc541ccf5fb878facebbe93d2b1f842dfc5c
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-06-27 11:20:00 +00:00
Johan Klokkhammer Helsing
d923a19491 Client: Improve the look of bradient
[ChangeLog][QPA plugin] The window decorations have had a redesign,
they now use the window background color instead of the blue gradient.

Changes:

- Removed the gradient
- Used QPalette::Window for color instead of QPalette::Highlight
- Removed the xpm buttons as they look bad on high-dpi
- Redid the non-xpm buttons, removing their border
- Used anti-aliasing for cross icon (diagonal lines)
- Size of buttons have been increased, to be easier to click
- The position of the buttons have been shifted slightly
- Reduced rounding of the corners slightly
- Switched to non-bold and increased the font size for the window title

Task-number: QTBUG-68834
Change-Id: I17b2464c5e2518294d795512493bfe93e9a2f550
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-06-25 09:27:44 +00:00
Thiago Macieira
764a79e01d Fix build: some shells need to link to libxkbcommon
They use QtWaylandClient's private headers.

In file included from qwaylandinputdevice_p.h:1,
                 from qwaylandxdgshellv6.cpp:45:
qwaylandinputdevice_p.h:69:10: fatal error: xkbcommon/xkbcommon.h: No such file or directory

Change-Id: I6efb28c3145047559ec0fffd1538a642167da67f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-06-20 16:04:38 +00:00
Thiago Macieira
f2610e8d76 Fix warning about extra const
qwaylandxdgsurfacev5.cpp:77:97: warning: type qualifiers ignored on cast result type [-Wignored-qualifiers]

Change-Id: I6efb28c3145047559ec0fffd1538a5ce04f2721b
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-06-20 16:04:22 +00:00
Johan Klokkhammer Helsing
0424118abd Client: Move bradient buttons inside processMouseTop
To avoid them covering for the edges of the window

Change-Id: Id8a1362ec11bd25f54cb2c9fbcbd562af8f283d8
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-06-20 11:15:15 +00:00
Qt Forward Merge Bot
3c8df67f26 Merge remote-tracking branch 'origin/5.11.1' into 5.11
Change-Id: Idd23894d256f83518f2cd25d7c13f5a09c7d577e
2018-06-19 13:18:04 +02:00
Johan Klokkhammer Helsing
6dfa35b7a2 Client: Get rid of QWaylandShellSurface::setType
This shouldn't change any behavior, but lets the shell integrations choose
if they want to use the extremely hacky QWaylandWindow::transientParent().
Hint: Not all shells need the hacks, and not all shells need them in all cases,
and some shells may need even more hacks.

Change-Id: Id105e4feb83cc9c14dcf07dcca55fcd5e63d4a2b
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-06-19 06:19:13 +00:00
Johan Klokkhammer Helsing
b40a7bd4b3 Client: Use a pixel font size for window decorations
The window title bar's height is given in device pixels, so the font
size should be as well.

Task-number: QTBUG-68834
Change-Id: I5a82deb39439088dd55152fb8bae5c2d19d8b33e
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-06-19 04:58:20 +00:00
Johan Klokkhammer Helsing
7e5daff5dd Client: Don't restore content cursor when on the window decorations
Problem: When the cursor entered the window decorations,
QWaylandWindow::restoreMouseCursor would be called from the pointer
enter handler messing up the cursor from the decorations, making the
resize border seemingly hard to hit.

Don't restore the cursor unless inside the window contents.

[ChangeLog][QPA plugin] Fixed a bug where the arrow cursor would be
shown instead of the resize cursor when hovering over the window
decoration border.

Change-Id: I2fabd8d626deaa7006734a4d5c6d10d6c0114466
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-06-19 04:58:02 +00:00
Johan Klokkhammer Helsing
14beea787a Client: Fix bradient compilation error without xpm
Change-Id: I8cbe939352713f643474d383da95b6d13be798a8
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-06-19 04:56:44 +00:00
Liang Qi
8a14be4437 Merge "Merge remote-tracking branch 'origin/5.11' into dev" into refs/staging/dev 2018-06-13 10:13:57 +00:00
Liang Qi
640367b8ee Merge remote-tracking branch 'origin/5.11' into dev
Conflicts:
	.qmake.conf

Change-Id: I6596d1a127cc93e53ec30cd881da1810cb8076d5
2018-06-13 12:03:52 +02:00
Johan Klokkhammer Helsing
56b088d13e Client: Remove applyConfigure for xdg-shell popups
It's just dead code, we can add it back in the unlikely event that we should
need it.

Change-Id: I209fe92fb160e022c992384d731964e774596f74
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-06-13 09:32:17 +00:00
Robert Griebl
e16b3c1cc1 Add support for building QtWayland on macOS
Change-Id: I98aadd5019e913bf0adcf0122b7b209981926278
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-06-09 21:53:48 +00:00
Johan Klokkhammer Helsing
6ac25c4b12 Skip flaky tst_WaylandClient::dontCrashOnMultipleCommits()
Until we figure out the cause, just skip it.

Task-number: QTBUG-68756
Change-Id: I70d84ddabae4ef9df834ff8a471dddeee97e18f9
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-06-09 11:08:36 +00:00
Oswald Buddenhagen
d92ccb70a5 Merge 5.11 into 5.11.1
Change-Id: I3d3cc001320febd64529f0997b88efd69303fa30
2018-06-07 17:11:34 +02:00
Johan Klokkhammer Helsing
2c9bb12fe3 Client: Add tests for xdg-shell v6 window geometry
Change-Id: Ifb7a1d63a136349cd99d516e63732b4393967468
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-06-07 07:57:16 +00:00
Johan Klokkhammer Helsing
90336adc17 Client: Set window geometry for xdg-shell v6 and stable
Eventhough, according to the protocol spec, it should work perfectly fine
without setting the geometry, gnome-shell 3.28.2 chokes on it and
applications get stuck in the upper right corner and can't be moved.

Qt seems to be the only toolkit left that doesn't set the window geometry, so
let's just do it the simple, though somewhat incorrect, way.

The downside of this patch, is that the unset window geometry used to include
subsurfaces that extended outside the parent surface, but here we just set it
to the frameGeometry of the window.

Task-number: QTBUG-68575
Change-Id: I8a9d029ff6d57bd33294658e3bfd69ff08cd38c1
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-06-07 07:57:12 +00:00
Johan Klokkhammer Helsing
19403799d7 Don't ask libwayland to set absurdly long window titles
It will cause libwayland to terminate the application.

Task-number: QTBUG-68715
Change-Id: I1d1830453da224bec8bf4c5d6ab087c0e05328a8
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-06-06 12:19:09 +00:00
Johan Klokkhammer Helsing
2987de952c xdg-shell v6: Make sure popup parent is topmost popup when grabbing
Avoids protocol errors on Weston, gnome-shell and wlroots-based
compositors.

[ChangeLog][QPA Plugin] Fixed a protocol error that sometimes happened
when showing popups such as nested menus on xdg-shell unstable v6.

Task-number: QTBUG-67988
Change-Id: I037aec94fba3d177dd0392e5a216a604bc65ac4f
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-06-05 08:09:05 +00:00
Joerg Bornemann
6b54806003 Correct the include for QInternalMimeData
Since qtbase/9f27bfb3, users of QInternalMimeData should include
qinternalmimedata_p.h.

Change-Id: I531d5fa318f55497b955b03c7e25d51a6f87ba05
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-06-01 05:53:53 +00:00
Paul Olav Tvete
e6a0a0ce53 Client: Accept prioritized list of shell integrations
[ChangeLog][QPA plugin] QT_WAYLAND_SHELL_INTEGRATION environment variable
now accepts a semicolon-separated list of shell integrations.

Change-Id: I91364f53ea584bfbd9693b5ea58df07226c3e2c6
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2018-05-29 16:05:29 +00:00
Johan Klokkhammer Helsing
796b02d398 Client xdg-shell v6 tests: Fix dangling pointer usage
Fixes some flaky tests

Change-Id: Ifac7c95d12714d61afc37f879f4c70b2a7dbe0cf
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-05-29 08:26:06 +00:00
Johan Klokkhammer Helsing
6482bf5075 Client: Add shell integration for xdg-shell stable
[ChangeLog][QPA plugin] Added support for xdg-shell stable.

Mostly a copy of xdg_shell unstable v6 with prefixes and suffixes
removed. Otherwise, this is what changed:

- The global is now named "xdg_wm_base", since "xdg_shell" was taken by
  xdg-shell <= v5.
- Anchors and gravities are not bitfields anymore.

Task-number: QTBUG-66783
Change-Id: I8ca881aae52cc07b22ff5e26df13a9a1566f58f4
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-05-29 07:29:32 +00:00
Johan Klokkhammer Helsing
53749e2944 Client: Set unconfigured xdg surfaces (v6) as not exposed
Previously, isExposed would always return true, which resulted in a
wl_egl_window being created and an illegal attach and commit occurring.
i.e. protocol errors such as:

zxdg_surface_v6@15: error 3: xdg_surface has never been configured

Change-Id: I277c65d663cfed0fe436a128fe1963d138f01c87
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2018-05-28 11:41:20 +00:00
Johan Klokkhammer Helsing
b8410dd239 Client tests: Ensure there are no leftover ivi_surfaces
Similarly to what we do for xdg-shell v6.

Change-Id: Id72d0af53c7bcee461b741341bf6b587ffe98522
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-05-28 11:25:09 +00:00
Johan Klokkhammer Helsing
390856f452 Client: Move xdg-shell-v6 to a plugin
[ChangeLog][QPA plugin] The xdg-shell-v6 shell integration has been
moved to a plugin.

Change-Id: I548d19590ddbc8ad3e791301359a6de17ac9dcd8
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-05-28 11:23:06 +00:00
Johan Klokkhammer Helsing
4183147e80 Fix flakiness in xdg-shell v6 client tests
Change-Id: I4b63edef6ea130ad7f7f294bf0903d84b8db4723
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-05-28 10:38:14 +00:00
Johan Klokkhammer Helsing
389cc81a99 Client: Move cursor theme logic into its own class, QWaylandCursorTheme
...and out of QWaylandCursor. Encapsulates the ugly details of wayland
cursor themes, and presents a simple interface.

A theme is created with a given size and theme name. wl_cursor_images for a
theme can be acquired through:

wl_cursor_image *QWaylandCursorTheme::cursorImage(Qt::CursorShape shape);

Change-Id: Ia6fc6f2997133ca25c1610ecdf075ecb5c4edbfa
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-05-28 09:27:26 +00:00
Johan Klokkhammer Helsing
60146a92b8 Client: Only load cursor theme once
Now cursor themes load once per device pixel ratio, and not once per screen.

Task-number: QTBUG-67796
Change-Id: I4c253e65a791d69e7d510c4228989390a4343110
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-05-28 09:10:31 +00:00
Qt Forward Merge Bot
f9da2c645c Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: I8a1570eac9bbe418283522624002f8a03dd60c95
2018-05-26 03:00:15 +02:00
Johan Klokkhammer Helsing
52b2e5a346 Client tests: Remove redundant cleanup testing
We already have a QTRY_VERIFY(!compositor->surface()); in
tst_WaylandClient::cleanup() which is already run after every test.

The assertions from tests that are explicitly testing surface creation and
destruction have not been removed.

Change-Id: I21d574f5fe33d4e4c309dcfb2f50bde447238df2
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-05-25 07:46:52 +00:00
Johan Klokkhammer Helsing
9391184890 Replace qtkey-extension with qt-key-unstable-v1
- Remove the "dummy" request, which seems to be just leftover test code.
- Rename the event from "qtkey" to "key". We've already prefixed the
  global interface, no need to also prefix the event.
- Prefix the global with `zqt_` and suffix it with "_v1". If we make
  backwards incompatible changes, we should bump the suffix, rename the
  xml-file and reset the version number.
- Add some documentation to the xml file.
- Add notice about (lack of) compatibility guarantees.
- Four spaces for indentation

Task-number: QTBUG-68423
Change-Id: I78f0eaff4cac22f27318ba32c83c83feb2de857a
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-05-24 05:34:17 +00:00
Johan Klokkhammer Helsing
da03b6f2a2 Add readme for internal protocol extension folder
There have been some misunderstandings about the compatibility guarantees
of our internal protocols. I.e. some compositors have started
implementing them, and then we have removed or made backwards
incompatible changes to the protocols.

Also, when we've made backwards incompatible changes, we've previously
incorrectly used the version attribute of the interface, however that
attribute is supposed to be used for backwards *compatible* changes. This
causes problems for both ourselves and others.

So let's be explicit about it in a README and be more careful when
reviewing protocol extension changes if they don't bump the version
suffix (i.e. rename the protocol).

This is the same versioning and naming scheme as used by the unstable
protocols in wayland-protocols.

Task-number QTBUG-68423

Change-Id: I9c1a7e13c9356660914bbfeff4139ec033f1d443
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-05-24 05:25:57 +00:00
Thiago Macieira
72a5628a34 Suppress warning about MFD_CLOEXEC being redefined
glibc 2.27 #defined it as just "1U" instead of the kernel "0x0001U".
Same value, but because the tokens are different, this triggers a
warning.

Change-Id: I052407b777ec43f78378fffd153112449de8cf4f
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-05-23 12:57:55 +00:00
Thiago Macieira
75b60471cf Disable the -Wmissing-field-initializers warning for Clang too
qwldatadevicemanager.cpp:277:1: warning: missing field 'finish' initializer [-Wmissing-field-initializers]

Change-Id: I052407b777ec43f78378fffd15311263e7498287
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-05-23 12:57:43 +00:00
Johan Klokkhammer Helsing
d8e37e4b03 Move wl-shell to a plugin
[ChangeLog][QPA plugin] The wl-shell shell integration has been moved to a
plugin.

This also adds API so shell integrations can return native resources for
windows, as it was needed in order to continue to supporting wl_shell_surface.

Change-Id: Ibc68ffcc5b0c6993d8f4e078f663e4d67340e1a5
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-05-18 09:37:07 +00:00
Johan Klokkhammer Helsing
ae58414530 Client: Lazy load QWaylandCursor
If nothing is trying to access QWaylandScreen::cursor() leave the platform
cursor uninitialized. This in turn avoids initializing cursor themes, which may
use a significant amount of shared memory depending on the cursor size, number
of screens and screen DPI.

Task-number: QTBUG-67796
Change-Id: Ifd062cb52c4889adcaadeb00bea928b8e84a2182
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-05-16 10:35:38 +00:00
Aleix Pol
c683571411 Adapt the cursor size per screen
Adapt the cursor size to the screen's devicePixelRatio, so we are not
forced to have a tiny cursor on a high dpi screen or a huge cursor on
external low-dpi displays.

Change-Id: I3712dc64e5c5e2e05d0dc5943bd49ba5c1335cd3
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-05-15 09:43:58 +00:00
Johan Klokkhammer Helsing
9b49788540 xdg-shell-v5 client: Remove accidental qDebug
Change-Id: I1dbe14b317dd0a460abf3602da1772968d2fe150
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-05-14 14:20:50 +00:00
Johan Klokkhammer Helsing
1e34573674 Clean up forward class declarations in qwaylanddisplay_p.h
Change-Id: I57ead68f2c243c14015afeddc9721866b3dd01f1
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-05-14 12:19:28 +00:00
Johan Klokkhammer Helsing
6f3e121276 xdg-shell-v5: Suffix classes with v5
To make it easier to distinguish when implementing xdg-shell stable.

Change-Id: I730f3b8411f68b7e5c707b7ba6b94b2563ac500e
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-05-14 12:17:45 +00:00
Johan Klokkhammer Helsing
08d02f5392 Rename xdg-shell.xml to xdg-shell-unstable-v5.xml
Also change the protocol name in the xml file from xdg_shell to
xdg_shell_unstable_v5 (similar pattern as v6) because qtwaylandscanner doesn't
support the file name being different from the protocol name.

Change-Id: I1d9edf7c8ca512e716284250a2b2bc13e205c33c
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-05-14 12:17:36 +00:00
Johan Klokkhammer Helsing
7ef6c33a69 Move xdg-shell-v5 to a plugin
This is the first step in deprecating xdg-shell unstable v5 and making the good
names available for the good names for xdg-shell stable.

Shell initialization has been refactored slightly, so the
QWaylandShellIntegrationFactory actually tries to initialize the shell
integration before returning it. Similarly for the factory method of non-plugin
shells.

Change-Id: I85e60594c4fc03c6f302c04316110aed428d28dc
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-05-09 11:04:35 +00:00
Johan Klokkhammer Helsing
4f292a1226 Fix QWaylandXdgShellV6Integration::handleKeyboardFocusChanged
The implementation was broken because it:

1. Didn't activate popups.
2. Activated toplevels with keyboard focus twice.
3. Tried to cast to xdg-shell-v5 classes, so windows were never deactivated.

Change-Id: If492ebdbcd10a3214424f7bf6ac01e7ba8704bbf
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-05-09 09:55:24 +00:00
Gatis Paeglis
b2a8bcb9c4 update to use new dnd APIs
For details see qtbase/10b3286313c78fa380b5fe676a7c14f3ae84f017

Change-Id: I197b2c158a0ffcb21cab973169c6257afa3d2c06
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-05-09 06:17:32 +00:00
Johan Klokkhammer Helsing
d47119339b Client: Add acked configure support and implement it for xdg-shell v6
The problem:

The code in QWaylandWindow::setWindowStateInternal made many assumptions about
how the shell surface responded to new window states, and when and if they were
applied. Particularly:

- The shell integrations support different subsets of Qt::WindowStates, so it
  doesn't make sense to map from states to setFullscreen, setNormal, etc. in
  QWaylandWindow because it really depends on the shell integration how it
  should be handled.
- Some states are not supported/unknown on some shells and should immediately be
  rejected.
- On some shells, particularly those where the current state is unknown, flags
  need to be resent even though they didn't change.
- Should handleWindowStatesChanged be called immediately (client decides) or
  should it wait for a configure event (compositor decides)? I.e. the mState
  variable only makes sense for some shells.

Furthermore, when state changes come from the compositors, some shell
integrations require that a configure event is acked by the client and that the
next committed buffer's size and content matches that configure event.
Previously, we would just ack immediately and still send a buffer with the old
size before a correct frame was drawn. i.e. sending incorrect acks, which would
lead to protocol errors on some compositors.

Additionally, QWaylandWindow::createDecoration() also assumed that windows
should have decorations unless they are fullscreen. This is not always the
case, particularly on ivi-application and probably on future shell integrations
for embedded or tiling window managers etc.

The Solution:

The responsibility of mapping requested window states to Wayland requests have
been moved to the QWaylandShellSurface implementation. QWaylandWindow now calls
a new virtual, QWaylandShellSurface::requestWindowStates(Qt::WindowStates),
instead of trying to be smart about it. The virtual getters and setters for
window states have now been removed from the QWaylandShellSurface interface.

It's now also the shell surface implementation's responsibility to call
QWaylandWindow::handleWindowStatesChanged if and when it knows a new state is
effective.

QWaylandWindow::configure has been replaced with
QWaylandWindow::applyConfigureWhenPossible(), which causes another new virtual,
QWaylandShellSurface::applyConfigure(), to be called whenever we're free to
resize and change the states of the next buffer (this is when states should be
acked). This means that shells that use acked states need to store the pending
states themselves, call applyConfigureWhenPossible(), wait for applyConfigure()
to be called, call resizeFromApplyConfigure() and handleWindowStatesChanged(),
and finally ack the applied state.

Acked state for xdg-shell v5 and v6 has now been implemented, which also means
we've now:

[ChangeLog][QPA plugin] Implemented support for maximizing, minimizing, and
setting fullscreen with xdg-shell unstable v6.

[ChangeLog][QPA plugin] QWindow::isActive now follows configure events on
xdg-shell unstable v6 (like v5).

QWaylandWindow::createDecoration queries QWaylandShellSurface::wantsDecoration
before creating window decorations, instead of using the previously unreliable
QWaylandWindow::isFullscreen().

[ChangeLog][QPA plugin] Window decorations are now automatically disabled for
ivi-application.

The refactor also removes a couple of hacks:

- QWindowSystemInterface::flushWindowSystemEvents() was called in
  QWaylandWindow::setWindowStates. Since this hack was introduced, the events
  now have oldState and newState members, and their values seem to make sense
  (ensured in the tests).
- The hack for unminimizing on xdg-shell v5 in QWaylandWindow::createDecoration
  was not needed anymore.

Finally, tests have been added for xdg-shell v6 to ensure that the right Wayland
requests are sent, that we respond to configure events from the compositor, and
that the Qt events and signals emitted on the client side make sense.

Task-number: QTBUG-53702
Task-number: QTBUG-63417
Task-number: QTBUG-63748
Task-number: QTBUG-66928
Change-Id: Ib4c36b69105750f9dbdcc78adcf71e2e994cc70d
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-05-07 11:34:41 +00:00
Qt Forward Merge Bot
69b9686236 Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: I146a45fb7ae41646d1cff42268e3a89ab2b92dfb
2018-04-17 03:00:40 +02:00
Allan Sandfeld Jensen
0fc0a890a0 Fix typo in wayland formats
Change-Id: Ic4a8c64fa0e1b56a8d21316c96e3eeb3f20fb8b1
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-04-16 07:41:05 +00:00
Johan Klokkhammer Helsing
faf99279d4 Use deliverUpdateRequest on QPlatformWindow instead of QWindowPrivate
This is because bff59f87ba11cac1dfa710f021522372de7a776f in qtbase.

Task-number: QTBUG-67480
Change-Id: I2bb89f94ecc1d78e8919cd16e7bf9d8877baf121
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2018-04-06 05:28:58 +00:00
Johan Klokkhammer Helsing
91e81af14c Fix crash when calling setVisible for EGL windows twice within one slot
Task-number: QTBUG-63411
Change-Id: I56c367a1801d215e93bf195332272cfee300cdd8
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-03-23 08:36:54 +00:00
Johan Klokkhammer Helsing
2804d35cb4 xdg-shell v5,v6 shell integrations: Fix crash when showing popups
If a popup was shown without any input events happening first, it would cause
nullptr dereferences in both xdg-shell v5 and v6.

Fixes crashes in:

- tst_QAccessibility::comboBoxTest
- tst_QAccessibility::menuTest
- tst_QWindow::touchInterruptedByPopup
- tst_QFocusEvent::checkReason_Popup

Task-number: QTBUG-67150
Change-Id: Ib3e06326f71e4ab5f74727cb4f79626a21c34d55
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-03-20 08:12:14 +00:00
Johan Klokkhammer Helsing
bfb8f07065 Run shell agnostic tests on all shells
And not just the default one.

Change-Id: I6debbda9ae249f5f9df914901dc60722253b7d09
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-03-13 07:46:56 +00:00
Johan Klokkhammer Helsing
e6c84abc55 Mocking compositor: Don't leak wl_shell_surfaces
Change-Id: Ic133b41bdcfb98418be4a0141f382734f1d5db85
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2018-03-12 11:06:31 +00:00
Johan Klokkhammer Helsing
08d8136071 Add client-side tests for ivi-application
Tests ivi surface creation and configuration.

Task-number: QTBUG-66512
Change-Id: Idff60eb99eb34b7fce1c935bd036ef18a8f97d7c
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2018-03-12 11:05:55 +00:00
Johan Klokkhammer Helsing
45dbab401a Send configure events in shell-agnostic client tests
xdg-shell >= unstable v6 requires surfaces to be configured before buffers can
be attached. Make sure to send a configure event when a compositor would
normally do it.

Task-number: QTBUG-66510
Change-Id: Icbff6ebaa597e858d92d621849aa0df7a8a976f3
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2018-03-08 16:29:45 +00:00
Johan Klokkhammer Helsing
9df7980958 Client test for xdg-shell v6 configure events
Task-number: QTBUG-66689
Change-Id: Ifdf38a9ab73357fdbe61e77f0464b227ddd2e8ac
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2018-03-08 16:13:33 +00:00
Johan Klokkhammer Helsing
1605c84bbf QWindow::requestActivate() is not supported on Wayland
Return false for the WindowActivation capability to ensure we don't run tests
that require it.

Change-Id: Ia24d6eef02d462a25f3d50597debda9e062b3955
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-03-08 11:00:03 +00:00
Johan Klokkhammer Helsing
b127a86f1d Fix nullptr dereference in client tests
Change-Id: I932cd20f17b5486a1161569c5e9a3feebabeee8e
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-03-08 10:34:58 +00:00
Johan Klokkhammer Helsing
88101641c0 Test what happens when wl_display_connect fails
A failed wl_display_connect should make the platform plugin fail gracefully.
Add a test for it to make sure.

Change-Id: I87a3d9ee151fcdb1bc6ad9ffba44ad5014ede005
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-03-08 10:34:08 +00:00
Johan Klokkhammer Helsing
fae6abb64b Show warning when trying to minimize on wl-shell
Change-Id: Ice040dad70d0bcaf8bd101da5956ae75e211fe91
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-03-07 11:47:04 +00:00
Johan Klokkhammer Helsing
1ed7da501a Add logging category for Wayland platform plugin
Change-Id: Ic42119e47afc7bda72eb985fe86d1343a762c274
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2018-03-05 14:31:00 +00:00
Antonio Larrosa
5f32a06c28 Test for null pointer before using it
Task-number: QTBUG-66867
Change-Id: Ibbe407fa3ac32141b52fa0086e9f1ebfd27052ba
Done-with: Fabian Vogt <fvogt@suse.de>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Jan Grulich <jgrulich@redhat.com>
2018-03-05 14:08:38 +00:00
Johan Klokkhammer Helsing
2d468ebfa5 Client: Implement QPlatformWindow::startSystemMove()
Hooks into what we already use for the window decorations.

Task-number: QTBUG-58044
Change-Id: Idcd971f69d52a5bb760bb6bffb26e9f5bdd429df
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2018-03-05 12:26:08 +00:00
Johan Klokkhammer Helsing
01d0594c9e Ensure paintGL() is called in tst_WaylandClient::glWindow()
The test is still skipped due to CI problems, though (QTBUG-65802).

Task-number: QTBUG-66511
Change-Id: I79a67a80708de4cf2a7347a96c4b6344182d3ae0
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-02-28 16:16:45 +00:00
Johan Klokkhammer Helsing
bb409e849b Use override when applicable
Applied automatic fixes using clang-tidy's modernize-use-override.

This adds the "override" keyword where it's possible and also removes the
"virtual" keyword when redundant.

Change-Id: I899950e5cf8782785d30a245a9c69c1720905d50
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-02-28 14:25:27 +00:00
Johan Klokkhammer Helsing
290e12e5a6 Use default member initialization for raw pointers
Initialize to nullptr to prevent undefined behavior.

Change-Id: I7753c0be77a886d62ecb1cd7b86fc8c98340b0b8
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2018-02-28 10:51:35 +00:00
Johan Klokkhammer Helsing
9147c0e688 Init variables where they are declared when possible (clang-tidy)
clang-tidy -p compile_commands.json $file \
    -checks='-*,modernize-use-default-member-init,readability-redundant-member-init' \
    -config='{CheckOptions: [{key: modernize-use-default-member-init.UseAssignment, value: "1"}]}' \
    -header-filter='qtwayland' \
    -fix

Afterwards I ran search and replace on the diff to clean up some whitespace errors:

- Replaced '(\n\+[^:\n]*)(:\s+\+\s+)' with '$1: '
- Replaced '(\n\+[^,\n]*)(,\s+\+\s+)' with '$1, '
- Replaced '\n\+\s*\n' with '\n'

I also had to do some manual edits, because for some reason, this particular
clang-tidy check doesn't trigger for some files.

Change-Id: I3b3909bac4bf20108bbe8ad1e01bcc54236dae1b
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2018-02-27 17:03:41 +00:00
Johan Klokkhammer Helsing
ef99cac249 Client: Fail gracefully when wl_display_connect fails
[ChangeLog][QPA plugin] If we're unable to create a connection to the Wayland
display, fail gracefully so other platform integrations can be tried instead.

This also adds QWaylandIntegration::hasFailed() which can later be extended to
report that the platform plugin is unusable for other reasons. I.e. no
compatible shell extensions or similar.

Task-number: QTBUG-59762
Change-Id: I0f1ae73982e2860814235c1a189741d130e1db3e
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-02-26 15:59:45 +00:00
Johan Klokkhammer Helsing
bf18cfcd84 Client tests: Use generated classes for mocking shells
Removes a lot of boiler-plate code and makes the two shells more similar. This
also makes it easier to extend the shells with additional mocking
functionality.

Change-Id: I4a846b06eeda695527d7c5679df339beae983af6
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-02-26 11:19:37 +00:00
Kari Oikarinen
91ef77f095 Fix use after free in tst_WaylandClient::dontCrashOnMultipleCommits
QBackingStore had a pointer to TestWindow window, but it was destroyed only
after the TestWindow was already deleted.

Change-Id: Id8fe38277cf843d532f2d8c2fdbe1f69d0309a7f
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-02-21 15:16:40 +00:00
Johan Klokkhammer Helsing
e87c6a3809 Fix crash when connecting a new screen
In QWaylandWindow::virtualSiblings, don't include screens that have not been
added yet. I.e. QWaylandScreens for which QPlatformIntegration::screenAdded has
not yet been called.

There are two reasons why this crash wasn't covered by the
removePrimaryScreen() test. First of all, the mock output didn't send
wl_output.done events when updating the mode/geometry. These wayland events are
what causes QWindowSystemInterface::handleScreenGeometryChange() to be called
(where virtualSiblings are called).

Furthermore, virtualSiblings is only called when the geometry actually changes,
so add a new test that changes the screen geometry of the existing screen while
a new one is being added (i.e. moves it to the right).

Task-number: QTBUG-62044
Change-Id: I623fbf8799d21c6b9293e7120ded301277639cc6
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Aleix Pol
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-02-21 12:38:57 +00:00
Johan Klokkhammer Helsing
e3d236cfa7 Fix flakiness in tst_WaylandClient::events
The test was flaky because we have a workaround for a bug in Weston where
Weston fails to send the last wl_touch.frame event (QTBUG-36602). We've worked
around it by letting our client handle the wl_touch.up event before the frame
event if it's the last up event.

This caused a race condition in our tests, though (which include the frame
event). Because Q_TRY_COMPARE(window.touchEventCount, 1) would pass and the
window was sometimes destroyed before the frame event had been sent by the
compositor thread.

Work around it by moving the touch testing before the pointer testing, so the
surface is still alive when the compositor tries to send the frame event. That
way the test will not be flaky, and will continue to work when we eventually
remove the workaround in QWaylandInputDevice.

Task-number: QTBUG-66537
Change-Id: I5673445682810e75343c6df2d1b2a4f1c1b21bcb
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-02-21 10:36:28 +00:00
Johan Klokkhammer Helsing
6eac43515d Use nullptr instead of 0 or NULL
Applied automatic fixes using clang-tidy's modernize-use-nullptr, and some
manual cleanup to prevent QFlag macros to be affected.

Change-Id: I88f94390185bc6e6f23693b68723cd5710815ae6
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2018-02-20 14:15:08 +00:00
Johan Klokkhammer Helsing
8de7183ae1 Test that xdg_toplevel_v6s are destroyed before xdg_surface_v6s
Adds an assert so tst_WaylandClientXdgShellV6::createDestroyWindow verifies
deletion order.

Task-number: QTBUG-65568
Change-Id: I0b4dd350f811495a9c7a78811915647fb713a43a
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-02-01 08:25:34 +00:00
Paul Olav Tvete
397d3f75ab Merge remote-tracking branch 'qt/5.10' into dev
Change-Id: I603cbb164e6015c1bb7796bd8bb055d84dbc3b04
2018-01-31 10:29:53 +01:00
Liang Qi
4a6dd89b63 Merge remote-tracking branch 'origin/5.9' into 5.10
Change-Id: I6c201769561f53d88c89f75cce7d9a7b2643d2f6
2018-01-18 18:04:03 +01:00
Paul Olav Tvete
d4dc5f3573 Fix requestUpdate()
After commit 027a7131543b0194a7d9e98a6b53928e30bc080f, mFrameCallback
is set to null when the next buffer is attached, not when the callback
arrives. This means that a requestUpdate() after the frame callback
would never be delivered. The solution is to test mWaitingForFrameSync
instead. There is still a small race condition, but the failure case is
that the update will arrive after 5 ms instead of exactly at frame sync.

Change-Id: I413ed2b76c8527f825e501077bab712146b6705f
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-01-18 14:57:45 +00:00
Liang Qi
c177b75420 Merge remote-tracking branch 'origin/5.9.4' into 5.9
Change-Id: If72cba3251b792028a51f815f2f0cb064779bcec
2018-01-18 11:02:23 +01:00
David Edmundson
dd2018f0e5 Don't recreate hidden egl surfaces
QWaylandEglWindow deletes surfaces when a window changes from hidden to
visible, presumably as a result of us not having a valid wl_surface
object. By extension it doesn't make sense to create a surface whilst a
window is still hidden.

This fixes a crash where a QQuickWindow hides and then is destroyed. In
QQuickWindow destruction we have to create a valid context in order to
delete any textures/assets owned by the scene graph; as the wl_surface
has gone this causes an error in the EGL libs when we create an EGL
surface.

Task-number: QTBUG-65553
Change-Id: I9b37a86326bf2cd7737c4e839c1aa8c74cf08116
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-01-16 15:20:14 +00:00
Johan Klokkhammer Helsing
6ec8b1093a Fix static builds with libwayland-egl
There was a naming conflict between the client buffer integration, wayland-egl,
and the system library libwayland-egl.so

Rename the plugin binary to qt-plugin-wayland-egl to avoid the issue.

Task-number: QTBUG-65652
Change-Id: Ib074c25e269a5e11b087fb4c3ddb15fef7d4a7ee
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2018-01-16 12:23:27 +00:00
Johan Klokkhammer Helsing
8f880a5d5d QWaylandWindow: Fix incorrect namespace order
Change-Id: I741d3fb392c6121f2d8514ee2504fc88f99092ff
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-01-16 10:24:19 +00:00
Johan Klokkhammer Helsing
f94c0f2cb6 Fix protocol error when destroying xdg surfaces (v6)
Destroy role object for toplevels when destroying the xdg surface.

Task-number: QTBUG-65568
Change-Id: Ibe027c3eef8160f9fd2cfb05971c92ceb155f95b
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-01-11 10:08:21 +00:00
Liang Qi
6b85987299 Adapt to qtbase 5.10 API change: qssize_t -> qsizetype
Task-number: QTBUG-65600
Done-with: Thiago Macieira <thiago.macieira@intel.com>
Change-Id: I34116dad8eecd01090596270965b9a24f6fe8f39
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-01-07 14:12:00 +00:00
Liang Qi
8bc7ea23e3 Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts:
	.qmake.conf
	src/compositor/compositor_api/qwaylandquickitem.cpp

Change-Id: Id2f49e8703a67daedcee66db83f006df828d9da0
2018-01-07 00:13:39 +01:00
Johan Klokkhammer Helsing
0483742ad9 Client tests: Support testing with window decorations enabled
Previously tests would hang because eglInitialize (which was called on window
decoration creation) would wait for a Wayland roundtrip while our compositor
thread was waiting for more commands.

Work around this by prematurely causing the clientBufferIntegration to be
initialized before applicationInitialized (when the compositors switches
to handling requests synchronously).

Change-Id: I793c70a8f3a764cb3a70f00ddcab76cd4044b442
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-01-05 10:37:48 +00:00
Johan Klokkhammer Helsing
2a82da8787 Revert "Ref count buffer usage"
When a buffer is committed multiple times, not all compositors (i.e. Weston)
send a matching number of release events. This caused clients to freeze on some
occasions on those compositors because they were waiting for a release event
that never came.

This reverts commit 1fbffb9dfb011c3b7c7aaa41b7be3a8167ce0c8a.

Backport from 5.10.0 to 5.9.4

Task-number: QTBUG-64631
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
(cherry picked from commit f1b07ea1ee9e839a5ca38c4c330511ab6cd0b56c)
Change-Id: I2acf5574a1b792d3bbf928fb0bc328aa8ee8ffe0
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2018-01-05 08:26:04 +00:00
Johan Klokkhammer Helsing
d7f4f6ba10 Client tests: Fix wrong position being sent when mocking touch events
We were sending ints when we should have been sending wl_fixed_ts.

Change-Id: I9f074334cb3ea8a3d61789ff641c2d022a5989b7
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2018-01-04 12:07:01 +00:00
Johan Klokkhammer Helsing
0b60f768af Client: Don't leak the last Wayland sync callback
If QWaylandDisplay is deleted while waiting for a sync callback, don't leak the
callback.

Change-Id: I4fd46cdc8c431e44998d70d1afc01018c4908f27
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2017-12-18 08:28:04 +00:00
Aleix Pol
0f29ae0024 Fix crash when opening a window with a hidden parent
We have a transient parent but it doesn't have a shell surface.
We need to make sure that it exists before setting the transient
parent's shell surface as the parent to the window.

Change-Id: I918b2f14074217638529ba73530f0102f7438079
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2017-12-14 15:36:01 +00:00
Liang Qi
5e6e5d8930 Merge remote-tracking branch 'origin/5.10.0' into 5.10
Change-Id: Id64ad5564f3cd85829ede15ebf33db13cd1587fa
2017-12-08 13:59:27 +01:00
Johan Klokkhammer Helsing
7b40685ad2 Simplify and modernize QWaylandInputDevice
Use enum values and nullptr instead of using magic ints directly. Also get rid
of ifdefs in constructors by using in-class member initializers.

Change-Id: I037bec7070296a4a8cb46ebe85104caf5a08fb77
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2017-12-05 13:43:42 +00:00
Giulio Camuffo
dd13698a73 Implement basic key composition support
Use xkbcommon-compose to handle basic compose key support. We should expand on
it in the future to handle things like resetting the compose state on text
field switching.

Task-number: QTBUG-54792
Task-number: QTBUG-64572
Change-Id: I9d1d5ca4c9991928e12979f69eaa477e0cb28ada
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2017-12-04 13:47:25 +00:00
Marc Mutz
a8a2dc0d8a Port away from QRegion::rects()
Use begin()/end() instead.

Change-Id: I1a73b4518ee7408271ec913a219c034e330b0d5a
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2017-12-04 13:27:42 +00:00
Holger Hans Peter Freyther
e96d16d2b0 ivi: Try the ivi-shell as shell integration as well
When using the IviApplication in a compositor and launching a
Qt Client it will fail to initialize a shell. This is because
QtWaylandClient::QWaylandIntegration::initializeShellIntegration
will only try some shells by default. Add the ivi-application
to make it work out of the box. Add it last to have XDG and WL
shell take preference and avoid loading the libivi-shell.so.

Change-Id: I5c97c65d81434cba59cf9cb5bbe4b6fd8ccf4757
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2017-12-01 12:25:36 +00:00
Johan Klokkhammer Helsing
a5c79599c8 Client: Add removePrimaryScreen test
Test that removing the primary screen will not crash the application.

Task-number: QTBUG-62044
Change-Id: I8ba870e1d608629318ef897f88a6cc0d6e6aa85e
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2017-11-24 08:40:15 +00:00
Johan Klokkhammer Helsing
f7e6a478b7 Fix tst_client::windowScreen and tst_client::screens sometimes freezing
Sometimes the callback in forceRoundTrip would be handled in response to the
QEventDispatcher::aboutToBlockSignal signal emitted at the start of
processEvents, and would wait there for more events that may never come.

Task-number: QTBUG-64696
Change-Id: I4e38a4dd4158afc606e779ff615b5eef98b955b0
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2017-11-23 15:53:42 +00:00
Johan Klokkhammer Helsing
f1b07ea1ee Revert "Ref count buffer usage"
When a buffer is committed multiple times, not all compositors (i.e. Weston)
send a matching number of release events. This caused clients to freeze on some
occasions on those compositors because they were waiting for a release event
that never came.

This reverts commit 1fbffb9dfb011c3b7c7aaa41b7be3a8167ce0c8a.

Task-number: QTBUG-64631
Change-Id: I818d9bd71e5d9ce7a351a2010914b7219b1975bc
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2017-11-21 10:33:03 +00:00
Johan Klokkhammer Helsing
a6257efe0c Client: Use QPointer for focus members of input device capabilities
Change-Id: I2824269f89fddb7e276cf0e35df3f7c063b6d8b3
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2017-11-17 13:07:06 +00:00
Johan Klokkhammer Helsing
2b32defc38 Verify that the client supports the compositor removing outputs
Change-Id: I799d29fa43ad429b7973d7a210aca554d6b0ce26
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2017-11-15 14:54:30 +00:00
Johan Klokkhammer Helsing
679dc2e281 Client: Test that the current screen is updated by surface events
Change-Id: If96691a2d844263a1e01a86df8b0d58f23848a4c
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2017-11-15 08:34:27 +00:00
Johan Klokkhammer Helsing
7f8e7b4195 Automatically change scale when entering a new output
Change-Id: I99198d47eac5b2091fe2bfd8fc24646be9c9890a
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
2017-11-15 06:44:37 +00:00
Johan Klokkhammer Helsing
83cd3d383a Change serial parameter from int to uint
In QWaylandWlShellSurface::setPopup

Change-Id: I591b759bf8db9548776b28a485d75b53507761f4
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2017-11-06 04:44:38 +00:00
Paul Olav Tvete
448312b179 Merge remote-tracking branch 'qt/5.10' into dev
Change-Id: I4f885a551093ada07da97fd3d99902e36f98595e
2017-10-27 10:37:21 +02:00
Paul Olav Tvete
dd6248faff Merge remote-tracking branch 'qt/5.9' into 5.10
Change-Id: I6c283081669594b3e8c6b30194bb96e389319cb2
2017-10-25 14:06:54 +02:00
Johan Klokkhammer Helsing
80f167fbc4 qtwaylandscanner: Remove globals when destroying wrappers
When globals are destroyed on the compositor side, send the "global_remove"
event and set the resource implementation to nullptr so all further requests
are ignored.

This also adds a compositor test to see if outputs are removed when they are
deleted.

Change-Id: Ib77a4c3d4c2c93283a14ac20f5964e2ce08a1d38
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2017-10-25 11:37:38 +00:00
Johan Klokkhammer Helsing
7f8d9b7f54 Ensure QWaylandWindow::transientParent has a shell surface
This may not be a perfect solution, but it's better than the current one, where
the transient parent may not have a shell surface (because the window may be
hidden or not yet initialized).

Task-number: QTBUG-63840
Change-Id: Ia5f04376d4b6d12b41ceeab5ba13cdc1b63b4e3c
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2017-10-25 08:48:10 +00:00
David Edmundson
1fbffb9dfb Ref count buffer usage
The QPlatformBackingStore can get flushed multiple times between paints.

Flush sets the front buffer, but it does not create a new backbuffer.
We can't do so without doing an expensive pre-emptive copy.

This means we send the same front buffer multiple times. This is
somewhat questionable with regards to the Wayland specification, but
seems to work.

If we do send a buffer multiple times we can't consider it free until
the last attached buffer is released; otherwise we end up painting into
a buffer whilst the server is still using it, leading to
flickering.

Change-Id: I8235eed6a85f0d52b37544e7bcb623b16a9dd832
Reviewed-by: Marco Martin <mart@kde.org>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2017-10-23 08:13:55 +00:00
Johan Klokkhammer Helsing
b90c278ed8 Test client side xdg shell v6
Apart for some new mocking code for xdg shell v6, this is mostly a refactor of
the existing test, to reuse the existing mocking code between the different
shell integrations.

Change-Id: I68f93ab12ac47e51a50fd69647286cab46a3c595
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2017-10-20 10:59:08 +00:00
Johan Klokkhammer Helsing
6cf44bf690 Fix crash when wl-shell setType is called with a hidden parent
Fall back to creating a toplevel instead

Change-Id: If7db27d08b79e4f9f8c82fa8f9bf73abdb2585d9
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2017-10-20 10:02:03 +00:00
Johan Klokkhammer Helsing
4e0e6db654 Use QImage::sizeInBytes() instead of deprecated QImage::byteCount()
Change-Id: If3f21fc43d0118c1819d354c8ef43f1b79617c7b
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2017-10-19 06:57:09 +00:00
Johan Klokkhammer Helsing
6c1c47611f Tests: Add missing Q_UNUSEDs
Change-Id: Ifc7e5d000b7f5d75fb899d2294008f8dcabca777
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2017-10-16 07:56:49 +00:00
Christophe Chapuis
b3621cfe7c QWaylandWindow: reset window should reset mask
When QWaylandWindow::reset() is called, the window's mask is not changed. It
means that when the window will be initialized again, it will not re-send the
mask description to the server side through Wayland.

Task-number: QTBUG-62638
Change-Id: I07d561f466836bbd90ae58521c0768ed85554256
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Christophe Chapuis <chris.chapuis@gmail.com>
2017-10-13 13:55:36 +00:00
Johan Klokkhammer Helsing
58b30a6820 Fix -Wreorder warning by using default member initializers
Change-Id: I50f2928f1329fe45b4315baa33909b3227be1faa
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2017-10-05 07:29:25 +00:00
Johan Klokkhammer Helsing
5ba3b471b1 Add missing override for QWaylandClientExtensionTemplate::bind
Change-Id: Id8dabf1e54cb2f6fda2d8ac41b4c63bb68f835f5
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Erik Larsson <erik@ortogonal.com>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2017-10-04 12:05:13 +00:00
Liang Qi
bd668a31d6 Merge remote-tracking branch 'origin/5.10' into dev
Conflicts:
	src/client/qwaylandwindow.cpp
	src/client/qwaylandwindow_p.h
	src/compositor/compositor_api/qwaylandpointer.cpp

Change-Id: Icbc22a1ae3cdd9cde438742817d07fccf97f647b
2017-09-27 15:10:13 +02:00
Kevin Funk
458b1bc6c1 Replace Q_NULLPTR with nullptr
Change-Id: I9699a957430b8d3574ce29acb91b7ada9ea6209b
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-09-26 15:45:33 +00:00
Liang Qi
2a2da715b0 Merge remote-tracking branch 'origin/5.9' into 5.10
Change-Id: I76bfc271efcf75c75bf38f4bf58503e1d2a00839
2017-09-20 11:38:52 +02:00
Paul Olav Tvete
1a0939a8de Fix server buffer integration override logic
Assign to the actual variable instead of a new one with the same name.

Change-Id: I9e4c3525891ff53f0194198b9c11f223df4c14a9
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2017-09-14 08:28:59 +00:00
Johan Klokkhammer Helsing
61510d62d1 Temporarily rename QWaylandWindow::screen to waylandScreen
The function is being made virtual in qtbase. Rename it to avoid issues with CI
(missing override). It can be renamed back and made to override later.

Task-number: QTBUG-63177
Change-Id: I4e3029445b34c53bfdd3e99254a690a1fac6f06e
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
2017-09-13 11:48:16 +00:00
Johan Klokkhammer Helsing
f35dc39ae9 Set window screen from wl_surface.enter and leave events
Removes the pointer mScreen, which would previously cause a crash if the screen
was removed.

Ensures that QWindow::screen() is correct, except in the cases where:

- The compositor has not yet sent enter and leave events (in which case the
  primary output is returned).
- The compositor is not sending enter and leave events (although this is
  mandatory, some compositors don't do this).
- The application developer has tried to move the window with
  QWindow::setScreen(QScreen *). Since there is no way for a client to ask to
  be moved to a specific monitor in windowed mode, we return the requested
  screen until a new enter or leave event is received.

This will also be useful when implementing/fixing features where the current
screen matters. Examples are QT_AUTO_SCREEN_SCALE_FACTOR and the optional
output parameter to wl_shell_surface.set_fullscreen.

Task-number: QTBUG-62044
Change-Id: Iafde2e278fbc8876e8dafe5b2a4d2482fdc7961a
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2017-09-11 13:49:48 +00:00
Paul Olav Tvete
844002cb81 Close popups in the correct order
According to the protocol, child popups have to be closed before
parents, but QMenuBar/QMenu will sometimes close the parent first.

Change-Id: Id027ac483b727a19388df619fe1503d794e12c12
Task-number: QTBUG-62048
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2017-09-07 09:50:36 +00:00
Johan Klokkhammer Helsing
027a713154 Fix crash when window attach is called without waiting for frame callbacks
If QWaylandWindow::attach was called before getting the frame callback, it
would overwrite mFrameCallback. Hence, all but the last frame callback would
still be alive after the QWaylandWindow destructor.

When the dangling callbacks got invoked the data pointer was statically casted
to the deleted QWaylandWindow, resulting in undefined behavior.

In this change we only delete frame callbacks from the render thread, avoiding
a race condition we fixed earlier. And we always destroy the frame callback
when adding a new one, ensuring that the destructor will clean up the only
remaining callback.

There's a test confirming that the crash has been fixed.

This fixes the flakiness of many of the qtbase auto tests.

Change-Id: Iecb08ab48216eac61b1ebc5c0e0664d4aac900c0
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2017-08-31 09:50:51 +00:00
Thiago Macieira
32daa1a5b9 QWaylandShmBuffer: use a memfd if we can for a simple memory buffer
which has a file descriptor we can also use to share with

Change-Id: I8d96dea9955d4c749b99fffd14cd61628c616b30
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2017-08-26 03:09:54 +00:00
Liang Qi
70044654d3 Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
	.qmake.conf

Change-Id: Ia0f9d099e92a40cae7ec506781f70c56415bcf89
2017-08-17 10:48:28 +02:00
Paul Olav Tvete
7f964c1bd0 shm-based server buffer for testing on desktop
Change-Id: I2ea03f3366524d3133a65870abad9d9389dfec9c
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2017-08-16 09:56:39 +00:00
Johan Klokkhammer Helsing
2a3676d8c4 Use nullptr instead of 0 in qtwaylandscanner
Change-Id: I5ffee26a4c0cd7726e007cc0692e403e15b5726e
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2017-08-15 23:53:04 +00:00
Johan Klokkhammer Helsing
9041247dc7 Try -lEGL when checking for wayland-egl
This will detect wayland-egl on an imx6 without pkg-config

Change-Id: I9c0fe6eef375fd0431a218c3b0407505c29eead9
Reviewed-by: Karim Pinter <karim.pinter@qt.io>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2017-08-15 13:19:19 +00:00
Paul Olav Tvete
43d25e770c Update server buffer integration
Fix crashes, and change the (private) API to be more usable.

The libhybris code compiles without warnings, but is untested.

Change-Id: I1433daf1ba76d7869d1dfe260642199ce5a1b849
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2017-08-15 11:45:18 +00:00
Frederik Gladhorn
afb68a09f2 Remove extra semicolon
Change-Id: I3941d7e8caffb613f546e628c7e089e971d1e8b8
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2017-08-11 07:55:39 +00:00
Marco Martin
66af01b17f Fallback to focusWindow as transient parent
The wayland protocol requires Popup windows to have a transient parent
set, in order to correctly position the window on the screen.
In Qt, some popup menus don't have it, so they will appear misplaced in
the screen. This adds an heuristic which makes transientParent()
return the current application focus window, which is an approximation
which won't be always correct, but seems to fix most applications

Task-number: QTBUG-60932
Change-Id: Icec1e306d3f64f4f00ad735a8c2eedb99e85eabb
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2017-08-10 08:33:53 +00:00
David Edmundson
f41bd9c06e Check surface exists when setting textinput focus
QWaylandWindow resets the surface on various events.
Handling focus comes in a posted event, so this can be after we've
hidden a window and lost a surface.

Task-number: QTBUG-61704
Change-Id: I535ff78c6bc2b86816696a08f8eebc47186d1225
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2017-08-09 16:11:27 +00:00
Thiago Macieira
516c3b7fe9 QWaylandShmBuffer: use QTemporaryFile
Instead of using mkstemp. Even current glibc versions do not open the
file with O_CLOEXEC, so this code is not thread-safe. QTemporaryFile is.
And since Qt 5.10, it will also use O_TMPFILE on Linux, so the file will
not actually exists on disk.

Take this opportunity to use the runtime directory instead of /tmp.
There's no guarantee that the /tmp filesystem can support mmap'ing,
while XDG_RUNTIME_DIR has that guarantee. It's also usually a tmpfs, so
no data will be leaked to disk.

Change-Id: I8d96dea9955d4c749b99fffd14cd5335d1114cef
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2017-07-31 16:13:31 +00:00
David Edmundson
6a1f52c90d Reset mFrameCallback in destruction
Otherwise we crash if we call reset twice. For example if we call
setParent and setVisible together.

Change-Id: I7f07825167bf8c3236a80e649a6d6805fd6c868b
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2017-07-19 14:23:58 +00:00
Giulio Camuffo
7a41c0171c Use a non grabbing zxdg_popup_v6 for tooltips
Change-Id: I9de16c48a1dee7728fb02faa590c112bd656aa09
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2017-07-12 14:17:36 +00:00
Paul Olav Tvete
636ce8d733 Merge remote-tracking branch 'qt/5.9' into dev
Change-Id: I286b58e2c3a42c1078fd25d5b699c8a17edb1c23
2017-06-27 14:50:40 +02:00
Thiago Macieira
8618b4227f Add missing break
Found by GCC 7
 qwaylandinputmethodeventbuilder.cpp:110:51: warning: this statement may fall through [-Wimplicit-fallthrough=]

Change-Id: Ia3e896da908f42939148fffd14c47fc6058b0933
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2017-06-22 03:24:49 +00:00
Thiago Macieira
177c1ae57e Disable the GCC warning about missing initializers
New fields are appended to the structure, so we can't initialize them as
we would lose compatibility with earlier versions of libwayland. So just
disable the warning.

Change-Id: Ia3e896da908f42939148fffd14c4806ce3468e56
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2017-06-22 03:24:46 +00:00
Thiago Macieira
d6e47a81c2 Fix all the warnings about deprecated qLoadPlugin1
qLoadPlugin is variadic and can take one argument to the plugin loader,
so just use that.

Change-Id: Ia3e896da908f42939148fffd14c481e367fdb128
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2017-06-22 03:24:43 +00:00
Tasuku Suzuki
a92a519e79 Translucent background support
Change-Id: I6e7b5869097f579020c7a4439441a63a0771e955
Task-number: QTBUG-55956
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2017-06-19 00:08:41 +00:00
Johan Klokkhammer Helsing
57af7c4c22 Send SurfaceCreated and SurfaceAboutToBeDestroyed events for wl_surface
Previously, the events were matching the life cycle of QWaylandWindow. This
commit changes it so the events are matching the life cycle of wl_surfaces
instead (a QWaylandWindow can outlive several wl_surfaces).

Some of these events were already sent in QWindowPrivate (the first and last).
Now we handle the cases where the wl_surface is destroyed and recreated due to
hiding/showing the window or when changing the role of the wl_surface.

Task-number: QTBUG-58423
Change-Id: Ie4a4e7dd529e1a41a2cf42e02cebb3c8aca4a4cc
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
Reviewed-by: Marco Martin <notmart@gmail.com>
2017-06-09 15:11:07 +00:00
Liang Qi
fbec715de2 Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
	.qmake.conf
	src/client/qwaylandwindow.cpp

Change-Id: I3ae070ff20df4b858a4eef769438092c061e47ef
2017-06-07 13:52:32 +02:00
Giulio Camuffo
fa4d3dec37 Fix setting the window state
Change-Id: I236095aa9103a2a35ecd79e747b8d1ee843a98f1
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2017-05-26 13:32:59 +00:00
Johan Klokkhammer Helsing
8e181a61f4 Add missing header guard to mocksurface.h
Change-Id: I353c8b67c0990ca6fc4d8168c09d2af8899ed081
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2017-05-19 07:49:23 +00:00
David Edmundson
b5b693e888 Match WaylandWindow scale to what we set on the buffer, not the screen
Currently if the screen scale changes we report a new devicePixelRatio
to rendering but we don't send a new set_buffer_scale nor do we update
the buffer sizes. This leaves us in a corrupt state.

Change-Id: I5bb2bd5eec440cd1ce9080cd3a3dc65448f68298
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2017-05-18 09:53:05 +00:00
Robert Griebl
9b6a927026 Remove duplicate code
This code started as a 1:1 copy from the base class in 5.8. Just call the base
class implementation, since this was also improved in the meantime.

Change-Id: Ib9c7c6efa3f043a83029b5387097533bf5da833e
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2017-05-15 09:05:54 +00:00
Giulio Camuffo
c9a156f29e Set the cursor when the pointer enters the window
Change-Id: I1ff9928bc5d9d1d80ce07561243eeec89c406e36
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2017-05-12 15:53:34 +00:00
David Edmundson
6698deaa46 Pass modifiers with wheel events
Change-Id: I345cdeea1357a8f9201a74b2d5e80350b6c42f24
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2017-05-12 15:15:19 +00:00
David Edmundson
07a8cb2d91 send handleScreenGeometryChange with scaled geometry
Change-Id: Ia9c3622369114e04318628262cc6ce2ea447cb4c
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2017-05-12 14:55:56 +00:00
Tasuku Suzuki
32075e0e4b Fix build without features.xlib
Change-Id: Id0f57aa71a1ec66dc16c9cfa1f31a2e1bdf3b61d
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2017-05-08 14:00:25 +00:00
Jani Heikkinen
57551844fc Fix licensing
Currently tests are licensed under GPL-EXCEPT, examples under BSD and
src under LGPL so replase old license headers with new & proper ones.
Also remove old & unused license files

Task-number: QTBUG-57147
Change-Id: Ia6a738798736c275dc309ccfa5b627dc2178d241
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-05-04 04:29:11 +00:00
Paul Olav Tvete
13a861ede8 Don't depend on shell extension
The mininimal-cpp compositor example does not have any shell extensions.

Change-Id: I925450a75ab6f93245ca9897bbc6f092d93364b6
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2017-04-27 13:01:07 +00:00
Liang Qi
d862329074 Merge remote-tracking branch 'origin/5.9' into dev
Change-Id: I7285dfeaac0d7963607930904aa017bedb1e48ab
2017-04-21 11:10:27 +02:00
Johan Klokkhammer Helsing
b0f57f5e31 Don't try to create zxdg_popup_v6s with incomplete positioners
A positioner without a size is considered incomplete, and creating a popup with
an incomplete positioner is a protocol error.

Change-Id: I5efdba0edfe6edc5f7b0a4908c1e43b93d35eea8
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2017-04-19 09:52:03 +00:00
Liang Qi
9ef82c4dae Merge remote-tracking branch 'origin/5.8' into 5.9
Change-Id: I436178527be54fd0efa6ffbe39918740d4737478
2017-04-18 22:07:42 +02:00
Thiago Macieira
240fb37484 Fix warning about inconsistent use of override keyword
qwaylandshmbackingstore_p.h:93:19: warning: 'paintDevice' overrides a
member function but is not marked 'override' [-Winconsistent-missing-
override

Change-Id: I27b55fdf514247549455fffd14b1791d4dd6b6b3
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2017-04-04 06:53:23 +00:00
Thiago Macieira
e9b87c0b1c Fix warning about unused variable
QPoint has no side-effects so it's safe to remove.

 main.cpp:214:12: warning: unused variable 'gradCenter' [-Wunused-variable]

Change-Id: I27b55fdf514247549455fffd14b179b3a6a08617
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2017-04-04 06:53:11 +00:00
Olivier Goffart
15b3e52c18 Adapt to the API change in QPlatformWindow::setWindowState
Change-Id: Ic6655f239ea449baf862934608feda182799c42d
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2017-03-28 07:36:21 +00:00
Paul Olav Tvete
0dc450ec22 Don't redefine symbols from system libraries
The system library versions may contain driver-specific functionality.

Change-Id: Iaaa71bff7d2c305cb47798920a5977aaa2a3ac8a
Task-number: QTBUG-58299
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2017-03-28 07:16:26 +00:00
Kai Koehne
dfb0a833d6 Doc: Fix external links to wayland-ivi project
Seems that the project moved to github.

Task-number: QTBUG-59656
Change-Id: Ib6c9c62e987f11ffbcffe013cbeb4a4454e594b0
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
2017-03-24 12:11:46 +00:00
Paul Olav Tvete
086b0a9a26 Clean up draganddrop and clipboard features
Don't assume that no-draganddrop implies no-clipboard. Introduce
a new private feature wayland-datadevice which contains the
common functionality. This feature cannot be controlled independently,
but is automatically disabled when both clipboard and draganddrop are
disabled.

Change-Id: I6aac09c7ee524e3b11f0a1caa4a6c62fc3f1d10f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2017-03-23 13:37:00 +00:00
Paul Olav Tvete
a74c82edb4 Prepare for qtbase change
The signature of setWindowState is changing. Remove the 'override'
so qtwayland compiles without error against both the new and the
old version.

Task-number: QTBUG-59588
Change-Id: I2adc6a5a1addc9b8855a3a1b3c1f0e3952181846
Reviewed-by: Liang Qi <liang.qi@qt.io>
2017-03-20 15:34:40 +00:00
Albert Astals Cid
697e074e2c Remove platformDropData() that is removed from QPlatformDrag
Change-Id: I12321852027279d8b34d2e231253dfd858167a15
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2017-03-20 12:05:29 +00:00
Paul Olav Tvete
2c24b00733 Temporary change to prepare for qtbase change
QPlatformDrag::platformDropData() will be removed in qtbase. By
removing the 'override' specifier, we make sure that qtwayland will
compile with both versions, so we can get the changes through the
CI system.

Change-Id: I8f5f3252ecc5125e5dab3f7a4da8760fe259b739
Reviewed-by: Albert Astals Cid <albert.astals@canonical.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-03-13 14:44:18 +00:00
Paul Olav Tvete
c2f1a2dd89 Merge remote-tracking branch 'origin/5.8' into 5.9
Change-Id: I76be82a6da77f51f6d53239d593dc6f61951559b
2017-03-13 13:51:33 +01:00
Giulio Camuffo
4e319b5141 Fix build when xkbcommon is disabled
Change-Id: I0ec7a5aa8300e796b015c0d995e71ebf77727bbd
Task-number: QTBUG-58839
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Yong Bakos <junk@humanoriented.com>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2017-03-08 17:00:54 +00:00
Paul Olav Tvete
501aeedb54 Code cleanup (fixing -no-feature-cursor)
Move QWaylandDisplay member functions into the correct .cpp file.

Change-Id: Ie3915d2bd0d191900ad2fd306564bb732e40221a
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2017-03-08 08:12:41 +00:00
Paul Olav Tvete
44577f8cfb Remove QRegularExpression dependency
Fix build error with -no-feature-regularexpression.

Change-Id: I6d3d0228548d832abea74b8e1145dc5b09f77b1b
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2017-03-02 13:58:44 +00:00
Paul Olav Tvete
a89c479a01 Merge remote-tracking branch 'qt/5.8' into 5.9
Change-Id: I43cd0147a63b5523e3112f09bbfe60e1d6636e6c
2017-03-01 15:48:39 +01:00
Pier Luigi Fiorini
d4b15affa1 client: Set screen product information
Set QScreen manufacturer and model and set name to the
output name rather than the model.

Change-Id: I53dfb12d7d992d517885a2c6e9b95abcc57d5117
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2017-02-23 09:10:33 +00:00
Johan Klokkhammer Helsing
b109d2e848 Initialize the first wl_surface in the constructor of QWaylandWindow
This makes it possible to get a pointer to a wl_surface immediately after
platform window creation.

Task-number: QTBUG-58423
Change-Id: I2e62380af8b34d05ae31baacc071766493633022
Reviewed-by: Marco Martin <notmart@gmail.com>
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2017-02-22 11:18:32 +00:00
Giulio Camuffo
efce1fa6e4 Fix crash when running without shell integration
Change-Id: Ia480913fd9986cbd306858d1fb497e1fb70551f0
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
2017-02-16 14:08:52 +00:00
Oswald Buddenhagen
83f3b32872 fix typos in "Raspberry Pi"
Change-Id: I92938ad834999ceabe0b360ab733a2c54335004c
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2017-02-10 12:28:43 +00:00
Pier Luigi Fiorini
d2d84ab958 Deduplicate xcomposite-egl and xcomposite-glx plugin class name
In 81f80fa1 was set a wrong PLUGIN_CLASS_NAME for xcomposite-egl and
xcomposite-glx client integration plugins that collides with the one
for the compositor counterpart.

Task-number: QTBUG-58491
Change-Id: I23d141adf988942ac8c4c55f421cf763c0e4faff
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2017-01-31 11:56:33 +00:00
Liang Qi
fab1e8a5a6 Merge remote-tracking branch 'origin/5.8.0' into 5.8
Conflicts:
	src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.h

Change-Id: Ie45a13d3c866d0503e6e31b2a53b70f3420c5066
2017-01-26 01:05:17 +01:00
Liang Qi
9fc54bf67c Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
	.qmake.conf
	examples/wayland/custom-extension/client-common/main.cpp
	src/client/qwaylandwlshellintegration_p.h
	src/client/qwaylandxdgshellintegration_p.h
	src/compositor/compositor_api/qwaylandquickoutput.h
	src/plugins/shellintegration/ivi-shell/qwaylandivisurface_p.h

Change-Id: Ic78c610ddf102b0a185294f625bbfcb9238b0f3c
2017-01-25 12:19:40 +01:00
Johan Klokkhammer Helsing
2b7ad7f8a8 Replace all occurrences of Q_DECL_OVERRIDE with override
Change-Id: I16b7b23efe944b49d1fcc9e7588cdb0a991cebd1
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2017-01-23 16:20:03 +00:00
Tasuku Suzuki
0dadfc4233 Fix build without feature.draganddrop
Change-Id: I4fff1a8d48483298eebecdc751fe76e80444bd99
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-01-15 04:52:17 +00:00
Tasuku Suzuki
cfcc462166 Fix build without feature.cursor
Change-Id: If244e7ac58133ae6fbefacfa243d47fa210140be
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-01-13 14:25:20 +00:00
Tasuku Suzuki
12cc564878 Fix build without feature.clipboard
Change-Id: I195efecca9350cb519865f251cdee9c6e23d3592
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2017-01-13 10:11:44 +00:00
Johan Klokkhammer Helsing
c2d22c4ab8 Don't call wl_surface::destroy if the surface was never initialized
Task-number: QTBUG-57757
Change-Id: I85b74a3445c8d9df1a89b16760ce57e45204d2c6
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@hawaiios.org>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2017-01-05 05:51:10 +00:00
Johan Klokkhammer Helsing
a37ac71c33 Client: Don't crash when the receiver of a paste closes the pipe
Ignore the SIGPIPE signal

Task-number: QTBUG-57202
Change-Id: If22381f446675836aeb741a8e6da5473b0a27301
Reviewed-by: Martin Gräßlin <mgraesslin@kde.org>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2017-01-03 11:07:02 +00:00
Johan Klokkhammer Helsing
18d0f87b87 Fix crash when starting clients
Don't send wl_surface::set_input_region requests before the wl_surface has been
initialized.

The shapedclock example used to crash in wl_proxy_marshal prior to this fix.

Task-number: QTBUG-57757
Change-Id: I0a459d374bfb88fb22d048eda3722a41112d67a4
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2017-01-03 05:06:33 +00:00
Paul Olav Tvete
81f80fa19f Set PLUGIN_CLASS_NAME in .pro files
This fixes static linking and cmake config file generation.

In some cases, the class was renamed for disambiguation or just
uniformity.

Task-number: QTBUG-51248
Change-Id: Ibdce2e1b6a52312f84301c426632e94deeb567bd
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
2017-01-02 12:49:39 +00:00
Robert Griebl
97e8bd6f4a Fix initial window property values being propagated
This was broken since the the shell-surface refactoring.

Change-Id: I130b7396e85c570a9d11d609af6b3016e3f706f0
Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-12-16 17:13:44 +00:00
Johan Klokkhammer Helsing
dfb9a78e6c Handle the zxdg_toplevel_v6.close event
Change-Id: I9f470930e8d3d88430f8a7b2017fa2d0159a015e
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-12-13 13:35:20 +00:00
Liang Qi
fb41b1c4e1 Merge remote-tracking branch 'origin/5.8' into dev
Change-Id: Idd91b55bc2b1e3506d9385b3352aeda06de6d4bc
2016-12-12 09:49:16 +01:00
Johan Klokkhammer Helsing
6c6ccbfa8b Fix broken HEADERS list in client.pro
Change-Id: I67fa756f584577028a90706609bc6485ee98b126
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-12-08 14:19:32 +00:00
Johan Klokkhammer Helsing
6caaf81f9b Deprecate QT_WAYLAND_USE_XDG_SHELL
In favor of QT_WAYLAND_SHELL_INTEGRATION, which can be set to:

- ivi-shell
- wl-shell
- xdg-shell-v5
- xdg-shell-v6

Change-Id: Ie2ca1184f22dcac56beb441329ea8b5a9a81baf4
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-12-06 08:42:44 +00:00
Kai Koehne
c6acb1256b Doc: Mention files for different wayland protocols
Change-Id: If7de71930a8339ff8b36e74331810b186e1ebd32
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2016-12-06 08:42:08 +00:00
Giulio Camuffo
4f2c0f1a4e Add xdg_shell_v6 support for Qt clients
Task-number: QTBUG-56174
Change-Id: I6610905d0c9f29be29e812bcac193ea2a7e4f107
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2016-12-02 15:23:19 +00:00
Johan Klokkhammer Helsing
7a116ac3f0 Don't crash when trying to run on a compositor without outputs
Change-Id: I164ad71f42dff1ad92576729040608016497a56a
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-11-28 08:24:49 +00:00
Liang Qi
1835e6ed5c Merge remote-tracking branch 'origin/5.7' into 5.8
Change-Id: Ida15dd3247ae5690685fc66005cbebe58fca5d10
2016-11-26 12:56:25 +01:00
Liang Qi
45d4da6b73 Merge remote-tracking branch 'origin/5.7.1' into 5.7
Change-Id: I3aaa6641fb0b941d1fcadd796fb43edf15f34be9
2016-11-24 11:49:37 +01:00
Paul Olav Tvete
d14378ec1c Fix crash when destroying focus window
Make sure we don't try to disable input for a window that has
already been destroyed.

Change-Id: I1224599b3c43e2315b3571f01c5896a001614dc4
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
2016-11-23 13:51:54 +00:00
Paul Olav Tvete
50b875e12c Merge remote-tracking branch 'qt/5.8' into dev
Change-Id: I8a9455105e8e3519f6a860f58820382d7e337b1e
2016-11-23 13:36:04 +01:00
Paul Olav Tvete
e56040ec7d Fix crash on exit
Make sure that QWaylandDrag and QWaylandClientBufferIntegration are
destructed before the QWaylandDisplay.

Change-Id: I606154c9861a51d7cf3e5afb16d4f805ab9368b8
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2016-11-23 09:46:23 +00:00
Lars Knoll
f6912982eb Use new feature system, part 2
Convert all uses of QT_NO_FOO to proper QT_CONFIG(foo) checks.

Change-Id: Id0f0b3325c246567a43d6b2d71b0d69e5535e648
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2016-11-23 08:42:11 +00:00
Lars Knoll
1d51cabc54 Use the feature system internally
Get rid of almost all DEFINES += ... in the pro files,
instead use the proper QT_CONFIG() macro to determine
whether a feature is available.

Change-Id: I867769be2085c6ba93b6815e223e2b89edcb245d
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-11-23 08:42:05 +00:00
Lars Knoll
629663aa2e Move qtwayland over to use the new configuration system
Re-use configuration results from qtbase where possible and move
all pkg-config handling over to be done at configuration time.

Since waylandclient and waylandcompositor are two independent libs,
this required some duplication of features and libraries used by
both in the configure.json files.

Change-Id: I1f3ec56c85cb780324cc7634a3ad7951125853a0
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-11-23 06:50:34 +00:00
Giulio Camuffo
999fe98f66 Don't reset the cursor at every mouse move
Change-Id: I67f9a0d171da403ebb124ab584c2510891da80fc
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-11-22 09:09:17 +00:00
Johan Klokkhammer Helsing
882f20bbf4 Client: Close popups on xdg_popup::popup_done
Change-Id: I6d3b1ec5c22e6d07ed87948074d886cc9aa126ef
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-11-18 08:22:37 +00:00
Giulio Camuffo
9fc25b4a60 Create and destroy the shell surface when showing and hiding
This changes the shell surface handling for windows, and instead of
creating the shell surface at initialization time, and then attaching
a null buffer to hide it, it creates the shell surface on setVisible(true),
and destroys it on setVisible(false).
This fixes hiding when using xdg_shell, as that interface defines that
attaching a null buffer to an xdg_surface is an error.
Also this should help with bugged EGL drivers which attach a buffer
after eglSwapBuffers() returns, which used to cause a newly hidden
window to get a new valid buffer after we attached a null one, showing
it again.

Task-number: QTBUG-47902
Change-Id: I8e0a0442319a98cc1361803ea7be1d079b36fc8c
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-11-17 15:28:24 +00:00
Johan Klokkhammer Helsing
fb1ac98280 Rename qwaylandxdgpopup_p.cpp to qwaylandxdgpopup.cpp
Change-Id: I4bffaafdae07db96d4fcca7d2a0751941a2e635f
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@hawaiios.org>
2016-11-16 13:08:55 +00:00
Johan Klokkhammer Helsing
68b4408400 Remove useless method QWaylandShmBackingStore::hidden
Change-Id: I8e28d3c1dc2c2bbff4517ffe3b2f63c2ac86b95f
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-11-11 09:54:35 +00:00
Johan Klokkhammer Helsing
dfb256be36 Remove QWaylandWindow::shellManagesActiveState
If m_shellSurface was deleted, there was no way for QWaylandDisplay to know
whether the shell handled window deactivation or not.

The shell integration now always handles the window active state. The default
implementation of QWaylandShellIntegration will make a window active on
keyboard focus.

Change-Id: I80cfce9976b1d3c57094fdd8980c9110b873f239
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-11-10 15:32:07 +00:00
Johan Klokkhammer Helsing
ff3c3ad9f6 Follow the protocol for nested xdg_popups
The previous implementation sent the wrong parent for nested popups and used a
new serial for each popup instead of reusing the one for the current grab.

Change-Id: I22b1cbe997a64562d47275821c9146157c51bc42
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-11-10 15:31:27 +00:00
Paul Olav Tvete
2744dfbb87 Merge remote-tracking branch 'qt/5.7' into 5.8
Change-Id: Ibfe6fe6ed983b537d55544883b7dc75e5cc3fc37
2016-11-10 12:50:29 +01:00
Paul Olav Tvete
27490e8dde Merge remote-tracking branch 'qt/5.6' into 5.7
Change-Id: I1efd16d6c5f939d61001376c3b010eae1927595b
2016-11-10 10:40:10 +01:00
Johan Klokkhammer Helsing
8d291193ab Client: Cleanup mouse state after drag
Fixes an issue where dragging with the mouse would cause the next touch event
to not generate a synthesized mouse press event.

The touchDrag test can now be run directly after the mouseDrag test without
failing.

Task-number: QTBUG-56187
Change-Id: I53cc5f90fc8d8672936b23f54a017687d41c31fc
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-11-10 08:07:35 +00:00
Johan Klokkhammer Helsing
c8e2e7d102 Client: Fix touch getting stuck after drag-and-drop
wl_touch.up is not sent by compositors when dragging, so release all touch
points when the drag ends.

Task-number: QTBUG-56187
Change-Id: I1c3d03c72e75a551355c50bb5d82433f5e2e35f0
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-11-09 15:17:58 +00:00
Johan Klokkhammer Helsing
7afb887521 Don't create new xdg surfaces in updateTransientParent
Change-Id: I1644a75269fec40644f02eeb275d9e6b98995c0e
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-11-09 14:35:33 +00:00
Paul Olav Tvete
c1444d272e Fix build when some features are disabled
Make QtWaylandClient compile when Qt is configured with:

-no-opengl -no-accessibility -D QT_NO_CLIPBOARD -D QT_NO_DRAGANDDROP -D QT_NO_SESSIONMANAGER

Task-number: QTBUG-56192
Change-Id: Idc6aae6b36a35515109a27bed31a22e3e909ef27
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-11-07 09:07:48 +00:00
Liang Qi
192c88eae3 Merge remote-tracking branch 'origin/5.8' into dev
Change-Id: Ic2135c6ff27ca3fdef6a76dbdc72f73f5ca4d7fb
2016-11-03 12:11:41 +01:00
Giulio Camuffo
fec8cd87e0 Fix memory leaks
Several fields in QWaylandIntegration were never deleted, so use QScopedPointer to
handle that. Also use QScopedPointer for all the heap allocated fields of the
class.

Change-Id: I4c33be4157a6e17abfa1610f84ef9a88afe5f38a
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@hawaiios.org>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2016-11-03 08:33:00 +00:00
Johan Klokkhammer Helsing
bac96606a6 Client: Call parent requestUpdate after changing subsurface position
Calling setPosition on a child window would not send the appropriate commit
request after the wl_subsurface.set_position request.

Task-number: QTBUG-52118
Change-Id: I792016ce7e0a5a2efd3a32a98727b43ee0275b0e
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-10-26 14:17:44 +00:00
Johan Klokkhammer Helsing
cd36be2131 Client: Remove windows from keyboard focus list when destroyed
This fixes the undefined behavior in tst_WaylandClient::touchDrag and mouseDrag

Note: The test still fails if run twice in a row, but it appears to be
deterministic.

Task-number: QTBUG-56187
Change-Id: Ib45d82224f004d1324f2ce4d6b7df05ee36c04f5
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
(cherry picked from commit a33cc547055eb12c5efa82a6612cbf8793988b72)
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2016-10-25 04:09:38 +00:00
Johan Klokkhammer Helsing
e8a4ffff20 Client: Remove windows from keyboard focus list when destroyed
This fixes the undefined behavior in tst_WaylandClient::touchDrag and mouseDrag

Note: The test still fails if run twice in a row, but it appears to be
deterministic.

Task-number: QTBUG-56187
Change-Id: Ib45d82224f004d1324f2ce4d6b7df05ee36c04f5
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
(cherry picked from commit a33cc547055eb12c5efa82a6612cbf8793988b72)
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2016-10-24 09:59:06 +00:00
Oswald Buddenhagen
ac24d8341e use modularized platformsupport modules
Change-Id: I7883470e22deb089240d86df7dc2d625a107a53e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2016-10-22 14:22:20 +00:00
Oswald Buddenhagen
e723b954a4 fix namespaced build. *again*
Change-Id: I3cbc3efdac61a9f329d0796c64885e6565bd0b77
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
2016-10-17 10:45:59 +00:00
Giulio Camuffo
0f8195c08e Don't return a null QMimeData from the clipboard
The documentation for QClipboard::mimeData() doesn't say that the returned
value can be null, and some clients just dereference that without checking.
So instead return an empty QMimeData.

Change-Id: Ieec3140af4e7f33cde98ed96fd96b2674d0d0f9f
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@hawaiios.org>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2016-10-17 09:37:48 +00:00
Martin Gräßlin
039f8acf6a Call formatWindowTitle on the window title
According to QWidget::setWindowTitle documentation the QPA plugin is
responsible for adding the application name to the window title.
As it's supposed to be done for Unix platform the Wayland QPA also needs
to perform this task.

Task-number: QTBUG-56475
Change-Id: Ib261c68d08ca06d1ec4734c8c215a4ceb059fae3
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@hawaiios.org>
2016-10-11 13:39:13 +00:00
Paul Olav Tvete
3850310051 Don't try to deliver event to destroyed window
Change-Id: If1c57250e2dc9e0d55767bbdfb15c3e3f5d9b333
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2016-10-11 09:43:45 +00:00
Johan Klokkhammer Helsing
a33cc54705 Client: Remove windows from keyboard focus list when destroyed
This fixes the undefined behavior in tst_WaylandClient::touchDrag and mouseDrag

Note: The test still fails if run twice in a row, but it appears to be
deterministic.

Task-number: QTBUG-56187
Change-Id: Ib45d82224f004d1324f2ce4d6b7df05ee36c04f5
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-10-11 09:43:38 +00:00
Johan Klokkhammer Helsing
174b7a9a30 Clients tests: Don't send leave events for destroyed surfaces
Change-Id: Ia7dd13f629439b116f494ff8b7432020a65ea1df
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-10-11 09:43:26 +00:00
Johan Klokkhammer Helsing
2f496838f6 Fix failing test for touch drag
Don't send both touch down and touch move in the same frame. This confuses
mouse synthesis.

Task-number: QTBUG-56433
Change-Id: I7f0b88d6a27c87464c26ce1c194dc7f07a0eb382
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-10-10 11:12:17 +00:00
Paul Olav Tvete
50c2ed1b9d Fix race condition on mFrameCallback
Don't try to destroy the callback from two different threads. This
caused a crash with brcm-egl.

Change-Id: Idcb18fca9ed7f84902b88212c0cebd67932a59d3
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2016-10-06 05:31:02 +00:00
Johan Klokkhammer Helsing
16502a3dbc Make sure we send frameSwapped signals
QWaylandWindow::deliverUpdateRequest() may trigger a new requestUpdate, so we
must clear the mUpdateRequested flag first, so we don't accidentally clear the
flag that belongs to the next update.

Fixes missing updates on brcm-egl.

Change-Id: Ib0decd5e8eb58505ccb94e93de494163ce0fd2ec
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-10-04 15:15:13 +00:00
Kai Koehne
f4dad859c6 Document 3rd party code in Qt Wayland
Unfortunately the QPA plugin for Qt Wayland does not have a dedicated
help, which is why everything is right now crammed into the compositor
documentaton.

Change-Id: Iddc4d67a817f2cc3bb334b2f040fa55230b5da4f
Reviewed-by: Topi Reiniö <topi.reinio@theqtcompany.com>
2016-10-04 13:29:01 +00:00
Pier Luigi Fiorini
b80fe76ae2 Include headers with full path
Fix build of programs using the private API outside QtWayland.

Change-Id: Ib43ed1be8df8be3cc7b67588003cd7f0a6ff6eb1
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2016-10-01 09:33:33 +00:00
Kai Koehne
7a02e6b2a5 Update xdg-shell protocol file
Update xdb-shell.xml file to one from tag v1.9.0
in qtwebengine-protocols.git. This includes switch to
MIT license, and also some doc updates.

Change-Id: Ia4a565d73f2b25f8a2c41d0cde4c48ac5a793279
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2016-09-28 15:34:18 +00:00
Kai Koehne
52ac4ffe4d Update ivi-application protocol to version 1.9.1
This updates the license to MIT, which all of Wayland
moves to.

Change-Id: I91080d787f2930620941b421bf44164e02fcf637
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2016-09-28 15:34:16 +00:00
Liang Qi
b93c902429 Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts:
	src/compositor/extensions/qwaylandxdgshell.cpp

Change-Id: Ic45b930e01fec803287d63b6f2347f45b7638ffc
2016-09-20 14:31:15 +02:00
Johan Klokkhammer Helsing
56ea738c6d Warn if using QWaylandClientExtension without a Wayland plugin
Change-Id: Ibbf6acab4af45a6b17089bd3809c33a199dc89f6
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@hawaiios.org>
2016-09-19 08:58:35 +00:00
Paul Olav Tvete
00a0d843d2 Only bind the extension once
Change-Id: I014269a19ca569298df91c2c329193e5ee5ff9c5
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@hawaiios.org>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2016-09-18 07:05:37 +00:00
Paul Olav Tvete
be090d4d41 Cleanup and null ptr check
Don't crash if we ask for the surface before the window is created.
Also clean up NULL/0/nullptr and a c-style cast.

Change-Id: I2a5a66ee76a3a12c8ca32847dbe30cc640e924c2
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@hawaiios.org>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2016-09-18 07:02:28 +00:00
Paul Olav Tvete
df32477ff0 Fix FramelessWindowHint
setFlags() works just like setWindowState(): we have to use the supplied
parameter because the window's state hasn't been updated yet.

Change-Id: I223e01ef192f30911697e449669e745f0ad59d99
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@hawaiios.org>
2016-09-18 07:02:13 +00:00
Liang Qi
867734461f Merge remote-tracking branch 'origin/5.6' into 5.7
Change-Id: If43a69c30682eab4a40149a03c619047e84c9f6d
2016-09-17 22:55:45 +02:00
Samuli Piippo
75bd5ca2b3 Fix build with QT_NO_ACCESSIBILITY
The accessibility() function is ifdef'd in the base class,
which makes build fail when Q_DECL_OVERRIDE is used here.

Change-Id: Ic3d800ccf32b39f5bc8d3f94d222bc0d34457057
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-09-16 11:27:39 +00:00
Johan Klokkhammer Helsing
5f533e9ccc Remove or add window decorations when toggling fullscreen
Task-number: QTBUG-55343
Change-Id: I38e94a70585ba93d40de22698fda80530cf2156d
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-09-05 13:57:46 +00:00
Paul Olav Tvete
6cb80c8a53 Don't assume we always have a shell
The mininimal-cpp compositor example does not have any shell extensions.

Change-Id: Ifec2822ef4f5944eed02c19ddfc47419051364a4
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2016-09-05 09:36:54 +00:00
Liang Qi
673cdbe1e0 Merge remote-tracking branch 'qt/5.7' into 5.8
Conflicts:
	src/compositor/compositor_api/qwaylandseat.cpp
	src/compositor/compositor_api/qwaylandview.cpp
	tests/auto/compositor/compositor.pro
	tests/auto/compositor/compositor/testinputdevice.cpp
	tests/auto/compositor/compositor/testinputdevice.h
	tests/auto/compositor/testinputdevice.cpp
	tests/auto/compositor/testinputdevice.h
	tests/auto/compositor/testseat.cpp
	tests/auto/compositor/testseat.h

Change-Id: I98e045908dd964e5d4120bd35e71b8839c0d923a
2016-08-28 10:12:09 +02:00
Paul Olav Tvete
b47f89bb39 Merge remote-tracking branch 'qt/5.6' into 5.7
Change-Id: I6784a53fcc2f0f68b8e916181cb8cdef263782b8
2016-08-26 19:18:59 +02:00
Paul Olav Tvete
47d6975894 Merge remote-tracking branch 'qt/5.6.2' into 5.6
Change-Id: Ie6ec1ae90396619214cf1f29ae9595c5f1915e10
2016-08-26 16:23:35 +02:00
Martin Gräßlin
f6417bd744 Pass TRANSIENT_INACTIVE flag for windows with WA_ShowWithoutActivating
When setting a transient window also evaluate the state of the window
attribute WA_ShowWithoutActivating. If that flag is set the transient
should get the inactive flag as well.

Task-number: QTBUG-55403
Change-Id: I757e5527e78f730a440e26abb52e84c9b2bb2f3a
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-08-26 09:06:29 +00:00
Johan Klokkhammer Helsing
01234b85f8 Client: Fix keyboard focus logic and crash
The previous solution did not check for nullptr before dereferencing, which
caused a crash. Furthermore, it checked the new ShellSurface's
shellManagesActiveState before deciding whether to unfocus the old one.

Task-number: QTBUG-55526
Change-Id: I410b6200a5b7b86806f70970730045a4a25f21db
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-08-26 05:51:29 +00:00
Liang Qi
130e378a16 Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	tests/auto/compositor/compositor.pro
	tests/auto/compositor/compositor/compositor.pro

Change-Id: Id9f3cf97ca3b600bdafba846908643ff0f8964b9
2016-08-23 12:28:25 +02:00
Paul Olav Tvete
895b46e394 Fix autotest directory structure
The client and server parts are separate modules, so they need separate
top-level directories under tests/auto. This also makes it easier to add
new tests later.

Change-Id: I393341b6f4e8fc3afa480653f3482192e002e425
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-08-19 11:46:04 +00:00
Liang Qi
250ebcf086 Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	src/client/qwaylanddisplay.cpp
	src/client/qwaylanddisplay_p.h
	src/client/qwaylandxdgpopup_p.h

Change-Id: If86ea09971773dc6c541f07819459a90e8ab73a0
2016-08-11 10:50:02 +02:00
Johan Klokkhammer Helsing
2631c35ad7 Client: Fix popup position for xdg shell
Popups used xdg_surface instead of xdg_popup. It's not possible to set a
position for an xdg_surface, because it's supposed to be a top level window (in
xdg shell v5). Consequently, popups were treated as top level windows and
positioned randomly on Weston.

Using xdg_popup instead solves the problem.

Task-number: QTBUG-55063
Change-Id: I223348677ef8a1ef1eee6a4c389276a6c802bcb5
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-08-10 11:33:29 +00:00
Johan Klokkhammer Helsing
1514e2dc8a Make wl_shell and xdg_shell use the QWaylandShellIntegration interface
This simplifies the code in QWaylandDisplay and hopefully makes it easier to
implement a prioritized shell selection mechanism later.

Change-Id: I2bb3a13f8acedb60a6606cb3a8b5b228095eadf9
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-08-09 10:58:10 +00:00
Johan Klokkhammer Helsing
f70756c94d Client: Refactor window active state
Let shell surface implementations decide if they manage activated state. Moves
the logic out of QWaylandDisplay.

Change-Id: I75c86df68a1a93f9b1d2bf378b6603215d0b0128
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-08-08 10:43:53 +00:00
Liang Qi
70d36235b1 Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
	.qmake.conf
	examples/wayland/minimal-qml/main.qml

Change-Id: Ic34029a6aa77f2b359f40258a05421d82efd5b37
2016-08-02 10:44:58 +02:00
Johan Klokkhammer Helsing
1e36cce9fe Fix crash when dragging with touch without first having pointer focus
Also add drag-and-drop tests for both touch and mouse.

Task-number: QTBUG-54756
Change-Id: Ibfff48b1f2377022a8624e28e9f638076187ddca
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-08-02 07:11:26 +00:00
Johan Klokkhammer Helsing
8184ff6bfb Client tests: Unlock mutex while processing compositor commands
Only lock the client autotest compositor mutex when necessary. This allows
compositor commands to be queued while a command is being processed.

Change-Id: Ib2ca6b4942f57f56f56a055cbe6ce6d876695529
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-08-02 07:11:15 +00:00
Johan Klokkhammer Helsing
17b2417157 Remove logging of drag-and-drop data
Change-Id: Ic66faf02f7d4eb82aa898a2858a0271a007460a0
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@hawaiios.org>
2016-08-01 12:27:18 +00:00
Johan Klokkhammer Helsing
5bfd57f7d5 Also test touch in client events test
Following the same pattern as for mouse and keyboard, also test touch events.

Change-Id: Ie84aa0ffe0b0f4f66e9f40207c63d94e32f6dbaf
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2016-08-01 12:26:15 +00:00
Liang Qi
d04de01e80 Merge remote-tracking branch 'origin/5.6' into 5.7
Change-Id: I75a8ddc0652f3c6f438ef98e940c9357450d29c6
2016-08-01 11:03:38 +02:00
Johan Klokkhammer Helsing
2e6e785ca4 Compile with -no-opengl
QtWayland has not compiled without OpenGL for a while.

This patch fixes the compilation issues and removes the old config variable,
"QT_WAYLAND_GL_CONFIG" and instead checks for the presence of "opengl" in
"QT_CONFIG". A new define is also introduced, QT_WAYLAND_COMPOSITOR_QUICK,
because it may eventually be possible to use create a QtQuick compositor
without OpenGL.

Task-number: QTBUG-54322
Change-Id: Ica7b3b320212d4ae1f8b1053725b73c83739c73c
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-07-20 08:24:21 +00:00
Johan Klokkhammer Helsing
63d716543c Fix wrong path to qwaylandsharedmemoryformathelper_p.h
Change-Id: I711536ea8c7ec167e531afe61e716e0081d2aab6
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-07-18 07:18:25 +00:00
Johan Klokkhammer Helsing
84aec97c83 Fix clang compilation errors
Adds missing overrides and removes a private header generated by
wayland-scanner from the public API.

Change-Id: I53fc3f8bacca41821f0531aae02ca2a5da758e13
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-07-13 08:46:16 +00:00
Johan Klokkhammer Helsing
cf1bf1b684 Compositor: Rename shm to sharedMemory
sharedMemory is much clearer and will increase the readability of the code and
API.

Change-Id: Ibb6d7424fa8d44a94a0f4ddf476a564eb235323f
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@hawaiios.org>
2016-07-11 12:13:30 +00:00
Johan Klokkhammer Helsing
f4c3ad57b7 Fix high-DPI scaling of window decorations for shared memory buffers
Change-Id: I6833ab86ffdb4e37dad5108baddb7a54cfb5e9fa
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-07-11 07:42:30 +00:00
Johan Klokkhammer Helsing
d4d47f2a04 Use xdg_shell configure events to determine active window
According to the xdg_shell protocol, the compositor is allowed to set multiple
active windows. Qt's model, however, allows only a single active window.

In order to map between the models, a list of the compositor's active windows
is kept in QWaylandDisplay in the order they were activated. Hence, the front
of this list will always be the most recently activated window, and it will be
mapped as Qt's active window.

Previously keyboard focus was used to determine the active window, this method
has been disabled for xdg_shell.

Functionality for delaying the call to
QWindowSystemInterface::handleWindowActivated has been moved from
QWaylandInputDevice::Keyboard to QWaylandDisplay so the implementations can
share the workaround.

Task-number: QTBUG-53702
Change-Id: I878151f9c52ed09a8d6571c6208920436c3ca8fc
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-07-04 14:05:30 +00:00
Giulio Camuffo
f213a7d54e Fix the key code of key events when control is pressed
Change-Id: I51a57a32d8263e663a48dac15881d685359bc91d
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@hawaiios.org>
2016-07-04 08:34:00 +00:00
Liang Qi
05d8629760 Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
	src/compositor/extensions/qwaylandxdgshellintegration.cpp

Change-Id: I3e8666d0c2fd047f12daeb94b2c967c646576ed9
2016-06-30 14:28:55 +02:00
Liang Qi
c32b30362d Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	src/client/qwaylandinputcontext_p.h
	src/hardwareintegration/client/brcm-egl/qwaylandbrcmglcontext.h
	src/hardwareintegration/client/wayland-egl/qwaylandglcontext.h
	src/hardwareintegration/client/xcomposite-glx/qwaylandxcompositeglxcontext.h

Change-Id: Iac517e1985e4e67d7ca00ca4c10dcda9dd9079f9
2016-06-30 10:20:40 +02:00
Johan Klokkhammer Helsing
261f31eacb Remove unused method QWaylandDisplay::lastKeyboardFocusInputDevice
Change-Id: Iee19b36ae2032112e0097dc6eb2e4592697c2a1c
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@hawaiios.org>
2016-06-29 13:39:26 +00:00
Johan Klokkhammer Helsing
795378e64c Add missing Q_DECL_OVERRIDEs to client classes.
Change-Id: I10e550a25ce498bbeedc242ac73059cc6fdcef30
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@hawaiios.org>
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-06-27 11:50:23 +00:00
Johan Klokkhammer Helsing
e8d77c0101 Only resize when the cursor is actually on the window frame
The previous code seems to have been written under the impression that
QWindow::width() included frame margins, causing the resizing areas of the
window decoration to be too large.

Change-Id: Ia13f12afd88a4017d01853798226455b84290d01
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-06-20 10:29:27 +00:00
Johan Klokkhammer Helsing
065557fa2b Use QWaylandDisplay::addRegistryListener in QWaylandClientExtension
Gets rid of an unnecessary get_registry request

Change-Id: Ic8c6a61271658e07fbd67c83df0ae9e3d955d938
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-06-20 08:50:33 +00:00
Johan Klokkhammer Helsing
ad7245b942 Client: Fix incorrect size when maximizing using xdg_shell
When maximizing xdg_shell clients, the clients would call
QPlatformWindow::setGeometry() with frame margins included, resulting in a
window that was bigger than what was requested by the compositor.

The reason for this, was that QWaylandXdgSurface would subtract the frame
margins from the width and height only when the resizing state was set, not
when the maximized state was set.

Later, margins were added again before QWaylandWindow::configure was called.
This resulted in margins being subtracted and then added back for the resizing
state, while for the maximized state margins were only added and never
subtracted.

This behavior has now been simplified so only size including window frame is
tracked. This is what we receive in the XdgSurface::configure event anyway, and
also what QWaylandWindow::configure expects.

Change-Id: I0629e7e79a5367fa872743c6d025bfab8a4f2866
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-06-16 08:23:14 +00:00
Johan Klokkhammer Helsing
fe52b009f3 Set device pixel ratio for window decorations on scaled windows
Change-Id: I40d96362131124effd9405cdad4e3dea79e6ebe3
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2016-06-09 07:58:15 +00:00
Giulio Camuffo
477e7e844c client: Always accept the DnD data offer
Weston stopped sending the wl_data_device.drop event if the data offer
was not accepted, which was the case when it was coming from the same
client that was receiving the offer. So now always accept the offer
even if we will bypass the offer when retrieving the data.

Change-Id: If825f4dbc962a7812e379f36a42ceabe3eb3096f
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
2016-06-03 13:32:42 +00:00
Pier Luigi Fiorini
e79aa19f67 Rename QWaylandWindowManagerExtension to QWaylandQtWindowManager
* QWaylandWindowManagerExtension become QWaylandQtWindowManager
 * WindowManager become QtWindowManager

Follow naming convention already established for other extensions
like QWaylandWlShell and avoid confusion that might arise with
a name as generic as WindowManager.

Use QWaylandClient rather than wl_client.

Also the Wayland protocol definition has been renamed
to qt-windowmanager.xml

Change-Id: I941621ce229327c21eff9e80c7e92205cc60e8eb
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2016-05-31 14:17:26 +00:00
Johan Klokkhammer Helsing
f3df72594e Don't use deprecated wl_client_add_object and wl_display_add_global
Use wl_global_create, wl_resource_create and
wl_resource_set_implementation instead.

Change-Id: I8b1812df3daa2f4fe2ef8e850aa93ab125dadcf8
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2016-05-31 13:13:12 +00:00
Paul Olav Tvete
c1efd6fa2a Compile with -Wzero-as-null-pointer-constant
Task-number: QTBUG-53619
Change-Id: Idf073287f215113431cad64f85628e010176ab74
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2016-05-25 15:42:32 +00:00
Paul Olav Tvete
9272efd271 Merge remote-tracking branch 'qt/5.7' into 5.7.0
Change-Id: I8396ea4fc9f656accd2e97e3c78570bff64928cd
2016-05-20 14:36:27 +02:00
Liang Qi
696b7fca51 Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	.qmake.conf
	examples/wayland/qml-compositor/qml-compositor.pro
	examples/wayland/server-buffer/compositor/compositor.pro

Change-Id: Ie6fa21dfbdb71f33e0a4d29d34a824048cf00864
2016-05-19 21:44:24 +02:00
Paul Olav Tvete
90b66d4c46 Move QWaylandClientExtension out of namespace
The class name already has a QWaylandClient prefix. We don't need
QtWaylandClient:: in addition.

Change-Id: I42f16d43fe414e3388dfdb924e96d9fc2b0b4ba9
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-05-19 12:00:35 +00:00
Paul Olav Tvete
7f97e7116d Make qwaylandclientexport public
...since it's being used by a public header.

Change-Id: I38049c27c8bd4dc793416bf836d79c4226172d38
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-05-19 12:00:27 +00:00
Paul Olav Tvete
7efc23b8fb Rename private headers to _p.h
Change-Id: I0f0d1bd8efabc39325eec7dba4166ae0bccbf6ff
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-05-19 07:33:26 +00:00
Giulio Camuffo
b4b446915a Rename QWaylandClientExtension's active() to isActive()
Change-Id: Idaf14be727af20d308c21f2cf33db6d417765744
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2016-05-13 08:10:13 +00:00
Giulio Camuffo
c9ea9bb0fc Fix checking the Qt::BypassWindowManagerHint flag
Change-Id: I24ca4854aa6756f4cea4f4f5a471ffd9bf33c620
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Erik Larsson <erik@ortogonal.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2016-04-21 11:56:16 +00:00
Erik Larsson
4e697de346 Add QML api for client side extension.
This makes it simple to use client-side extensions in QML. The only
thing that the user needs to do is register the extension class using
qmlRegisterType() and the use the extension in QML.

Also adds simple QML example which uses client-side extension.

Change-Id: I2db99861d97c7bca5cfdbf86ba3a8ccc50fb24b0
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-04-21 11:29:56 +00:00
Erik Larsson
c477d954ae Move drag icon relative the cursor hotspot position
Instead of placing the drag icons top-left corner at the cursors
hotspot the drag icon is moved so it will be placed correct relative
the cursor hotspot. This will makes the drag feeling more realistic.

Change-Id: I8d60ae1b7788accb9034575983417abae4c58c1a
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
2016-04-21 11:12:43 +00:00
Jan Arne Petersen
f1bf4fc2c6 Use function to convert indices for text protocol
Use a proper function instead of left/midRef(index).toUtf8().size().

Makes it more clear what is happening and makes it easier when wayland
text protocol switches from byte-based to unicode character-based indices.

Also rename parameters of existing indexFromWayland() function to be the
same as in the new function.

Change-Id: Ie90abdcb264b74a024e96e041d5daf651920e9e4
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-04-19 08:44:50 +00:00
Giulio Camuffo
980f5fdfdc Destroy the subsurface protocol objects
This fixes a protocol error the compositor would send when a window
changes its parent, because we were creating a new subsurface without
destroying the old one.

Change-Id: I0855d0582153e0aff37be508d9fb43d22c9ad0b5
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2016-04-19 07:33:23 +00:00
Erik Larsson
e347632447 Compensate for window decoration size in data_device_enter/motion.
Change-Id: I71a549e597ec0821c778edca9f8cb20eefdcc75e
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-04-18 14:39:01 +00:00
Jan Arne Petersen
0654dbd90c Fix clicking on preedit text
Ignore clicks inside of preedit text for now instead of resulting in an
unexpected reset.

Change-Id: I9962f3a2a868a9a1afa7b0082fba97ec6cc6c500
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-04-18 12:27:10 +00:00
Jan Arne Petersen
853f8f6b67 Fix text-input support for new API
Update text input support to upstream text-input protocol v2 from
wayland-protocols. Remove support for input-method protocol for now.

Map text-input protocol on compositor side to the Qt input method API,
this allows to use any qt platform input method on compositor side
(especially qtvirtualkeyboard). Add support for qtvirtualkeyboard to
pure-qml example.

Implement all missing functions of the text-input protocol.

Change-Id: I597451ff65454a63dff86026b6a8d1ffbe07ce02
Done-with: Zeno Endemann <zeno.endemann@kdab.com>
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-04-18 11:39:14 +00:00
Liang Qi
17d8de6ca3 Merge remote-tracking branch 'origin/5.6' into 5.7
Change-Id: I31f4c29c985301d28d5c8d0501761c7d4fb7fda6
2016-04-08 10:24:17 +02:00
Giulio Camuffo
4a7a357aa8 Implement the QPlatformWindow::requestUpdate() virtual method.
The implementation will wait for the frame callback before firing
the update event.

Change-Id: Ieea748fda7c2aeb62cc40f35dbd122864c09f7cd
Reviewed-by: Johan Helsing <johan.helsing@theqtcompany.com>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2016-04-04 07:05:32 +00:00
Johan Klokkhammer Helsing
d77d934874 Client: Don't create shell surfaces for QShapedPixmapWindow
QShapedPixmapWindow is used as a drag-and-drop icon. This caused two roles
(wl_data_device-icon and wl_shell_surface) to be assigned to the same surface,
resulting in a protocol error.

This bug hasn't been encountered before because QShapedPixmapWindow sets
X11BypassWindowManagerHint, which was previously used to determine whether to
create a shell surface or not.

Task-number: QTBUG-52052
Change-Id: I1d79f3ec8ad08e0be1551c39df6232876dc2ac2e
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
Reviewed-by: Erik Larsson <erik@ortogonal.com>
2016-03-31 07:43:55 +00:00
Giulio Camuffo
3e0ad8f7c9 Add QWaylandShellSurface::fromResource()
Also make sure that the generated *::Resource::fromResource() code
returns null if it doesn't own the resource or if the interface is
wrong.

Change-Id: I904e0dd49dd6e535ef8cab6687c6869e1000048d
Reviewed-by: Johan Helsing <johan.helsing@theqtcompany.com>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2016-03-29 12:11:07 +00:00
Liang Qi
ef5f1a82e3 Merge "Merge remote-tracking branch 'origin/5.6' into 5.7" into refs/staging/5.7 2016-03-29 10:26:12 +00:00
Erik Larsson
e7ba33c0ec Remove attached() definition from header.
The implementation of attached() method was removed in commit 'Fix SHM
drawing logic' (330e3a78695bbe7f439676831b2336f3e5e26521) but the
definition in the header file was not.

Change-Id: Ib850bc7101a661882078be95011d75660f621622
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-03-29 08:08:13 +00:00
Arnaud Vrac
e418dbc403 Filter key events through the input method context
This allows the input method to capture keys, for example to implement
the Compose key or to navigate in a virtual keyboard.

Change-Id: Ic0ab318e84401ac339881eadd5eb992a2d57f9e3
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-03-25 07:23:59 +00:00
Liang Qi
c334c5b58d Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	src/compositor/compositor_api/qwaylandcompositor.h
	src/compositor/compositor_api/qwaylandquickcompositor.h
	src/compositor/compositor_api/qwaylandsurfaceitem.h
	src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration_p.h

Change-Id: I094128be314d2c3d4fe350fa7a162e37da34ae10
2016-03-22 19:05:17 +01:00
Pier Luigi Fiorini
93ee329289 Send keyboard repeat information
Complete the API for keyboard rate and delay that was previously
implemented sending the information to clients.

Back then this wasn't possible for lack of Wayland >= 1.6 on
the CI system.

Change-Id: I95bab22bf4eea6549d2f8a762341c6485a24665c
Reviewed-by: Johan Helsing <johan.helsing@theqtcompany.com>
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-03-22 14:10:59 +00:00
Arnaud Vrac
5324f6af4d inputdevice: map more X11 keys
This is a copy of the key mapping in the XCB plugin. The only difference
is the Launch* keys, which will be changed in Qt6 in the XCB plugin.
Here we don't need to wait for that since the mapping is new.

This also change the mapping of the following keys, which was incorrect:

XKB_KEY_XF86AudioRewind: Qt::Key_MediaPrevious -> Qt::Key_AudioRewind
XKB_KEY_XF86AudioForward: Qt::Key_MediaNext -> Qt::Key_AudioForward
XKB_KEY_XF86Phone: Qt::Key_ToggleCallHangup -> Qt::Key_Phone

Change-Id: I30308da8529dba5b139fc599314c9465573b848e
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-03-21 12:54:17 +00:00
Pier Luigi Fiorini
0537b40bfe Update wayland.xml to 1.6
Change-Id: I89b1dd4f6b6f03f54a9126dd5f67b0cdc9a006ad
Reviewed-by: Johan Helsing <johan.helsing@theqtcompany.com>
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-03-21 08:35:58 +00:00
Erik Larsson
e862c2d222 Simplify client-side API for Wayland extensions
This simplifies the client-side API for Wayland extensions by
introducing QWaylandClientExtension/QWaylandClientExtensionTemplate
classes. These classes takes care of the initialization of the extension
if it matches the interface name.

Change-Id: I7c4fb34563563af4be072cdebda54954b79cddbe
Reviewed-by: Johan Helsing <johan.helsing@theqtcompany.com>
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
2016-03-18 07:38:55 +00:00
Frederik Gladhorn
8d4b8c588d Merge remote-tracking branch 'origin/5.6.0' into 5.6
Change-Id: If2caca2463ef6815d2cc9a8f05ccd78c867c95d2
2016-03-17 16:09:05 +01:00
Martin Gräßlin
6474099684 Add support for bitmap cursors
So far QtWayland did not support custom bitmap/pixmap QCursors.
This change adds support for them by creating a QWaylandShmBuffer and
copying the pixmap data into that buffer. The internal API to set
cursors images is changed to not only rely on wl_cursor_image, but also
allow to just set the buffer with a specific size and a hot spot.

The created WaylandShmBuffer is passed around as a shared pointer, so
that it can be automatically cleaned up once the cursor image is no
longer used on any seat.

Task-number: QTBUG-51604
Change-Id: I1f1ee87f03186c3d564468d3e8ea2a3141d7e2fb
Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
Reviewed-by: Johan Helsing <johan.helsing@theqtcompany.com>
2016-03-17 06:40:40 +00:00
Johan Klokkhammer Helsing
2414bb75bb Fix client xdg_surface not handling all states from configure event
The code used sizeof(state) when it should have been sizeof(*state).

Change-Id: Id1714a5e90e6c58850023424726de26719a69046
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
2016-03-15 13:30:57 +00:00
Paul Olav Tvete
29d74ed32e Merge remote-tracking branch 'qt/5.6' into 5.7
Change-Id: Iada0e076ee33e8d39ecc4f40edfd9764ba610c03
2016-03-08 14:45:49 +01:00
Giulio Camuffo
330e3a7869 Fix SHM drawing logic
The old logic didn't care to listen for wl_buffer.release events
so it always drew in the same buffer, potentially resulting in
tearing if the compositor was scanning out the buffer at the same time.
Instead properly cycle between a few buffers and don't reuse the same
one until the release event was received.

The old code also used to throttle the redraws, unless the buffer was
changing, that is unless the window was getting resized. This is now
lost, and no throttling is ever done. Doing it properly, by waiting
for the frame callback before committing the new buffer shows very
noticeable lags with many applications when resizing, because they
paint many times per resize event, so they fall behind the cursor.
A proper fix will be to implement the support for requestUpdate(),
and using it in the applications.

Change-Id: I02732c34769a5c75a6ad68c095bae916e4b274d3
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2016-03-07 07:44:21 +00:00
Thiago Macieira
db14c19d17 Fix failure to build from sources: missing #include
qwaylandinputdeviceintegration_p.h:64:85: error: ‘uint32_t’ has not been declared

Change-Id: Ic747cc2ab45e4dc6bb70ffff143843d1ed4a341b
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
2016-03-03 09:46:51 +00:00
Oswald Buddenhagen
d9e3842afd don't over-expose private dependencies
Change-Id: If46406b4129b464e8ccfa0b4cf6ff2989402ca74
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
2016-02-25 16:48:02 +00:00
Oswald Buddenhagen
9d119e5c96 consistently put {qt,qml}_{module,plugin} at the end of project files
this fixes static builds by ensuring that all dependencies are exported.

Task-number: QTBUG-51071
Change-Id: Ie9e89fa47696244e8ee478ed1a019765c835533e
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
2016-02-25 16:47:59 +00:00
Elvis Lee
f52b53996c Fix crash for destroyed surface on touch event
Change-Id: Ia3dd8627c1b96a88d308dc7fa85d936f809c7856
Reviewed-by: Elvis Lee <kwangwoong.lee@lge.com>
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
2016-02-25 14:22:41 +00:00
Liang Qi
f9510e1aff Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
	.qmake.conf
	src/compositor/compositor_api/qwaylandquicksurface.cpp

Change-Id: Ic5e4217549c6c08740dba5ac1794d0a8e53f3a47
2016-02-19 16:05:24 +01:00
Yusuke Binsaki
e7e8dbbd7a Implement initial IVI-shell support with shell integration.
IVI-shell provides a shell interface for Weston, which maps the GENIVI
API (http://www.genivi.org) for In-Vehicle Infotainment as Wayland-Ivi-Extension
(http://wiki.projects.genivi.org/index.php/Wayland_IVI_Extension_Design).

This patch is included in two protocol. The first is ivi-application protocol
which provided by weston. Next is ivi-controller protocol which provided by
Genivi's wayland-ivi-extension.
In IVI use case, the client create and destroy surface with the unique ID
by using ivi-application protocol. On the other hand, the controller such as
HMI Controller control some properties, which are visibility, position, size,
etc, with created the unique ID by using ivi-controller protocol.
It means the unique ID is necessary to create and control the ivi-surface and
the the ivi-layer. However Qt has no API to set the some surface or layer ID.

In this ivi-shell plugin, the unique ID can be set via the environment
parameter so that we can control the ivi-surface and ivi-layer. The
name of environment parameter is QT_IVI_SURFACE_ID.
QT_IVI_SURFACE_ID will be used as ivi-surface and ivi-layer. If application
needs more than two surfaces, ivi-surface IDs will be incremented.
When QT_IVI_SURFACE_ID isn't set, ivi-surface and ivi-layer ID will be
generated internally.  The ID consists of the process ID and the surface
ID which is incremented in ivi-shell plugin.
The process ID is used as lower 22 bit per 32bit. 23 to 32 bit is used as
the surface IDs in a process.
e.g. When the process ID is 0x765 and create two surfaces,
ivi-layer ID is 0x765 and ivi-surface IDs are 0x765 and 0x00400765.
  +------------+---------------------------+
  |31        23|22                        0|
  +------------+---------------------------+
  |0000 0000 00|00 0000 0000 0000 0000 0000|
  |<- ID     ->|<- process ID            ->|
  +------------+---------------------------+

We can set QT_WAYLAND_SHELL_INTEGRATION of the environment
parameter to "ivi-shell" to use IVI-shell.

Change-Id: Iddcfb3de89dc022530c0285524cf6bbf640147b6
Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com>
2016-02-12 21:29:13 +00:00
Johan Klokkhammer Helsing
c70987cd65 Fix freeze when using BypassWindowManagerHint
Shell surfaces are now created for windows with BypassWindowManager
set, unless the environment variable
QT_WAYLAND_USE_BYPASSWINDOWMANAGERHINT is also set.

This means that in case you need a window to not create a wayland
shell_surface (perhaps because you do not want to use wl_shell or
xdg_shell), you can set the environment variable and get the same
behavior as before. Meaning the surfaces of windows with the flag set
will not be assigned a role.

Task-number: QTBUG-49272
Change-Id: Idf969540497d6b4e54395b97472d99d2e068be93
Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2016-02-12 10:41:00 +00:00
Giulio Camuffo
fbbdcc1224 Allow initializing the server protocol classes with a wl_resource
Change-Id: I3efd23284392e0ff587f86c7c163c0e4ffadb1f1
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2016-02-10 13:38:42 +00:00
Laszlo Agocs
8a706c0a7e Add missing we mean it header
Change-Id: I170089d87a56e56e12360a60bf76a142343b47f4
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2016-01-29 15:13:59 +00:00
Antti Kokko
a38a6a7d9d Updated license headers
From Qt 5.7 -> tools & applications are lisenced under GPL v3 with some
exceptions, see
http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/
Updated license headers to use new GPL-EXCEPT header instead of LGPL21 one
(in those files which will be under GPL 3 with exceptions)

Change-Id: Ifa334d2d3487e413e90ba9f2bf377026076b2df1
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
2016-01-20 10:53:53 +00:00
Antti Kokko
08a9a13b4a Updated license headers
From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see
http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/
Updated license headers to use new LGPL header instead of LGPL21 one
(in those files which will be under LGPL v3)

Change-Id: I76ae5d3e64f096eb3163d6163a38d68c7c1ca756
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
2016-01-20 10:53:37 +00:00
Pier Luigi Fiorini
ab9b67b140 Set appId according to QGuiApplication::desktopFileName()
Since qtbase 61ad604ad41607be97efea5a18cd4d9fb7ddca73, QGuiApplication
has got a new property: desktopFileName.

Applications can now specify the desktop file name.
In that case we have a reliable information: use it for the appId
removing the ".desktop" suffix.

Otherwise, just use the logic we previously established.

Change-Id: I03c89009620b33bc68ee97ed414cfee1c1794632
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
2016-01-11 20:05:33 +00:00
Paul Olav Tvete
4c0a1bc3b0 Don't create wl_surface for desktop widgets
Change-Id: I3ebcb49a4acf230b9515c0317aab2307dcb9270b
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2016-01-11 15:45:38 +00:00
Paul Olav Tvete
53326bfa3f Fix the control key
Let Ctrl+A cause a key event with text Ctrl+A (0x01), like we do on
the other platforms. Previously we would use 'A', which would confuse
some applications.

Task-number: QTBUG-50398
Change-Id: Ie3def4bd9c96e538b2572b88fae029d347e08814
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2016-01-11 15:44:23 +00:00
Paul Olav Tvete
a1c0b7e148 Merge branch 'wip-compositor-api' into dev
This introduces the new compositor API, removing the
old API (which was never officially supported).

Change-Id: I1dc01f0fb4edc749e34ed8356e56ad87d7d64913
2015-12-02 14:01:08 +01:00
Paul Olav Tvete
8c56476164 Merge remote-tracking branch 'qt/5.6' into wip-compositor-api
Change-Id: Ie70fdd03e1259a8cb75bbdbf1324e3e4a2b51807
2015-12-02 10:35:50 +01:00
Liang Qi
ab83e33a61 Merge remote-tracking branch 'origin/5.6' into dev
Conflicts:
	src/client/qwaylanddisplay_p.h

Change-Id: I602b90a055d1322af369fb7b77a68583154b660f
2015-12-01 23:08:05 +01:00
Mikko Levonmaa
e259816fd0 Support non-blocking flush for shm subsurfaces
Change-Id: I6cc8d5214c905d6b2e9f0c2eebb07d1cb897f74a
Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: Mikko Levonmaa <mikko.levonmaa@bitfactor.fi>
2015-11-28 09:51:09 +00:00
Mikko Levonmaa
6c3297a6f1 Make swap buffer call non-blocking for subsurfaces
Allows clients that use subsurfaces in synchronized mode to continue
processing the event loop even in cases where a frame callback is not
delivered from the compositor pending a parent surface commit

Change-Id: I7df38afc4080546b60184dacecde321ba8062fac
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-11-12 06:41:18 +00:00
Laszlo Agocs
5a4487e16b Get rid of the egl config test and use what qtbase provides
contains(QT_CONFIG, egl) and CONFIG += egl is the only sane way to test
for and pull in EGL headers and libs. This is particularly important when
trying to be robust and guard against half-broken sysroots on embedded
where a naive PKGCONFIG += egl breaks.

Also add an EGL_WAYLAND_BUFFER_WL define to keep wayland-egl compiling.
We are not testing for that in any config tests may cause a failure in sysroots
that have parts of Mesa thrown in but pick ip an older EGL header from the
vendor's driver.

Change-Id: I7b7e6a7a91e78dbda5b6954ad08761298c538efc
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-11-11 13:22:40 +00:00
Mikko Levonmaa
cf514c46a9 Add QWaylandWindowFunctions
Allow the control of the subsurface sync mode

Change-Id: I19f35261313282873f57228487a63a8f6a780b0c
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-11-06 15:08:47 +00:00
Friedemann Kleint
8c457f7183 Fix compiler warnings.
qwaylandinputcontext.cpp:57:16: warning: unused parameter 'sym' [-Wunused-parameter]
qwaylanddatadevice.cpp:173:135: warning: 'dragData' may be used uninitialized in this function [-Wmaybe-uninitialized]

Change-Id: Id654360fd9b7fdb572565ad39b664af3355b5e79
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-11-05 12:54:58 +00:00
Giulio Camuffo
d49cd790d8 client: Remove the event thread
If the compositor sends events to us while the main thread is blocked
the socket notifier in the events thread would keep sending out the
activated() signal, but no events would actually be read until the
main thread starts to run again. That causes the event thread to keep
queueing new events, and so allocating memory, potentially forever.
This patch fixes the issue in maybe a bit radical way, that is by removing
the event thread. The socket notifier now runs in the main thread so it
will block if the events are not being read.
Nowadays there is no real reason to keep the event thread around, as every
thread that needs to receive wayland events can dispatch them on its own,
we don't need a central dispatcher thread anymore.

Change-Id: Ib7885e4b038b82719d78d193f465618a72cbe6af
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2015-11-03 13:13:34 +00:00
Kevin Funk
0520481077 CMake: Create CMake files for WaylandClient
Also add unit tests

Change-Id: I66de887607f73b318884e4a35f18510b90cf0315
Task-number: QTBUG-47357
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-11-02 16:27:34 +00:00
Martin Gräßlin
eace7fb3ad Add wl_shell_surface as nativeResourceForWindow
Allows to get the wl_shell_surface for a QWindow, if it exists.

Change-Id: I16b1c578a1c605e58c96e94ae55a3331ecfa353d
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-10-30 08:59:19 +00:00
Giulio Camuffo
face687a62 Fix deadlock when starting a drag
With commit c55a36cb9015cf1eebd49eaa5b1b4f4ec9b28451 in qtbase the
QSimpleDrag code changed in a way that caused a deadlock due to
drawing a window without a role. However, thanks to that we can
now remove that start/cancel hack and simplify the code.

Change-Id: Icba6e7c9c4927855e48fb21632db1a10332c4ffb
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-10-29 15:05:46 +00:00
Laszlo Agocs
2920b04d88 Merge branch '5.6' into wip-compositor-api
qwindow-compositor changes from 5.6 will be adapted separately.

The traditional wayland-egl path is tested and is functional like before.
The EGLStream support will be verified separately once the qwindow-compositor
changes are ready.

Conflicts:
	examples/wayland/qwindow-compositor/qwindowcompositor.cpp
	examples/wayland/qwindow-compositor/textureblitter.cpp
	examples/wayland/qwindow-compositor/textureblitter.h
	examples/wayland/server-buffer/client/client.pro
	examples/wayland/server-buffer/compositor/compositor.pro
	src/compositor/compositor_api/qwaylandbufferref.cpp
	src/compositor/compositor_api/qwaylandbufferref.h
	src/compositor/hardware_integration/qwlclientbufferintegration_p.h
	src/compositor/wayland_wrapper/qwlkeyboard.cpp
	src/compositor/wayland_wrapper/qwlkeyboard_p.h
	src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp
	src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h
	src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp
	src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.h
	src/plugins/hardwareintegration/compositor/wayland-egl/wayland-egl.pro

Change-Id: Ic2e3a6e8f74606c35b1e27cd4016fa133527d7ba
2015-10-27 18:31:47 +01:00
Liang Qi
b8fc07100b Merge remote-tracking branch 'origin/5.6' into dev
Change-Id: Idc8300948e3d52bfe2c14c62230280a68b2ed100
2015-10-27 10:09:13 +01:00
Laszlo Agocs
fc78f8239e Fix for QStringBuilder
Change-Id: I2a7b82bd2705919a91492edfccac02f4d8fc2c9b
Reviewed-by: Louai Al-Khanji <louai.al-khanji@theqtcompany.com>
2015-10-19 18:30:44 +00:00
Liang Qi
7dbe121971 Merge remote-tracking branch 'origin/5.6' into dev
Conflicts:
	src/client/qwaylandintegration.cpp

Change-Id: I29120f06d33c2d383a41cf35ca4a59f5d8548ad7
2015-10-15 09:07:48 +02:00
Paul Olav Tvete
5effda3eb0 Merge branch 'qt/5.6' into wip-compositor-api
Conflicts:
	examples/wayland/pure-qml/main.cpp
	examples/wayland/pure-qml/qml/Chrome.qml
	examples/wayland/pure-qml/qml/main.qml
	src/client/qwaylanddnd_p.h
	src/compositor/compositor_api/qwaylandquicksurface.cpp
	src/compositor/compositor_api/qwaylandsurface_p.h
	src/compositor/compositor_api/qwaylandsurfaceitem.cpp
	src/compositor/extensions/qwlinputmethodcontext_p.h
	src/compositor/hardware_integration/qwlclientbufferintegration_p.h
	src/compositor/hardware_integration/qwlclientbufferintegrationfactory_p.h
	src/compositor/hardware_integration/qwlclientbufferintegrationplugin_p.h
	src/compositor/hardware_integration/qwlhwintegration_p.h
	src/compositor/hardware_integration/qwlserverbufferintegrationfactory_p.h
	src/compositor/hardware_integration/qwlserverbufferintegrationplugin_p.h
	src/compositor/wayland_wrapper/qwlcompositor_p.h
	src/compositor/wayland_wrapper/qwldatadevice_p.h
	src/compositor/wayland_wrapper/qwldatadevicemanager_p.h
	src/compositor/wayland_wrapper/qwldatasource_p.h
	src/compositor/wayland_wrapper/qwlextendedsurface_p.h
	src/compositor/wayland_wrapper/qwlinputdevice_p.h
	src/compositor/wayland_wrapper/qwlinputmethod_p.h
	src/compositor/wayland_wrapper/qwlinputpanel_p.h
	src/compositor/wayland_wrapper/qwlinputpanelsurface_p.h
	src/compositor/wayland_wrapper/qwlkeyboard.cpp
	src/compositor/wayland_wrapper/qwlkeyboard_p.h
	src/compositor/wayland_wrapper/qwloutput_p.h
	src/compositor/wayland_wrapper/qwlpointer_p.h
	src/compositor/wayland_wrapper/qwlregion_p.h
	src/compositor/wayland_wrapper/qwlshellsurface_p.h
	src/compositor/wayland_wrapper/qwlsubsurface_p.h
	src/compositor/wayland_wrapper/qwlsurface.cpp
	src/compositor/wayland_wrapper/qwlsurface_p.h
	src/compositor/wayland_wrapper/qwltextinput_p.h
	src/compositor/wayland_wrapper/qwltextinputmanager_p.h
	src/compositor/wayland_wrapper/qwltouch_p.h
	src/compositor/windowmanagerprotocol/waylandwindowmanagerintegration_p.h
	src/imports/compositor/WaylandCursorItem.qml

Change-Id: I4e63ef295b297022d4970b3c68b3d565843086bd
2015-10-13 16:22:39 +02:00
Friedemann Kleint
2eac89028b Add missing "We mean it" comments to private headers.
Change-Id: I70c01453b3939d1d645d626ae84c21ab4c9d267a
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-10-05 09:35:34 +00:00
Liang Qi
9c55a359a9 Merge "Merge remote-tracking branch 'origin/5.5' into 5.6" into refs/staging/5.6 2015-10-02 15:33:19 +00:00
Andres Gomez
dcc7143a18 xkb: Provide support for the XF86Phone symbol
Change-Id: I19fd0bc7a56b4baa5b6d40836d5f0401a3b11c49
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-10-02 12:18:23 +00:00
Liang Qi
2638cae03d Merge remote-tracking branch 'origin/5.5' into 5.6
Change-Id: Ib3c5bec85a09d92e37a3af8e1c749a80cb40c056
2015-10-02 13:50:24 +02:00
Giulio Camuffo
3130cc4d86 Implement the wl_subcompositor interface server-side
This change removes the qt_sub_surface extension and replaces it with
the standard wl_subsurface.
Only the bare minimum functionality is implemented, the wl_subsurface
requests are left as dummy handlers currently.

Change-Id: I025304072cf157f732e90c4b5649a07b295fdea5
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
Reviewed-by: Mikko Levonmaa <mikko.levonmaa@bitfactor.fi>
2015-10-01 09:44:34 +00:00
Mikko Levonmaa
b69db39d48 Add QWayland::shm object to client
Allows more flexibility for the client to determine
additional shm formats supported by the compositor in
addition to the standard types. For example YUV formats.

Change-Id: Ib4a47c1d5bbeed9314d5ad5f5f8e1551c1dd71e4
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
Reviewed-by: Mikko Levonmaa <mikko.levonmaa@bitfactor.fi>
2015-09-25 18:37:33 +00:00
Giulio Camuffo
a7ed723edb Fix a segfault when the wayland connection is broken
When calling ::exit() the socket notifier in the events thread may still
fire before the process actually exits, using objects that are being
destroyed and resulting in a segfault.
Stop the events thread before calling ::exit().

Change-Id: I187762da2a7efa83db1e62b0e28dfab89f478c7d
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2015-09-25 11:33:02 +00:00
Philippe Coval
b975ab4b85 xdg-shell: upgrade to support current version (weston-1.8.0)
Handle transition from Normal to Maximize then Fullscreen and back to Maximized.
Avoid to maximize if no requested size

The protocol file is a raw copy of
Source: http://cgit.freedesktop.org/wayland/weston/plain/protocol/xdg-shell.xml?id=1.8.0

Minor Nitpick fixes (arrays of bytes, conditionnal or test, c++ function call)

Task-number: QTBUG-47327
Change-Id: Ib508e2166cc1337fd93454f30814136839cffa29
(cherry picked from commit 6906a6445c0cbf9d11f8d5d32b181f558a2292c9)
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-09-23 09:17:57 +00:00
Friedemann Kleint
38e4f03cf8 QWaylandXdgSurface/QWaylandWlShellSurface: Fix warnings about CT initialization order.
qwaylandxdgsurface.cpp: In constructor 'QtWaylandClient::QWaylandXdgSurface::QWaylandXdgSurface(xdg_surface*, QtWaylandClient::QWaylandWindow*)':
qwaylandxdgsurface.cpp:55:31: warning: base 'QtWayland::xdg_surface' will be initialized after [-Wreorder]
qwaylandxdgsurface.cpp:55:31: warning:   base 'QtWaylandClient::QWaylandShellSurface' [-Wreorder]
qwaylandxdgsurface.cpp:48:1: warning:   when initialized here [-Wreorder]
qwaylandwlshellsurface.cpp: In constructor 'QtWaylandClient::QWaylandWlShellSurface::QWaylandWlShellSurface(wl_shell_surface*, QtWaylandClient::QWaylandWindow*)':
qwaylandwlshellsurface.cpp:55:31: warning: base 'QtWayland::wl_shell_surface' will be initialized after [-Wreorder]
qwaylandwlshellsurface.cpp:55:31: warning:   base 'QtWaylandClient::QWaylandShellSurface' [-Wreorder]
qwaylandwlshellsurface.cpp:49:1: warning:   when initialized here [-Wreorder]

Change-Id: If7ed49fa6f788db7407b5ee82aa252e19e2d4747
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-09-15 11:34:19 +00:00
Jørgen Lind
65847be1be Fix sending exposeevents on all swapbuffers
In Change-Id: I2d4a5f6dd357d84df43acc0082f9621fb6609768 I extracted a
call to handleExposeEvent from a if statement. I failed to see that the
else condition also had an if statement.

Change-Id: Ie51c5f918a4e4ddaec9e75c9c3afffa962d2bd06
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
2015-09-10 08:21:25 +00:00
Jørgen Lind
9fa8f84f0b Fix % warning when using generated files
Change-Id: Ib7857743140d9f2dfa5bf1ff2187af8f3e2478da
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
2015-09-10 08:21:14 +00:00
Jørgen Lind
69d1793472 Rename QtCompositor to QtWaylandCompositor
enable building QtWaylandCompositor by default

Change-Id: I7cf34052b304ca9fef55b7e30ef6a6367b5d75f1
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
2015-09-10 08:20:53 +00:00
Jørgen Lind
7c93b46a03 Add an assert in QtWaylandScanner for duplicate binds
Since Q_SIGNALS are a one -> many distribution we can end up signalling
creation requests to many slots. Its then important that we verify that
only one of these actually binds an object for the object id. Its a
programming error to have this situation, hence its an assert, and not a
runtime check that gives a warning. The bind will overwrite the object
and the last bind will continue to work as normal in release mode.

Change-Id: I1f469066cf5287789249763843e6cbaa545ee619
2015-09-04 16:12:47 +02:00
Jørgen Lind
6f3dc689d7 Set default size if a QWindow has no geometry
also extract two lines out of conditional branches

Change-Id: I2d4a5f6dd357d84df43acc0082f9621fb6609768
2015-09-04 16:12:47 +02:00
Philippe Coval
23dbf71265 xdg-shell: upgrade to support current version (weston-1.8.0)
Handle transition from Normal to Maximize then Fullscreen and back to Maximized.
Avoid to maximize if no requested size

The protocol file is a raw copy of
Source: http://cgit.freedesktop.org/wayland/weston/plain/protocol/xdg-shell.xml?id=1.8.0

Minor Nitpick fixes (arrays of bytes, conditionnal or test, c++ function call)

Task-number: QTBUG-47327
Change-Id: Ib508e2166cc1337fd93454f30814136839cffa29
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-09-03 22:52:05 +00:00
Jørgen Lind
db75602d80 Compilefix from Pauls high DPI changes
Change-Id: I871cf93c690be2709d4fb6a1377f102c8d32e243
2015-08-28 13:10:33 +02:00
Jørgen Lind
3aa93bb379 Remove the qt_sub_surface extension
Change-Id: I380590722f2c95ff68972f5b3c94a7cc4cfe016f
2015-08-28 13:10:33 +02:00
Jørgen Lind
bc14c870c8 Check if we have a shellSurface in the decoration
Change-Id: I984163753791a640a99e182b55746f486c0a01cb
2015-08-28 13:10:32 +02:00
Jørgen Lind
02f0ea8fc2 Improve QWaylandExtension
By using curiously recurring template pattern we can generate a getter
which is very convenient, and all QWaylandExtensions should have this
casting operation

Change-Id: Idb5a786655f2e106cf5388b11ed71e8b6ddddec0
2015-08-28 13:09:42 +02:00
Jørgen Lind
3636606b72 Rework how we manage extensions
Change-Id: If2cbf096e7419bc1bda007d5167ce39d1a5d50ae
2015-08-28 13:09:42 +02:00
Liang Qi
99a3bfcf9b Merge remote-tracking branch 'origin/5.5' into 5.6
Conflicts:
	src/client/qwaylandwindow.cpp

Change-Id: I80ead87f3e1f36299b1bf9cc9c7db6cd48c0e86f
2015-08-28 12:24:42 +02:00
Giulio Camuffo
eb1fe81b7d Fix QDesktopServices::openUrl when there is no windowmanager integration
Change-Id: I51da06261acfb193a59db34bc2dd25e3452fce8d
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-08-26 07:42:02 +00:00
Bernd Weimer
e1a2dacb75 Enable input context selection
It was not possible to use a different input context than the platform
context. This has been unified across major platforms, depending on the
environment variable "QT_IM_MODULE", the following context is selected:
- null:  default platform context (Wayland in this case)
- empty: no context
- set:   set one, if it exists and is valid (otherwise no context)

Change-Id: I07c6fb339c434f99fc6e092a2e18f00600daa3bc
Reviewed-by: Nedim Hadzic <nedim.hadzic@pelagicore.com>
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-08-25 10:05:34 +00:00
Marco Martin
f984cff1d8 Fallback to normal input method plugins
wl_text_input is still a weston-specific extension. other compositors
just expect the normal input context plugins to be instantiated when the
wayland client connects.
now try to use the one based upon wl_text_input, if fails fallback to
the QPlatformInputContextFactory::create() route

Change-Id: I034acf9ed19c766250f81fc5648d0318ae45f1bf
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-08-20 09:36:00 +00:00
Morten Johan Sørvig
df9b95be2a Compile after QPA API changes.
QMouseEvent -> QPoint in QSimpleDrag::move and drop

Task-number: QTBUG-46615
Change-Id: I9cda0f039ee8f5a70219b320abbb65f8649747e1
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-08-06 12:24:02 +00:00
Jørgen Lind
5328e070e3 Fix some wrong licenses in QtWaylandClient
Change-Id: I8d5e88e9b296276c6d9d570b3e5e704f32298d83
2015-07-24 15:22:41 +02:00
Giulio Camuffo
bd4a0928ab Use xkbcommon for internal key events too
To manage the keyboard state and send key events to clients we use
the xkbcommon library (unless disabled). That means that we currently
have a separation between key events outgoing to clients and key events
being used internally in the compositor, resulting in different keysyms
being produced in the two cases for the same hardware key.
Filter the key events coming from the underlying platform and modify
them according to the xkb state instead.

Change-Id: I4c6678be68e5b214b2b9cd0222dc9f425c580085
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2015-07-23 07:29:02 +00:00
Giulio Camuffo
61b80576b0 Use standard wl_subsurface interface to set a window as a child of another one
Change-Id: I52628f87dbea5383db06468f9748a9bacdec3179
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2015-07-22 07:42:07 +00:00
Giulio Camuffo
0b71d61d37 Fix possible race condition leading to a dead lock
It is a bit dangerous to call wl_display_dispatch() in the event thread,
since it may race with the dispatch called e.g. in QWaylandDisplay's
blockingReadEvents() and lead to a dead lock. Instead, use wl_display_prepare_read()
and wl_display_read_events() in the event thread, which doesn't block, and only
dispatch in QWaylandDisplay.
As a result we don't need the additional wayland queue anymore, so remove it.

Change-Id: I9fbbe5d2f38d06773beb7847df1a0212cca92c37
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2015-07-06 08:00:02 +00:00
Sergio Martins
4d312f1ec7 Use by-ref in foreach where T is non-trivial
Change-Id: Iac40929aebc1e0f507b729b0c01a2ccb18516c37
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-07-04 10:11:22 +00:00
Giulio Camuffo
837c740cd6 Fix tooltips without a transient parent
QToolTip has the same problems as QMenu, that is you can create one
without a parent and with a global position. Use the same trick and
use the window that last received an input event as the parent.

Change-Id: I093c8da0d54110903f35670b01dea6fa96abecf4
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2015-07-04 07:31:17 +00:00
Liang Qi
4192bc7a06 Merge remote-tracking branch 'origin/5.5' into dev
Conflicts:
	.qmake.conf

Change-Id: Ic75157b11eee188608c3ac7ed6fb1a033bb72750
2015-06-29 20:14:23 +02:00
Olivier Blin
bc63ed702f Fix input devices leak in client
Change-Id: I28200698706168308e450b2cd3cfa99df517f9b7
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-06-12 09:51:56 +00:00
Christian Kandeler
36d1c47e66 Fix typo that leads to mis-evaluation of an expression.
Change-Id: I5d6eedeb3dfb80ca9df7ca27e29ad6604dbfe683
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-06-09 12:55:29 +00:00
Giulio Camuffo
7d54e5527e Fix wheel events when the decorations are enabled
We must offset the wheel events' position, as we do with the other
types of mouse events.

Change-Id: If85e93ffe95304c7dee4c2a3ff195a73243a8182
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-06-09 08:23:33 +00:00
Giulio Camuffo
58f3c602f0 bradient: Activate the decoration's buttons on mouse release, not press
Change-Id: I5a161119b20301a405bdde9bbea6bfbdcc4b9fa0
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-06-09 08:23:11 +00:00
Giulio Camuffo
9369a931d0 Fix a corner case freed memory use/crash
QWaylandDisplay::flushRequests() does not only flush them, but also
dispatches the pending events. If we have two wl_data_device.selection
events in the queue we must not dispatch the second one while we are
dealing with the first one because that will replace the data offer
and delete us while we're in QWaylandMimeData::retrieveData_sys().

Change-Id: Ib58ca571867faa2633daa9ec94fe7094df02e9fd
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-06-09 08:22:56 +00:00
Giulio Camuffo
202573e946 Don't generate spurious selection events
By calling destroy() on the active wl_data_source before replacing
it with a new one and calling set_selection() we trigger a spurious
selection(null) event before the one with the offer for the source
we are going to set.

Change-Id: I6c2f2fd029fa523312b9892c6a5050805dfa83b0
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-06-09 08:22:22 +00:00
Sergio Martins
f1d265fcdf Add 3 QList::reserve() calls
Change-Id: Ic89d25a4497ffaffb3f6b688f4c5ecc5128e9642
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-06-08 10:10:37 +00:00
Liang Qi
b18f9ef9b3 Merge remote-tracking branch 'origin/5.5' into dev
Conflicts:
	src/compositor/wayland_wrapper/qwloutput.cpp

Change-Id: I05f7431aca46760f90632dfa7ef9c4d0abf392ec
2015-06-03 11:02:30 +02:00
Jørgen Lind
f57dbc0358 Fix that we pick up the generated headers in source packages
Change-Id: If5ae8749ccbddfc878ae4e0adaa40f072527d425
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
2015-05-29 13:16:15 +00:00
Giulio Camuffo
f0a58486ef Fix crash when the wl_shm global comes after a wl_output one
Task-number: QTBUG-44503
Change-Id: I6932df57bb4560b6dceb72a5cb7c536cd090e92a
Reviewed-by: Martin Gräßlin <mgraesslin@kde.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-05-28 07:48:22 +00:00
Martin Gräßlin
022f452ed9 Add safety check in QWaylandInputDevice::Keyboard::modifiers()
::modifiers() might be invoked before being initialised. E.g. when
a pointer button event is emitted before the keymap is sent.

Change-Id: Ib95f9866d808b2a32ddfaa0862cdb3226fab1938
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-05-15 08:01:01 +00:00
Arnaud Vrac
3822bac2b7 Reset wayland object pointer after destroy
This allows calling init() on the wayland object again after destroy()

Change-Id: I7856cc8ec676eee7575e15a5d1f81cf1b89537c8
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-05-07 08:44:44 +00:00
Arnaud Vrac
679e14272c Track last input window with a QPointer in case it is destroyed
Change-Id: I61d7aa4b6a37922eb3beefd983154ee267cae0ef
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-05-07 08:44:11 +00:00
Arnaud Vrac
9b5376cce1 Map more XKB key codes
Change-Id: I0a2b56043235666bc57b46ae4ac78ca5e24e736d
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-05-07 08:43:28 +00:00
Pier Luigi Fiorini
4a0f32aa4b Remove output extension
This protocol is empty now and is no longer used.

Change-Id: I45e79fb86a67b4cebdc307170218fa039b2aa27f
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-05-06 09:34:37 +00:00
Giulio Camuffo
d0740edb9c Fix crash on keyboard remove
If the compositor sent a wl_keyboard.leave and a new wl_seat.capabilities
without the keyboard bit we would end up deleting the Keyboard object
with a roundtrip in flight, ending up using freed memory later.
Destroy the callback when destroying the keyboard, and notify the
window system the active window is active no more.

Change-Id: Ie415ca62b46e0b8ef0fe4d09c8e7a8130928df90
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-05-04 09:22:39 +00:00
Giulio Camuffo
b8be7b93a1 Use a FontSmoothingGamma value of 1.0
This is what the xcb plugin does, be consistent with it.

Change-Id: I5befa2de3ff514ca0c9196eb7137682586cec126
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-04-24 10:03:11 +00:00
Giulio Camuffo
7efc7c3d4d Use defines instead of hardcoded strings
Change-Id: Id382a1e39f2c052fbfeb96caa9b01becb31e81c9
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-04-24 10:02:15 +00:00
Giulio Camuffo
1cee02688f Do not manually update the xkb state
xkb_state_update_key() is not supposed to be used in apps with a master
process, such as wayland clients, which use xkb_state_update_mask()
with the state serialized by the master.

Change-Id: Ie51a39ca0c567c54072b221d1ab8cf7b8ea15c55
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-04-24 09:58:32 +00:00
Giulio Camuffo
81395b87a3 Add client side support for media keys
Unfortunately we don't have a keysym in libxkbcommon for PlayPause,
we only have Play. We're going to pretend XKB_KEY_XF86AudioPlay is
really PlayPause since that is what is most common.

Change-Id: I1a75d8b5b0ea360e0f62eb7a93004ba3fababfa8
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2015-04-16 15:41:00 +00:00
Liang Qi
cd7c9b50f6 Merge remote-tracking branch 'origin/5.4' into 5.5
Conflicts:
	src/client/qwaylandshmbackingstore.cpp
	src/client/qwaylandwindow.cpp

Change-Id: I795fd08f0fc5d3cb5ed55bf16e724f66b7567723
2015-04-15 09:33:45 +02:00
Pier Luigi Fiorini
be73094e6e Remove .desktop suffix to appId
The appId is the desktop entry identifier.

According to the desktop entry specifications [1], for applications the
part of the name should follow the reverse DNS convention (see [2]).

To do this we use the application domain if available, otherwise for
lack of information we fall back to the executable base name like other
toolkits such as Gtk+ do.

[1] http://standards.freedesktop.org/desktop-entry-spec/latest/
[2] http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s02.html

Change-Id: I181ad23a9736844e07e8060d78e756a943c27f67
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-04-10 08:29:12 +00:00
Giulio Camuffo
f9ad726e65 Don't handle mouse events in decos if buttons were pressed in the content area
This fixes the decorations stealing the mouse events when going outside the
content area.

Change-Id: I8f3592fbda6b9c1da6498d74820a73be11c6999d
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
2015-04-08 11:41:46 +00:00
Olivier Blin
5c897fb1ab Drop unused mScreensInitialized variable in QWaylandDisplay
Unused since commit 78a701272e68d4f0ab95df4062374b8d34ef2919:
    Made wayland plugin single-threaded, yay :)

Change-Id: I1fae78d77179feaac79f5dba6dcad8084e3e97fa
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-03-29 11:19:50 +00:00
Olivier Blin
43c14e514d Fix shm buffers init and destruction on failure
Some pointers need to be initialized in QWaylandBuffer and
QWaylandShmBuffer, and checked at destruction.

This avoids crashes when shm surface creation fails.

Change-Id: I6f6afa3cc6c67533b5130700cbc27b271764109e
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-03-27 16:52:06 +00:00
Olivier Blin
babb58933f Remove useless EGL linking in plugins
EGL libs are already linked from the hardwareintegration pri file, and
the plugins do not make direct use of any EGL symbol.

Change-Id: If6ecfee16e8c9d8fee67f03419941ced92d1eff8
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-03-27 15:17:44 +00:00
Olivier Blin
936eaaf0ab Make QWaylandShellSurface a QObject to allow build without RTTI
dynamic_cast can not be used when RTTI is disabled, so make
QWaylandShellSurface a QObject.

QWaylandWlShellSurface and QWaylandXdgSurface must also inherit from
QWaylandShellSurface first, to properly inherit from QObject.

Change-Id: I2addb8105a0fe61615d4bc905414f7ee7277029f
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-03-27 15:17:27 +00:00
Thiago Macieira
62b155bedf Disable -Wcast-qual in qtwayland
We have a lot of generated C source code that needs to do casting and C
doesn't have const_cast, so the -Wcast-qual option produces a lot of
noise. Let's make sure it isn't enabled in qmake.conf or qt_common.prf.

Change-Id: Iee8cbc07c4434ce9b560ffff13c9635861a8eca9
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-03-10 23:30:00 +00:00
Frederik Gladhorn
30b55342fc Merge remote-tracking branch 'origin/5.4' into 5.5
Change-Id: I03fd08fc0576ffac813f64905c23de4d65e67433
2015-02-20 15:38:53 +01:00
Jani Heikkinen
b366677a7a Update copyright headers
Qt copyrights are now in The Qt Company, so we could update the source
code headers accordingly. In the same go we should also fix the links to
point to qt.io.

Change-Id: I5a74d32515c3f1fe7aa1916f4241c92832510f8c
Reviewed-by: Antti Kokko <antti.kokko@theqtcompany.com>
2015-02-17 13:28:27 +00:00
Giulio Camuffo
62f0062e20 Fix build
Change-Id: I790e9bfbcffc7458e2a46f2da32dcbde0c6bffe8
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2015-02-17 10:52:09 +00:00
Martin Gräßlin
4ad52325f7 Run eventDispatcher in QWaylandDisplay::forceRoundTrip
If the application uses QCoreApplication::setEventDispatcher before
the QGuiApplication is created the blocking roundtrip might block the
application indefinitely. This can happen if the application starts a
Wayland server in the same process before the QGuiApplication is
created. And the QtWayland plugin connects to this server. In this case
a roundtrip blocks as the Wayland server cannot process the events
the QWaylandDisplay is waiting for.

By running the event dispatcher manually and using the pending
variant for dispatching the Wayland event queue, the application can
be kept alive.

Change-Id: I9c36fccbae8921e1ae9a0a8b7f460520b1b65d5c
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-02-17 09:55:10 +00:00
Giulio Camuffo
7e82e306bc Add a integration hook to get the wayland queue used by the QPA plugin
This comes handy for clients directly using raw wayland objects.

Change-Id: Ie526ac7b25a6c6a34ce61699103e612616bffbb8
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-02-16 19:05:56 +00:00
Frederik Gladhorn
d1de454093 Merge remote-tracking branch 'origin/5.4' into dev
Conflicts:
	src/client/qwaylanddataoffer.cpp
	src/client/qwaylanddisplay.cpp
	src/client/qwaylandinputdevice.cpp
	src/client/qwaylandwindow.cpp
	src/compositor/compositor_api/qwaylandsurfaceitem.cpp

Change-Id: I2eae0fd43a71fbfd7c907ca715707a26f3c134c5
2015-02-16 11:05:38 +01:00
Laszlo Agocs
520cb3e95e Sanitize popup behavior.
Popups are pretty important for widget apps. Menus, combobox dropdows
and such are all popups. Currently they are completely borked when
activated via keyboard or touch. This is because of the bizarre set_popup
request in the protocol, and Weston's current implementation, that ignore
the fact that a popup can be opened as a result of a keyboard event too
or may not originate from an input event at all.

Pass the last input device and serial we have seen, regardless of the type,
by tracking it globally in the QWaylandDisplay.

With this patch menus and such will not freeze the application anymore
when activated with keyboard or touch without sending a mouse event
to the window first. The behavior is still broken in some ways, especially
with keyboard due to immediately getting a popup_done, but at least
applications remain usable.

Task-number: QTBUG-41142
Task-number: QTBUG-41147
Change-Id: I18de501004ae8a62ff8667e72225d08c2d3ba491
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
2015-02-13 11:18:50 +00:00
Giulio Camuffo
817633a831 Fix popup menus with no parent windows
The QMenu API doesn't play well with Wayland. You can do:

QMenu menu;
menu.popup(someGlobalPos);

which is completely broken on wayland. If some popup window doesn't
have a transient parent use the current focus window for that.
Fixes right-click popups in qdbusviewer and other apps.

Change-Id: I3227f4ec27431ca8ec156971cbfdbf1e848a0527
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-02-11 13:47:12 +00:00
Giulio Camuffo
b52533db83 Fix copying text to non-qt clients
Like we do for pasting, set the mime type of text to "text/plain;charset=utf-8"
too besides "text/plain". This allows copying text to clients such as weston
example clients or Xwayland.

Change-Id: I8a24f32d93e438f16db662e7c09b09ddd7578768
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-02-07 17:48:07 +00:00
Giulio Camuffo
ccc23106b9 Do not send invisible key characters
xkb_keysym_to_utf32() will return 0 if the keysym does not have a
unicode representation.

Task-number: QTBUG-44012
Change-Id: I85a13b58c7f0b9765c7d67db6568a90629bcfbfa
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
2015-02-05 07:42:11 +00:00
Giulio Camuffo
ef259af2db Fix deadlock when starting a drag
Change-Id: Ie2fdc56bffb97ce04ffad11ea7a7686dc09a06cc
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
2015-02-05 07:42:06 +00:00
Jorgen Lind
1b6d20e463 Add a SHM format converter class
This class helps keeing one lookuptable for server and client
It relies on that wayland-(client|server)-protocol.h being included
before the qwaylandshmformathelper.h

Change-Id: I12158126a80c8fef5c52427d35792f33716020f1
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2015-02-05 07:12:15 +00:00
Giulio Camuffo
ce491e5dd0 Update the protocol to 1.4 and raise the required libwayland version
Wayland 1.4 introduces wl_subsurface which is quite an important
addition.

Change-Id: I48375f60adce556c9989872319f4d073e4a7b13b
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2015-02-03 13:32:33 +00:00
Giulio Camuffo
d62f2bc4e7 Make all the screens virtual siblings
Wayland outputs fit the definition of virtual sibling screens so make
the platform screen subclass so.

Change-Id: Id3f2592653f6309406185589f70127f2b74065ac
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-02-02 08:10:48 +00:00
Giulio Camuffo
f58cc97806 Send mouse events with the correct modifiers
Change-Id: I33da2681bc2315b3dc7de16fa80c45e26a478caa
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2015-01-29 19:18:46 +00:00
Giulio Camuffo
5d36ed33c7 Fix pasting from sources advertising the utf8 charset
Some clients use "text/plain;charset=utf8" as the mimetype for the
clipboard instead of just "text/plain".
Since we support Utf8 accept it as a valid type.

Change-Id: Icd540f0ff507ed9917b374f3b40fbdc259ce9ee2
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2015-01-29 17:49:15 +00:00
Giulio Camuffo
0dc189a432 Namespace the platform plugins
There currently is a QWaylandInputDevice class both in the wayland QPA
plugin and in the QtCompositor API. This causes the qwindow-compositor
example to crash when running nested in a wayland session due to a
mismatch between the two classes.
By namespacing all the plugin code we make sure that name clashes
will not happen anymore.

Change-Id: I17497cff697599200bea68bf01dfde474526390f
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
2015-01-29 12:53:04 +00:00
Giulio Camuffo
322bc6a377 Make sure we send a valid initial resize
Change-Id: Ib9a0152f83af433354d32ef4a8a233e5551ded8c
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-01-27 09:45:10 +00:00
Frederik Gladhorn
726e478bbe Merge remote-tracking branch 'origin/5.4' into dev
Conflicts:
	.qmake.conf

Change-Id: I65c8503cf632699129ebb6b4f01721b74be78def
2015-01-19 14:07:39 +01:00
Giulio Camuffo
6723e2148d Set the composing string of the wayland input method
Task-number: QTBUG-43346
Change-Id: I9bc6d804ddca59a7a0173b8f0d3ec2f268fe9a59
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
2015-01-13 14:01:42 +01:00
Giulio Camuffo
92eac38d68 Send proper mouse enter events
The wl_pointer.event carries the surface local position of the pointer.
Notify Qt of it, without pretending it to be a motion event.

Change-Id: Ibbe1d125a93b478f9c350a50bfea25b01f628178
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
2015-01-13 14:01:20 +01:00
Giulio Camuffo
7fd1af437b Allow retrieving the egl display for a QWindow on wayland
This allows a compositor running with the wayland qpa inside another
compositor to provide EGL to its clients.

Change-Id: I308fb909c8168955148be152bf314a53c0e5ca43
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2015-01-05 14:59:42 +01:00
Thiago Macieira
68a6cf54a0 Remove unused members
Clang found two problems with this from QWaylandDataDeviceManager. First,
it's a class, not a struct.  Second, nothing is using this private
member.

qwaylanddatadevicemanager_p.h:66:5: warning: struct 'wl_data_device_manager' was previously declared as a class [-Wmismatched-tags]
qwaylanddatadevicemanager_p.h:66:36: warning: private field 'm_data_device_manager' is not used [-Wunused-private-field]

And also this one:

qwaylandextendedoutput_p.h:61:21: warning: private field 'm_screen' is not used [-Wunused-private-field]

Change-Id: Ifc8f28f92190547dcb0a5319aa6fc14277894f15
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-12-31 13:36:09 +01:00
Giulio Camuffo
846324db5a Make use of the new QPlatformIntegration::destroyScreen
Task-number: QTBUG-41141
Change-Id: I0bd789cc1090f7e0e7615b47c33a4e4179677398
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
2014-12-29 17:30:06 +01:00
Frederik Gladhorn
5715d858a0 Merge remote-tracking branch 'origin/5.4' into dev
Conflicts:
	.qmake.conf
	src/compositor/compositor_api/qwaylandsurface.cpp

Change-Id: I3ee40153c959dbe31ea685571c5a8bb1ae36606e
2014-12-29 16:20:29 +01:00
Philippe Coval
934b4bb9a5 xdg-shell: upgrade to support current version (weston-1.6.0)
Many inprovements on windows's decorations,

Also handle compositor events
(test: Super+Shift+F , Super+Shift+M)

The protocol file is a raw copy of

Source: http://cgit.freedesktop.org/wayland/weston/plain/protocol/xdg-shell.xml?id=1.6.0

Task-number: QTBUG-38633/related
Change-Id: I667ec52c8a7e34d74b60174a671c89671f841d6b
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-12-28 15:30:59 +01:00
Morten Johan Sorvig
7b722dcd07 Implement high-dpi support
Wayland 1.2 added support for display scaling, where wl_output
has a "scale" event informing the the client that the compositor
will scale the output surfaces by the given factor. The client
then has the option of providing large surfaces to match the
target pixel densety and bypass the compositor's scaling. This
is done by calling wl_surface::set_buffer_scale.

Re-use the current high-dpi support in Qt by implementing
devicePixelRatio() for QWaylandScreen and QWaylandWindow.
Provide high resolution buffers both for raster and OpenGL
graphics.

Introduce a new coordinate system: buffer coordinates, which
is related to the window coordinate system via an "int scale"
scale factor. This scale factor corresponds to Qts qreal
devicePixelRatio, but we keep the name and the type in the
QtWayland implementation.

Change-Id: Ie10d7e5b4833480a9a25d96a26ad02150eb6e83f
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-12-17 13:46:27 +01:00
Giulio Camuffo
d2e278e4e2 Fix possible double free when hiding a window
There was a race condition between the gui and the wayland event thread
which could lead to double freeing the QWaylandShmBackingStore's frame
callback. Protect the wl_callback_destroy calls using a mutex.

Change-Id: Ia70ebac208a6d4450328ba5254a850be26d84d6d
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
2014-12-06 22:56:12 +01:00
Laszlo Agocs
a40ad12ef2 Enable Qt WebEngine on Wayland
The native resource getters that are supported by eglfs will have to be
supported by the wayland platform plugin too. (on wayland-egl at least)

Change-Id: Ibbab649c04785dbde177342c45b9bc6f1edd954d
Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
2014-12-04 13:46:59 +01:00
Laszlo Agocs
c9909b7ce9 Silence uninited variable compiler warnings
The code is correct but some compilers may still warn about dragData not
getting initialized. Silence them.

Change-Id: Ib52321667fc5094e22ebbef538b72b5477e6f10b
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-12-03 16:44:16 +01:00
Giulio Camuffo
ab56b7a11f Merge branch '5.4' into dev
Merge done by Giulio Camuffo

Conflicts:
	src/client/client.pro
	src/client/qwaylanddisplay.cpp
	src/client/qwaylandinputdevice.cpp
	src/client/qwaylandinputdevice_p.h
	src/client/qwaylandwindow.cpp
	src/compositor/compositor_api/qwaylandsurface.cpp
	src/compositor/compositor_api/qwaylandsurface_p.h
	src/compositor/wayland_wrapper/qwlsurface.cpp

Change-Id: I1df878bb54f49d953c51215a2772869e261ebe81
2014-11-15 18:46:38 +01:00
Olivier Blin
a92c4a48bc Fix crash when cursor theme can not be loaded
Also add a debug message about theme loading failure.
This is not necessarily fatal, some embedded applications could still
function properly without a cursor.

Change-Id: Ib3e2ee43b00630ee77997c7472a95ac5a22c2cc2
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2014-10-21 18:42:02 +02:00
Laszlo Agocs
351e3672d6 Fix -no-opengl builds
Task-number: QTBUG-41677
Change-Id: I039ec581e960eb70eb04aed6e65add70c563ba77
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2014-10-14 11:23:56 +02:00
Giulio Camuffo
77fd8f63c3 Be compatible with older compositors
When binding globals take care of the version the compositor provides
and don't call requests that the compositor doesn't implement.

Change-Id: Iea0c534fb9e005720857e2778e380b6a9c22a6f3
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2014-10-13 10:05:39 +02:00
Giulio Camuffo
eac16a7b28 Pass the relevant serial when setting the selection
This fixes copying in Weston.

Change-Id: Icbdb81078e8df4575bbe440321773131ba27ebbf
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-10-09 14:27:07 +02:00
Giulio Camuffo
838501541a Fix the compositor's wayland versioning
We cannot just assume all clients implement the same version of the
various interfaces as the compositor does. Keep track of them, and
react accordingly when creating a resource or sending an event.

Change-Id: I9792433a14d49c5c4df0c892fc1349ce0dfb0d43
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2014-10-09 09:40:10 +02:00
Giulio Camuffo
1ed546004c Fix shm windows sometimes not showing after being hidden
QWaylandShmBackingStore installs a frame callback on flush, and subsequent
flushes will not attach a new buffer until the callback is fired.
If the window is hidden while we're waiting for the callback, we attach
a NULL buffer, so the compositor will not redraw the surface and will not
fire the frame callback. When showing the window again the backing store's
flush() will wait indefinitely for the frame callback to attach its buffer.
To fix it destroy the frame callback when the window is hidden.

This was easily noticeable when fast switching between popup menus.

Change-Id: Ic0c71ed79e2fab9faf452f63b05bc4576ea9a3ba
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2014-10-06 10:16:28 +02:00
Mikko Levonmaa
5ec3eacefe Allow client side input device customization
Introduces QWaylandInputDeviceIntegration plugins to allow customization
of input device related behavior. The plugin can be activated via the
environment variable QT_WAYLAND_INPUTDEVICE_INTEGRATION

Change-Id: If5629737752afacb29161f51c1b7c6e171fb2758
Reviewed-by: Mikko Levonmaa <mikko.levonmaa@lge.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-10-06 07:53:53 +02:00
Giulio Camuffo
5984e1e5c1 Call ::exit() from the gui thread only
::exit() is not thread safe, so make sure to not call it more than one
time, once from the gui thread and once from the wayland event thread.

Change-Id: I80905c6d996cb827a5101ae6d6c9bc12a267ba71
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2014-10-02 11:36:52 +02:00
Giulio Camuffo
1a3d78d81f Support the creation of >= 3.x OpenGL contexts
Use the EGL_KHR_create_context extension if available to create modern gl
contexts. We disable window decorations on core profiles because that
mandates a VAO to be used.

Change-Id: Id6044e64f6736244ae9d593af4d68c4000a31de6
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-09-30 17:36:04 +02:00
Giulio Camuffo
12cc3e6f55 Send also repeat key release events
We were sending only key press events for the key autorepeat, going
out of sync with the release events. Xorg sends both relase and press
auto repeat events, do so here too.

Change-Id: I41a9bfaff50afea779a7572220f6a01b507e95ac
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-09-28 20:05:50 +02:00
Giulio Camuffo
222ed6ba7b Use the screen resolution to determine whether a screen is portrait
We were using the screen physical size to determine if a screen is
portrait or landscape, but we may not always get a valid size.
Instead use the screen resolution.
The orientation is then calculated in the wl_output.done handler,
since we don't know the resolution yet when receiving the first
wl_output.geometry event.

Change-Id: I3554f916e54db829f49fa3d1ea24f7ce1ff24e7c
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
2014-09-24 10:43:15 +02:00
Robin Burchell
21571bb4fb decorations: Remove strange set dance between QWaylandWindow & QWaylandAbstractDecoration.
This makes absolutely no sense. Just do things inline.

Change-Id: Ic6d4e62bc9b3c0a4533f63740f2608a0be201047
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2014-09-23 12:35:34 +02:00
Robin Burchell
9dca9722f0 QtWaylandClient: Pluginize window decorations.
Convert to a D-pointer, split between abstract base class and an implementation.

Also move implementation of the current built-in decoration to the "bradient"
plugin, named in glorious memory of the programmer-designed blue gradient that
will forever sear our eyeballs.

The decoration plugin may be specified using the environment variable
QT_WAYLAND_DECORATION.

Change-Id: Idc99ab06ae138ad299bad2b62b9595379bd007ab
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2014-09-23 12:35:31 +02:00
Robin Burchell
abd71e1305 Rename QWaylandDecoration => QWaylandAbstractDecoration
This is in preparation for decoration plugins.

Change-Id: Idb322a7a5cbc2eb5bf2cce019073f9f4fb46297f
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2014-09-23 12:35:27 +02:00
Frederik Gladhorn
03c1b4d4ca Merge remote-tracking branch 'origin/5.4' into dev
Conflicts:
	src/compositor/wayland_wrapper/qwlcompositor.cpp

Change-Id: Ica26e33eb2b77ed5be0e84e8f4256d2e85abfaf5
2014-09-19 18:05:25 +02:00
Giulio Camuffo
a3fa898878 Ignore negative screen physical size
Weston can send in some cases a negative physical size in the wl_output.geometry
event. While it is not clear whether that is legal go the extra mile and catch
it.

Change-Id: Ie2fbab84e653ad77732a72b6ca61509eb7849895
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-09-17 15:22:15 +02:00
Giulio Camuffo
1aeeab6e33 Fix retrieving the selection/dnd data
Installing a roudtrip on the custom event queue in the wl_data_offer.offer
handler is broken because that triggers a wl_data_device.selection event,
which emits the QClipboard changed signal, so code listening to it may end
up trying to retrieve the clipboard data before the roundtrip ends.
Additionally, we're calling wl_data_offer.receive for each mime type, even
if then we never read from the fd, making the source client do work for no
reason. Instead, call wl_data_offer.receive retrieveData_sys, that is when
actually retreiving the data.

We don't need to install a roundtrip after that, just flushing out the
requests is enough, because we wait up to one second for the source client
to write into the fd.

Change-Id: I180779e375ebd5a22af7084458505a41107fab19
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2014-09-15 11:54:03 +02:00
Giulio Camuffo
b9f7e26a49 Don't give bogus values for a screen physical size
If we don't have a valid physical size for a screen, i.e. (0x0),
return the default value from the base class.

Change-Id: Ia7b6f90ee73e07014ab752ceb165426812c49415
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-09-15 11:45:59 +02:00
Giulio Camuffo
3d6c98cc58 The QWindowSystemInterface API changed, make it build again
Change-Id: Ic00a820ebac7727a8d71d62ce191fe29de52aac0
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2014-09-15 11:45:54 +02:00
Giulio Camuffo
c9dbc3d97d Fix QWaylandScreen geometry and physical size
The wl_output.geometry event carries the physical size of the output,
not the logical one. This happened to work only because the geometry
event was sent before the mode event, which carries the logical size.
Moreover, use the done event to send only one geometry change event
instead of one per advertized mode.

Change-Id: I5b09d56654aac149d90692bb5a3e050cc0d60cb6
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-09-08 14:06:08 +02:00
Laszlo Agocs
f58e56ccf9 Silence warnings about keyboard grab and size hint propagation
These two unimplemented functions often result in showing warnings
from the default implementations. This is not quite ideal since the
warning is useless for users and pollutes the standard output (which
f.ex. Creator captures as-is)

Change-Id: Ic05ff1590ed351738f0390a94ed5203a05664d4a
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
2014-09-08 10:15:47 +02:00
Laszlo Agocs
767cc05e57 Avoid useless handleTouchEvent call
The call when allReleased is true is a historical artifact: Originally
the call was necessary to generate a TouchEnd. Later the determination
of the event type got moved to QWindowSystemInterface. As a result the
call is completely superfluous since it will bail out immediately.

Task-number: QTBUG-36473
Change-Id: If1a270445a620e6f795912873c60fb1a05384964
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
2014-09-08 09:37:26 +02:00
Laszlo Agocs
0fdbe40ad4 Allow activating decoration buttons with touch
Task-number: QTBUG-41142
Change-Id: Ifad600d375d3b5ba197c384ece54a93db9aa0d2d
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-09-06 22:27:05 +02:00
Laszlo Agocs
c1ed159653 Fix window decorations for GL apps
You cannot have rounded corners with an alpha-less config. To make OpenGL
applications appearing with the correct decoration, alpha must be enabled.

With this fix the OpenGL apps' decoration will now look identical to the
SHM apps'.

Change-Id: I24431ddab63146f7f697c85277f00f41e5c55e85
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2014-09-06 20:46:57 +02:00
Giulio Camuffo
1bb22c40a3 Advertise new screens created after startup
Change-Id: I995f49e52ec888830b478f1e1f9cc82132776725
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-09-06 20:25:00 +02:00
Laszlo Agocs
4ca2fc4d1b Avoid unused parameter
Change-Id: Icfc7e4e2d6cd030fc0509ad4724b577f88c4e850
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2014-09-05 22:17:20 +02:00
Li Qiu
03e95c8b8c DataOffer not invalidated when client loses keyboard focus
The data_offer object should be invalidated when client loses keyboard focus.
Otherwise in following scenario, it will become zombie object: start app1 ->
copy text -> start app2 -> paste text -> close app1 -> paste again in app2 ->
seg fault in qtwayland.

The root cause is that when app2 takes focus the first time, data_device.data_offer
event was sent to it from DataDevice::setFocus. When app1 is closed, the data source
reference in data offer becomes invalid. so when trying to paste again in app2,
segmentation faults

Change-Id: I16a584e80fddaadd269b00cdf39eb405dd95b622
Task-number: QTBUG-41005
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-09-04 10:13:01 +02:00
Giulio Camuffo
421b3bb9e1 Destroy the QScreen when its wl_output is removed
Change-Id: I4532d05cca44c88fe38c14eacbe90c190f272b2c
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-09-04 09:55:04 +02:00
Li Qiu
45fdcd4818 Fix crash of test client
No wl_data_device_manager created in Mock compositor

Change-Id: If80f71165c28678f296bc18f0fea572dcb1a2f77
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-09-04 09:29:43 +02:00
Shawn Rutledge
76c98e7671 Wayland: can drag a window by its titlebar using the touchscreen
It was already possible to drag it via the mouse but not via touch.

Task-number: QTBUG-41085
Change-Id: Ia52c7124fb2f1aa0331897bd072fcf09fb78aa1a
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-09-01 18:08:01 +02:00
Shawn Rutledge
c15ee9f0e3 Wayland: correct touch location
The window margins were offsetting the touch point in the wrong
direction.

Task-number: QTBUG-36602
Change-Id: Id8b31d2de4051f36d3ff4e088bbc9bd7cc84ca13
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-09-01 15:41:53 +02:00
Laszlo Agocs
6a0d904dda Fix touch with Weston
Work around the missing touch_frame after the last touch_up.

Task-number: QTBUG-36602
Change-Id: Iccb03bdc8b430c7cefc097c3c84e50be676c7fe7
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
2014-09-01 09:54:12 +02:00
Laszlo Agocs
2f329b4696 Indicate from the client buffer integration if decorations are supported
Custom client buffer integrations may not care about window decorations.
Setting QT_WAYLAND_DISABLE_WINDOWDECORATION is tedious and error-prone.
And it cannot be omitted since things like input events will be off if the
common client code thinks decorations are in use but the client buffer
integration does not render them at all.

Therefore add a supportsWindowDecoration() virtual in addition to the
environment variable.

Change-Id: If8f621182d5c230f4d8d679c050f5d27aed6c2fb
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-08-25 14:06:38 +02:00
Laszlo Agocs
5d49d5a224 Support RasterGLSurface windows
In an attempt to make QOpenGLWidget and QQuickWidget working on Wayland.

Since Qt 5.3 all widget windows are of type RasterGLSurface (given that
the plugin reports this capability which wayland will, with this patch).
Such a window can behave either like a raster or an OpenGL window.

This concept maps badly to platform plugins that have a rigid separation
between raster and OpenGL platform window implementations. From now on,
the OpenGL window implementation, that is used pretty much always,
except for raw RasterSurface windows, must be prepared to behave like
a raster window too, which involves having a backingstore.

Change-Id: I0226704b8d5893843fcae68059c5fe9ad2f5e761
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2014-08-25 11:50:32 +02:00
Giulio Camuffo
611716293c Explicitly define the interface versions
Currently a global is bound with the version the interface has in the xml
file. This is a problem for apps that explicitly link to libwayland-client
because they may link to a newer libwayland, so the version of some interface
may be higher than the one that it is actually implemented.

Change-Id: Id0dbe6c0f1e05fe91954b9d8d9472d42d2053cdc
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-08-23 21:41:11 +02:00
Laszlo Agocs
f4e576fbe9 Fix typo
Change-Id: Idd4351b2650e8869d0e6038d11be5da37f4bdbb1
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-08-22 17:49:09 +02:00
Robin Burchell
9ac0da7c31 Fix window decorations being leaked.
Change-Id: If0483f5e81a033b275ddc14eb1e44ff82fa1ce65
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-08-21 10:55:40 +02:00
Robin Burchell
8975683c37 QWaylandDecoration: Remove some unused members
Change-Id: Ia98190adbd3f710de6734c10062792ce3f4547d9
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-08-21 10:55:24 +02:00
Robin Burchell
bb360fce60 QWaylandDisplay: Centralize error handling in one place.
Change-Id: Ifba23e349a4006cea501480a7230408f0fafd1b7
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-08-19 18:46:11 +02:00
Robin Burchell
c6766fe4f4 QWaylandDisplay: Correctly intercept all errors when dispatching.
A connection reset isn't the only form of error we may run into, so make sure we
check for other exceptional circumstances through wl_display_get_error.

This fixes my case of e.g. wl_drm throwing an error but QtWayland never
quitting the client.

Change-Id: I8c76dd7913640e58d03bd2fe52eb054a4daa0235
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-08-19 18:46:05 +02:00
Giulio Camuffo
76f5ad1784 Make the test client more robust and make valgrind happy
Change-Id: I39ce667123391b946711cc2d16d12799e8b7dd2d
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2014-08-19 15:49:04 +02:00
Thiago Macieira
2efc3bcf4d Fix warning about use of uninitialized variable
qwaylandwindow.cpp:443:25: warning: ‘transform’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Change-Id: Ic0a96cfda35d331c9957a527eea7f8b987191b5f
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2014-08-19 02:49:02 +02:00
Robin Burchell
34d69d9b4d QWaylandScreen: Also call QPlatformScreen constructor.
Change-Id: Iae63ea5b15f2422ea28f2f9c8d7abeb30d23c86f
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-08-18 13:52:36 +02:00
Robin Burchell
132cbe5414 QWaylandDisplay: Destroy screens when destroying the display.
Fixes a crash in tst_QApplication.

Change-Id: Ibfc7aded10609cff9c7a20b7193f44d1c73bc893
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
2014-08-18 13:52:32 +02:00
Robin Burchell
131ccbd4cd QWaylandDisplay: Remove unused static.
Change-Id: I868168dee716103962217b5ceb38185090f82e09
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-08-18 13:52:29 +02:00
Robin Burchell
e03a21353c Remove qPlatformScreenForWindow from header.
Use of this was removed in 02e50ef592f28ec05654acf3f6c9b84d31736269.

Change-Id: I729282bfa9536380fc0d5b2702448cc54a90e37d
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-08-18 13:52:26 +02:00
Robin Burchell
223fc10cde QWaylandWindow: Add a missing shell surface null check.
Caught by tst_QWidget::mapFromAndTo.

Change-Id: I36e08ebfa3bae1ac8667ee828b1762867d71c66d
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-08-18 13:52:21 +02:00
Oswald Buddenhagen
a34017d157 Merge remote-tracking branch 'origin/5.4' into dev
Change-Id: Ie82592f160ebf545fac7b864db5e38c9ce9bb41f
2014-08-15 23:42:48 +02:00
Giulio Camuffo
d9ba141df9 Fix possible crash of the test client
The cursor surface is not in the surfaces list when destroyed

Change-Id: Ie29224679776d0abec7862d2976be892c63521a7
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2014-08-15 18:54:54 +02:00
Giulio Camuffo
6c9cd444fc Fix client tests
Change-Id: I6511dfb826c522db3d8bd01c5670c06f187abff2
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2014-08-15 15:28:32 +02:00
Giulio Camuffo
5ef1d81af0 Flush the wayland events on the dispatcher's awake signal
This is not normally needed, but it is when an app, like our client test,
needs to have the requests flushed out by a QCoreApplication::processEvents
call.

Change-Id: Id821eaf5b612dc44281141181a09718f409e7eb6
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2014-08-15 15:28:30 +02:00
Jan Arne Petersen
e1514abaea Add support for setMask to set input region
Also fix input region handling in compositor.

Change-Id: If88ad6a03443526eddee045d7af54daf5057373a
Done-with: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-08-13 21:24:40 +02:00
Giulio Camuffo
68e5d64a83 Reset the wl_keyboard/wl_pointer resource pointers if destroyed
Change-Id: I8693f845817d2dd4b0e0b54352c374f6a0e643d3
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
2014-08-13 13:20:36 +02:00
Robin Burchell
208fec2757 Fix license test.
Add missing copyright headers and fix existing (bad) ones.

Change-Id: Ibbc6f3e996105305c8a2ed7d81ccee79795ee531
Reviewed-by: Andrew Knight <andrew.knight@digia.com>
2014-08-13 11:36:55 +02:00
Giulio Camuffo
76ba822e04 Make the expose region local
Change-Id: I570bbe77185637ebe621e6c915eef2f4442fdd84
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-08-13 09:36:59 +02:00
Giulio Camuffo
5d30b5086d Fix namespaced build
Change-Id: Id73f8ddffe00359f38c634fc88b1f81ac5638653
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
2014-08-07 19:17:57 +02:00
Giulio Camuffo
9c1eef7e22 Add a way to have out of source shell integrations
Some platforms (especially non-desktop ones) may use a custom
Wayland shell extension, more tailored to the form factor than
the generic and desktoppy wl_shell or xdg_shell. Instead of stuffing
N protocol implementations in the QPA plugin use a plugin architecture
to allow them to live out of tree.
When creating a shell surface the QT_WAYLAND_SHELL_INTEGRATION env
variable will be checked, and if it points to a valid plugin that
will be used to create the shell surface, falling back to wl_shell
or xdg_shell if no plugin is specified.

Change-Id: I05019174bb915199dd726f5fdcc0385ef846e8de
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
Reviewed-by: Philippe Coval <rzr@gna.org>
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
2014-08-07 07:59:00 +02:00
Giulio Camuffo
ded0d67c22 Wait to get wl_output's events before creating surfaces
Change-Id: I2eb4b40a4b8b1de7990d06b57b0d7a7b04ee9657
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
2014-08-05 11:51:18 +02:00
Giulio Camuffo
fb46141b75 Bind the globals with the highest version available
Change-Id: I639b124f15416905c17665755b3288c905880f39
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
2014-08-05 11:51:15 +02:00
Giulio Camuffo
0897a2be72 Make sure to have a hardware integration when creating windows
We need to do a full roundtrip and wait for the qt_hardware_integration
global before returning from QWaylandDisplay constructor. Waiting
for the screen is not enough, since there is no guarantee it will come
after the hardware integration global.

Change-Id: I34cb50b830632db7e5d5c7a502eeef778599b267
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
2014-08-04 09:37:23 +02:00
Pier Luigi Fiorini
979b1db750 Resolve build warning on client code
QString::QString(const char*) is deprecated, wrap thread name
with QStringLiteral.

Change-Id: Ic914d05e7bee6e3f1c6aa0bede44a6b6b85be565
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-08-01 14:35:56 +02:00
Giulio Camuffo
b4b6dd3a75 Fix checking initial screen aspect ratio
The first time QWaylandScreen gets an output_geometry() event its
screen() may not have been initialized yet, so manually check
if the output is portrait or landscape.

Change-Id: I1d58daee7a3f168a881a1e2d21956c52c09818fc
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-08-01 14:10:16 +02:00
Giulio Camuffo
1cb65e556c Use wl_surface.set_buffer_transform to signal surface rotation
Drop the custom request in the surface extension, and use the
wayland core mechanism.

Change-Id: I580f56c90bcd3b2c5a6da08d1a033b10790ac330
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
2014-07-31 19:06:41 +02:00
Giulio Camuffo
755eefab6a Use wayland core interfaces to signal output rotation
The wl_output interface has an event for signaling the rotation of
the display, so use that instead of our own thing.

Change-Id: I8a017d575ee456a7a81649e19a015085fb784805
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
2014-07-31 19:06:30 +02:00
Giulio Camuffo
40ce144ae3 Auto repeat only the keys which should be repeated
Change-Id: I283bf6cc2f6c338fc769d77dd84ae7acb08eb7be
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-07-23 10:48:30 +02:00
Giulio Camuffo
db497bbba7 Give a name to the event handling thread
Change-Id: I5c6073bc1908e54bc5ae50d4b6b6044974f1ad60
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2014-07-21 23:09:01 +02:00
Giulio Camuffo
b03877cadf Add cmake test for QtCompositor and disable cmake files for QtWaylandClient
Change-Id: Id6e2d46b55e521218a3c0f44cf9a4a2be5f0df7f
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2014-07-08 12:21:08 +02:00
Gunnar Sletta
c0847e9144 Avoid crashing race condition.
Change-Id: I940bcbc509a689804a02f71af45f5efc19bccf9f
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-06-30 11:50:54 +02:00
Gunnar Sletta
0bfe40dc8d Delete data device manager while display is still alive.
Change-Id: I7691e06d75866034c93020ebdfb45421275fcf9d
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-06-27 15:08:12 +02:00
Philippe Coval
b4e47c370d xdg-shell: upgrade to support current version (weston-1.5.0)
The protocol file is a raw copy of

Source: http://cgit.freedesktop.org/wayland/weston/plain/protocol/xdg-shell.xml?id=1.5.0

Task-number: QTBUG-38633/related
Change-Id: I41ca2f89c09a8b6348ce2fbf6d59f44b4c8134df
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
Reviewed-by: Philippe Coval <rzr@gna.org>
2014-06-20 13:52:38 +02:00
Giulio Camuffo
43cd8c4fe7 Reduce headers inter-dependency in the QPA plugin
Change-Id: I8b810e54531453b6a80250555c21bb0b1e6e76cc
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2014-06-16 14:04:02 +02:00
Giulio Camuffo
2de0e4fe4e Fix generated code for interface names not starting with qt_ or wl_
The generated code for an interface without a qt_ or wl_ prefix was
broken, and could not compile.
This commit needs a 'make clean' to let qtwaylandscanner run again.

Change-Id: Id9c7e3f87385f83eeffd1e8718c854a405f411f0
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
2014-06-12 08:57:06 +02:00
Philippe Coval
1fc185140d Add minimize feature to QWindow using wayland's xdg-shell
The feature is disabled by default,
and can be enabled at runtime
by exporting QT_WAYLAND_USE_XDG_SHELL env variable.

This patch relies on presence of protocol file
which has been imported from weston-1.4.0 sources,
until the xdg-shell is merge into wayland itself.

Because xdg-shell is experimental,
code fallback to WaylandShell if no XdgShell
but keep in mind those shells are exclusive.

Since xdg-shell and wayland-shell share most of the API,
some factorization is done by an (empty) abstraction class
to keep the code more readable.

Despite xdg-shell introduces new popups concept,
they're not used on this change for maitainance purpose.

Notes:

* This change depends on presence of xdg-shell protocol file.

* You can check a demo video
  (qt-tizen-cinematic-experience-20140430-rzr)
  of the test case at :
  https://www.youtube.com/watch?v=pY_XXvKc_0E#

* Use Super+Tab to show window again if hidden

Task-number: QTBUG-38633/part/2of2
Change-Id: I2d7ed85bea1847d82439fdfc893a3dbb2581c14a
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-06-09 11:44:30 +02:00
Philippe Coval
806773681e Add xdg-shell protocol file version 1.4.0
Source: http://cgit.freedesktop.org/wayland/weston/plain/protocol/xdg-shell.xml?id=1.4.0

This file will need to be refreshed on protocol update
until xdg-shell land in wayland's public headers

Task-number: QTBUG-38633/part/1of2
Change-Id: I397d863dcfc2223ac6eb234c37dbcd7449eced58
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-06-09 11:44:20 +02:00
Giulio Camuffo
8d6b106a8c Disable headers precompilation
qtbase's cb09e1e enables precompiled headers by default.
Unfortunately qmake tries to precompile them as C headers
as a dependency of the .c protocol files we have, failing
the build.
Quick and easy solution: disable them alltogether.

Change-Id: I96a4f4fd1fe0d3a83bb990408f1f3994650d96c5
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2014-06-04 18:49:01 +02:00
Gunnar Sletta
75a2fc72aa Avoid virtual calls in constructors.
QWaylandWindow::setGeometry() is a virtual call and internally it
would call windowType() which is pure virtual, so calling it from
the constructor won't work.

Instead, set geometry explicitly from the constructor and call
setGeometry() on setVisible(true). This also merges it so we send
one expose event (with correct x/y offset) on geometry change + show.

Change-Id: I1d21664c982005c60c8d73740e43b3a463bac4a8
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
2014-05-22 14:37:26 +02:00
Giulio Camuffo
bff6e88d73 Fix resizing of shm apps
Change-Id: Iad94691317bde38603d9143f951b1b69326ab12e
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-05-12 16:35:43 +02:00
Giulio Camuffo
e295df8b1d Send the native codes of the key events
Change-Id: I58343ebf931d946a9d1dfc1f0949ba296d97ec52
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2014-04-29 12:44:08 +02:00
Giulio Camuffo
7fb846e5f2 Discard the selection and drag source when not active anymore
If another client sets a selection or starts a drag the active
wl_data_source, if any, gets a 'cancelled' event. We must listen to
this and discard the wl_data_source, else e.g. checking the clipboard
content will still return the data of the source instead of the current
wl_data_offer.

Change-Id: I80b202baf95fbc8abe19496a991cb30bc0b78bb0
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2014-04-24 15:13:38 +02:00
Andrew Knight
def782f1a4 Clipboard: perform non-blocking reads from compositor
Since the compositor recycles file descriptors when offering data to
clients, it is possible that a client (or multiple clients) can attempt
to read from the same FD simultaneously, creating a situation where one
read can wait indefinitely for data. By making the pipe non-blocking,
the client can gracefully time-out if data doesn't arrive in a timely
manner.

This commit also ensures that only one FD is open per client per offered
mime type.

Change-Id: If052e5bf8198df1cdc8fc4df360f83a77950b2f9
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2014-04-24 13:41:03 +02:00
Oswald Buddenhagen
47d979b9fa Merge remote-tracking branch 'origin/stable' into dev
also amended the libhybris plugin according to the merged change.

Change-Id: I2987043cf21936aa0f221343d00dacdc574be06a
2014-04-15 19:22:39 +02:00
Tomasz Olszak
88d888b126 build fix for MODULE_PLUGINS_TYPE
Change-Id: I8d44f50480440060eba84354e88fb2535e1d8e4a
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2014-04-15 14:16:21 +02:00
Elvis Lee
86146d9f86 Null check for window on pointer_axis
The window is already destroyed and server doesn't get a message yet.

Change-Id: Ia9dd0ce891a712d1aa913fcb3313a5fe300788ab
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2014-04-07 14:40:44 +02:00
Vesa Halttunen
5559bb6c1e Set the right content orientation of the extended window on QWaylandWindow ctor
Change-Id: I5cf5afc7b920ff754fb21fc748af61a596e20c7b
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2014-04-05 14:06:00 +02:00
Giulio Camuffo
2b0e4c78bc Fix broken include guard
Change-Id: I6f68e04c55397b702727a76ff50ea213c193cdf6
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2014-04-01 08:36:01 +02:00
Giulio Camuffo
5d9ed010d5 Always bail out when the compositor is closed
errno can both be EPIPE and ECONNRESET when reading from the connection
after the server is closed.

Change-Id: I03b64a382db3de66819277e9955aeca3e2d7f9a1
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2014-04-01 08:35:58 +02:00
Giulio Camuffo
0431544ee3 Add a libhybris hardwareintegrations to share EGL server buffers
Add a hardwareintegration plugin to make Qt server side EGL buffers
shareable from the compositor to the client, such as what the
server-buffer example does.

Change-Id: I24558324d51202ca449b47b0ee395c8e81c10698
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2014-03-26 15:14:10 +01:00
Jorgen Lind
1706b46194 Take advantage of the Qt 5 plugin json structure
Also change naming scheme of plugins:
buffer integrations doesn't start with "wayland-" but the platform
plugins have to start with "wayland-".

Also update the README

Change-Id: I6dd2103ab287ed569ab06cfb6eb469e3db058831
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-03-11 15:35:18 +01:00
Jorgen Lind
982cef3480 Fixup for GLX integration
Change-Id: I2de94481f7d3e109fdce7ca961f8969299cf5d9e
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-03-11 15:35:08 +01:00
Giulio Camuffo
8e8f8630b7 Change the minimum required Wayland version back to 1.2
As discussed, Wayland 1.3 is not common in distributions yet, and
that is a problem for the C.I. machines.

Change-Id: Iec5c6d8ae1d1a50199f66d45ca9269694db78efe
Reviewed-by: Andrew Knight <andrew.knight@digia.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
2014-02-28 15:27:47 +01:00
Oswald Buddenhagen
ab78e6599f Merge remote-tracking branch 'origin/dev' into stable
Conflicts:
	src/compositor/wayland_wrapper/qwlsurface.cpp

Change-Id: I3b6a4af41f272d3dc7fc920ba2542f2dd7978175
2014-02-19 10:14:47 +01:00
Pier Luigi Fiorini
a0bc006361 Strip custom prefix from interface name
Interface names for some protocols might not start with wl_ or qt_,
with this change users can specify a prefix of their liking.

Change-Id: I70d40985165c49114b525bdec2a872aa5b0dad6d
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2014-02-09 15:50:55 +01:00
Martin Gräßlin
82669149b0 Provide "kde" in the themeNames
KDE would like to get its integration plugin on Wayland.
The name won't change for Wayland, so filtering it out
because it is the name of the X11 desktop environment is
wrong.

The patch follows the approach of the QGenericUnixTheme.

Change-Id: Ia9c253ae6b5d609bd3bc630ce5c36b89811b079a
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2014-02-07 10:52:21 +01:00
Andy Nichols
ebe84dd5cc Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
	src/client/hardwareintegration/qwaylandclientbufferintegrationplugin_p.h
	src/client/hardwareintegration/qwaylandserverbufferintegrationplugin_p.h
	src/compositor/hardware_integration/qwaylandclientbufferintegrationplugin.h
	src/compositor/hardware_integration/qwaylandserverbufferintegrationplugin.h
	src/plugins/hardwareintegration/client/brcm-egl/main.cpp
	src/plugins/hardwareintegration/client/drm-egl-server/main.cpp
	src/plugins/hardwareintegration/client/wayland-egl/main.cpp
	src/plugins/hardwareintegration/client/xcomposite-egl/main.cpp
	src/plugins/hardwareintegration/client/xcomposite-glx/main.cpp
	src/plugins/hardwareintegration/compositor/brcm-egl/main.cpp
	src/plugins/hardwareintegration/compositor/drm-egl-server/main.cpp
	src/plugins/hardwareintegration/compositor/wayland-egl/main.cpp
	src/plugins/hardwareintegration/compositor/xcomposite-egl/main.cpp
	src/plugins/hardwareintegration/compositor/xcomposite-glx/main.cpp

Change-Id: I9a9b418075970dd334babc3590b9b0315c2afb0d
2014-02-04 15:04:56 +01:00
Giulio Camuffo
70c578cb5e Fix the client behavior when showing or hiding a surface
Reduce the chances of seeing a bad frame.

Change-Id: Idac3450d92210fc5fc33cb68862b089964c9a8ce
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2014-02-04 11:41:30 +01:00
Jorgen Lind
df0f2ea110 Add the A8 MESA for mat patch for the Mesa v.10 branch
Change-Id: I771e0478e274ef7cfabb417c9712d4dbb4d62f5b
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-02-03 17:50:21 +01:00
Shawn Rutledge
43aaab2808 init mTouchDevice to null
Since QWaylandInputDevice::seat_capabilities checks the pointer before
creating this object, it must be initially null so that the device
will be registered.

Change-Id: Ia15b407b1636eab41c04f30bb631306095e5aefb
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-02-03 15:28:55 +01:00
Giulio Camuffo
5f52b6b508 Allow resizing the Qt window after the buffers swap
Some EGL implementations resize the EGL buffers after eglSwapBuffers,
so we need to send the geometry change event after the swap, or else
the Qt window size and the physical buffer size will be different to
each other. Do not force this behavior though, but use it only when
the QT_WAYLAND_RESIZE_AFTER_SWAP environment variable is set.

Change-Id: I79e39442b3010c563a81d7c94e747a982e158fc1
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
2014-01-22 08:30:27 +01:00
Jorgen Lind
e8df7316cd Fixup the iid versions for the plugins
Change-Id: Iac1b8b070d3bf87b29d0be9a2a76fd56e7046f0f
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-01-20 13:10:03 +01:00
Jorgen Lind
47d8cb089e Fix compiler warnings because of deprecated apis
Change-Id: I60faee3fb4b9a74a13c8489a5dd1df7a2a5a4ae4
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-01-17 14:40:37 +01:00
Jorgen Lind
9a6a2fbe21 Update the required wayland version to 1.3
Change-Id: Id1c9d14061d513f6c37a59ed8161732366ab3526
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-01-17 14:40:01 +01:00
Laszlo Agocs
8738267dbc Fix some typos
Change-Id: I5c734561c0c13192acd9ffd590eb2e8eeb3ca4e1
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2014-01-16 12:36:56 +01:00
Laszlo Agocs
30cd553ea6 Fix brcm keys
Did not match the key used in the plugin metadata.

Change-Id: I58cf08c684b33d8d7166a074dbafb4187b010498
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2014-01-16 12:36:56 +01:00
Laszlo Agocs
cb09f9a7fa Send the globals to new listeners
Change-Id: I8d2a74cdc305fb086f3b5c63d0abe4c46c40bbde
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2014-01-16 09:59:23 +01:00
Tomasz Olszak
3a2ece17c3 Don't flushWindowSystemEvents in QWaylandWindow ctor.
tests/auto/gui/kernel/qbackingstore test crashed because the
flush in QWaylandWindow::setWindowState invoked backing store
expose event handling which in turn tried to use related
(not yet created) QWaylandWindow.

Change-Id: Ic9f29cc3433e6e671deb756aebe26530ebc72042
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-01-15 15:11:35 +01:00
Jorgen Lind
60fd8b1612 Fixup the brcm-egl hardware integrations
Change-Id: I2a25c7d0b5019c30f31cba1f608a8731be6b1f10
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-01-15 15:11:35 +01:00
Laszlo Agocs
67f9cef815 Fix build without xkbcommon
Change-Id: If6f0c5e14cea659a42dc0ba10c05356a5703ba14
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2014-01-15 12:28:57 +01:00
Jorgen Lind
003db66339 Make the glx backend compile again
Still needs some renaming and verification, but this makes it compile at least

Change-Id: Ifb7fc68e8705f235bf0edf2ae9bb38274b693d3c
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-01-10 11:00:00 +01:00
Jorgen Lind
61fda8f967 Fixup plugin interface versioning
Change-Id: Ia4ab692fde0dee9224c9c0e3204cfee56144b50f
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-01-10 10:48:43 +01:00
Giulio Camuffo
1c72063150 Destroy the input wayland objects
They are not automatically destroyed by the compositor when the seat
loses them.

Change-Id: I72d45d664948afb4b39f137c91870f21d26dcb4a
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-01-10 10:27:54 +01:00
Jorgen Lind
fec78c702d Include wayland-client with < and not "
Change-Id: Ida61437bb76c81ee2af57856d9be9694e2fdb4a4
Reviewed-by: Andrew Knight <andrew.knight@digia.com>
2014-01-09 14:18:50 +01:00
Jorgen Lind
78e1b8d06d Adjust the serverbufferintegrations to use bind texture api
It mapps closer to the underlying OpenGL architecture

Change-Id: I4e0dca4d54670846488c86df2a0fa0c58d49734d
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-01-09 12:25:11 +01:00
Robin Burchell
eef4e25962 Use xkb, not X11 for symbol defines.
Change-Id: I6a6acbf83bd13d0a746dc65f560ace3e485ebb38
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2014-01-08 14:36:22 +01:00
Giulio Camuffo
1f8631a1b1 Move the code for seat's keyboard, pointer and touch in different classes
This allows to remove the keyboard, pointer or touch objects when the wl_seat
advertizes it is gone.
Also fixes multiple keyboard, pointer and touch binding for the same object.

Change-Id: I878f494caf7f4ac277b6a4d24037dcecf9ff84e4
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-01-06 13:44:27 +01:00
Jorgen Lind
40aff4d33c Config test for drm_egl_server
Change-Id: Ib0ae4683374c2fd0c7386863ffb3c207605dc1e2
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-01-06 11:58:11 +01:00
Jorgen Lind
2d3a63fb52 update DrmEglServerIntegration to handle experimental 8 bit support
Change-Id: I8fa4ecf8b0848ca681f944a5fa56a4f6bb0a76be
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-01-06 10:19:53 +01:00
Jorgen Lind
d156eae3c5 Add a size to the QWaylandServerBuffer on the client side
Change-Id: I48b7d514c1231eb4bd4a30f1329a89515b497269
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2014-01-03 17:37:38 +01:00
Giulio Camuffo
6e0f6db111 Improve key auto repeat behavior.
Keep the repeat timer running when a key release is received if it
is relative to another key.
Make the repeat send the modifiers too.

Change-Id: I7438502bf50cbe60d56b14bab17aa394367406cf
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-12-30 14:29:44 +01:00
Jorgen Lind
4edf4eec32 Make classes in client private
Change-Id: Ibf400b32f78a6a0fcf0991914d2d9ad684483979
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-12-27 23:19:37 +01:00
Jorgen Lind
a1cfcb8ce8 Add drm-egl server buffer integration
Change-Id: Ib72cb43e78c068ebafa8c4e8ef1576746c7015e8
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-12-27 22:58:07 +01:00
Jorgen Lind
5ea6ff734b Add wl_display and server_buffer_integration to the native interface
This is because the platform plugin name might not be wayland but we
need a way to figure out that the platform plugin has at least the
wl_display

Change-Id: I0c88f153fd71d77dc703b4e69199b1b3d19ba013
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-12-27 22:37:38 +01:00
Jorgen Lind
151d530b44 update server buffer interfaces
Change-Id: Ifc10b17deedc800167f3d03b2e4437e6b702ffa5
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-12-27 22:37:38 +01:00
Jorgen Lind
36ef74965d QtWaylandScanner: add server api for specifically creating new objects
Its no that obvious I think that setting the id == 0 when ading a
resource is the right thing to do

This commit can potentially break a CI build since it will not force a
regeneration of the generated headers, but the "local" cpp files will
use the updated header interface. To fix this clean the QtCompositor
and the QtWaylandClient include directories in QtBase

Change-Id: I32db799dfe338f38c3941eeeb22dd91ed0c7e77d
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-12-27 22:37:38 +01:00
Jorgen Lind
a719dbfe80 Use QScopedPointer in QWaylandDisplay for extensions
Change-Id: I783639fcefd36967f42f18417b0e07ec34b49dbb
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-12-27 22:17:11 +01:00
Jorgen Lind
d44fe6a530 Add hardware integration protocol
This sends to clients what HW integration is being used in the
compositor. This is useful when the wayland clients are loading their
buffer integrations with plugins since they then can pick the correct
plugin automatically.

Change-Id: Ib4eac3b855c6772ac1581b7f06aa929aeb1a1db0
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-12-27 21:39:45 +01:00
Jorgen Lind
34720a996f Add a preprocessor protocol name variable
We should convert - to _ in the preprocessor protocol name since - will
lead to a new token, but we don't since it is better to fail early here
and the official wayland-scanner doesn't do this either. The generated
c++ header will give a compiler error when being used which gives the
user a chance to change the protocol name.

Change-Id: I049bdecacc8ed9a70c0879494d4d358ce53f3320
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-12-27 21:39:45 +01:00
Jorgen Lind
e36edb655f Fix compiler warnings
Change-Id: I499c50c901bff1c496b05b628f8155376b5af267
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-12-27 21:19:19 +01:00
Jorgen Lind
e6f5c22e4e Remove compiler warning qtwaylandscanner
We don't need the interface name anymore

Change-Id: I8b1d334a549adb388da083dd8f4261755a54ff20
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-12-27 21:19:19 +01:00
Jorgen Lind
61b25e0055 Remove stale createGLIntegration functions
They are not used anymore since QtWaylandClient supports subclassing
QWaylandIntegration

Change-Id: I847a412725c4ce06377886b44236f9793b609399
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-12-27 21:19:19 +01:00
Jorgen Lind
11b385740b Add serverbufferintegration to the qpa plugin
Change-Id: I3802ec2c2b69fa56d6a64962590ebaa7314b3eea
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-12-27 20:58:48 +01:00
Jorgen Lind
ba54fc0bb1 Remove compiler warnings in client.
Change-Id: Iedd2e53aa8d6c8d09272175e402e64bdb40acb36
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-12-27 15:32:57 +01:00
Jorgen Lind
6a33e75b8d introduce HW integrations client plugins
Change-Id: I07bdcf8db16741291b88084f045ae7b93a89b63f
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-12-27 15:32:53 +01:00
Jorgen Lind
49eb590a92 Change constructor of QWaylandClientBufferIntegration
For QWaylandClientBufferIntegrations to be loadable from plugins the
constructor shold not take any arguments, but give the display in
the initialize function

Change-Id: Ie38555120d7f29c6ba7eef0f095837235782684d
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-12-27 15:32:48 +01:00
Jorgen Lind
4875f1d1bb Rename QWaylandGLIntegration to QWaylandClientBufferIntegration
also add a factory to load QWaylandClientBufferIntegrationPlugins

Change-Id: Ia6a03627659b0452439ae664fceef21eaf0f6de0
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-12-27 15:32:43 +01:00
Jorgen Lind
778b009d53 Add server buffer extension
Change-Id: I69b8f59eecf807179e5962e111f7096a6dfbd797
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-12-27 15:32:39 +01:00
Jorgen Lind
310045c930 make compositor build with new directory layout
Change-Id: I3ede73420af9cb95820a9bec4fe7305f1107e22d
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-12-27 15:32:32 +01:00
Jorgen Lind
6000c4af02 Move to new hardware structure for the platform plugins
Change-Id: I0d383e4cdd59c4e4eae5506c814f0c80ecbf58ae
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-12-27 15:32:28 +01:00
Jorgen Lind
e9613ce5b7 Use the instealled headers in the public headers for client
and use the install generated headers feature for wayland-scanner

Change-Id: I6cba9f02f8739ef5fbeeb171582e6d766d9c0fdb
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-12-27 15:32:25 +01:00
Jorgen Lind
0984830c33 Move wayland into a client directory not under the plugins src folder
And make wayland common files into a library, exporting all classes. Now
there is no need to do bulild hacks to make your own version of the
wayland plugin.

Change-Id: Ib4872863dfb5ab3f2bc0f4a94ae16fc1e7b63b88
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-12-27 15:32:17 +01:00
Jorgen Lind
b89c7f238f Make it possible to install the generated headers
Adding a header_path parameter. This will cause the scanner to generate
header includes that look for corresponding files in that path.

Also when we'r installing files, then c++ classes needs to be exported

Change-Id: Ic539c0861143d7200b9cae85ca902a17ea0d0a8d
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-12-24 11:50:43 +01:00
Andrew Knight
abd018c8b2 QtCompositor: Make ExtensionFlags a QFlags
This simplifies the creation and use of ExtensionFlags.

Change-Id: Ia72bbc3f712759b231d8543a4f13ef2fdf6260f3
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2013-12-16 15:19:33 +01:00
Andrew den Exter
de783b953a QtCompositor: Allow key events to be delivered to unfocused windows
Adds an overload to QWaylandInput::sendFullKeyEvent which allows
specifying the surface to deliver the event to. This also extends
the Qt keyboard extension to allow sending keys to specific windows.

Change-Id: I1b7abdc4d8a30392ef2e7ee5e9af5b3036b23577
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2013-12-16 12:51:12 +01:00
Andrew den Exter
3908c0aa0d QtCompositor: Allow key events to be delivered to unfocused windows
Adds an overload to QWaylandInput::sendFullKeyEvent which allows
specifying the surface to deliver the event to. This also extends
the Qt keyboard extension to allow sending keys to specific windows.

Change-Id: I1b7abdc4d8a30392ef2e7ee5e9af5b3036b23577
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
2013-12-16 11:37:23 +01:00
Jan Arne Petersen
003894ecc2 Generate more useful methods for new_id requests
Change-Id: I3206bf7e0ffc99e9ec10d949f51ad043aca2548c
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2013-11-22 15:46:29 +01:00
Jan Arne Petersen
4a014e13e0 Add support for text protocol to compositor
Change-Id: Iff22ba8b10f4ae986acba416d6fbbd4cf4f722e5
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2013-11-22 15:45:54 +01:00
Jan Arne Petersen
3683b4c420 Fix creating new objects (with id == 0)
Change-Id: I2a6740d5e1a4367d2980e3fb17617c2f1cb95041
Reviewed-by: Andrew Knight <andrew.knight@digia.com>
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2013-11-22 15:45:33 +01:00
Jan Arne Petersen
7debd1b369 Bind to version 1 of an interface
Just require version 1 instead of the latest available version of an
interface for now. Explicit support for requesting a higher version
should be added still.

Change-Id: Ib1b8303191e000227e27e07b1adf837993ac3497
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2013-11-22 15:45:30 +01:00
Oswald Buddenhagen
4ebe966c03 explicitly request wayland-scanner feature
having qtbase include it for everyone is wasteful, so do it here
explicitly.

Change-Id: I9bf39a48fe3323aaa5471a638760ac61a61de683
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2013-10-21 21:22:05 +02:00
Andrew Knight
a29f1c0547 Compositor: add BypassWindowManager hint to WindowFlags
BypassWindowManagerHint is already being used on the client-side, and it
would be beneficial for some compositors to see this server-side as well.

Change-Id: I4801a0c2f14f86fcd48cc49c3f2324af4216fb6f
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-09-20 10:53:01 +02:00
Jan Arne Petersen
795974e724 Fix scanner to support also hex values in enums
Read the value of an enum entry as a QByteArray. There is not any
need to convert it into an int in between.

Change-Id: Ie75d30dc22f7e81ddcff64990e3c6f030f31ef79
Reviewed-by: Andrew Knight <andrew.knight@digia.com>
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-08-28 12:55:52 +02:00
Jan Arne Petersen
988785c857 Use QMultiMap instead of wl_list for resources
Change generated code in qtwaylandscanner to generate resourceMap()
methods returning a QMultiMap<wl_client*, Resource*>. Adapt code using
resource lists to use the map instead.

Remove Compositor::resourceForSurface().

Change-Id: Id41a1712f9c2477c1a1af843bba2795dd90391e5
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
Reviewed-by: Andrew Knight <andrew.knight@digia.com>
2013-08-28 12:55:38 +02:00
Andrew Knight
570df4082d qtwaylandscanner: fix binding delegate to track resources
Global extension objects created with qtwaylandscanner may need to track
their child resource list. This ensures bound objects are added to that
list.

Change-Id: I2875d84d2108ddad664c52ed1a11173312ff1b04
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-08-22 16:42:43 +02:00
Jan Arne Petersen
7aba6b21cd Do not create unused code with qtwaylandscanner
We do not use foreign wl_resource handles in the server code anymore.
Remove support for it from the generated code in qtwaylandscanner.

Change-Id: Id45235ceb4282db02858749c0bef04278be7322d
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-08-22 13:26:35 +02:00
Jan Arne Petersen
13ab2c15d4 Make test compile with Wayland 1.2
Tests still fail when running like before.

Change-Id: I9c0a5e8068fa7af7abc0018e6e9c4f08aa39533b
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-08-22 11:51:49 +02:00
Morten Johan Sorvig
02305555ca Make qtwaylandscanner generate correct interface versions.
Change-Id: I3e74b00c10a11fb60261e883cbcf25aa6d4589c2
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-08-22 10:48:52 +02:00
Jan Arne Petersen
8e4d666a6b Fix uninitialized value in generated code
Change-Id: Ied932604de63072cc3b5614c84c8ec34fd94c891
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-08-08 11:38:12 +02:00
Jan Arne Petersen
cf1775b464 Fix double frees in Wayland 1.2
Remove double frees in destroy_func generated by qwaylandscanner. The
wl_resource struct is already freed by wl_resource_destroy() in
wayland-server in Wayland 1.2.

Change-Id: Ibd42e42a23238ba9c665a7c918f9b547968f7146
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-08-06 14:08:23 +02:00
Robin Burchell
4e68516aa5 Implement QPlatformWindow::raise() in QWaylandWindow and relay it to the compositor
Change-Id: I744f9799730810e4afc73f86487a34aa0fd8405b
Done-with: Vesa Halttunen <vesa.halttunen@jollamobile.com>
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Andrew Knight <andrew.knight@digia.com>
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-08-06 13:18:50 +02:00
Jørgen Lind
ed089d9b7a Update tests so that it does not deadlock
still failes though

Change-Id: I7978c752b02f32a2e2c587c0ad674c51c5e0ad22
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-08-02 14:45:21 +02:00
Oswald Buddenhagen
9c4036ce6a fix namespaced build
rule 1: QT_USE_NAMESPACE in qt code itself is a bad idea
rule 2: don't forget to forward-declare your non-qt types

Change-Id: Ifba69328f3451e708c26624f349485e7c61d31f5
Reviewed-by: Jan Arne Petersen <jan.petersen@kdab.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
2013-07-23 08:38:19 +02:00
Andrew Knight
7d94b055bf Wayland compositor: only include Qt's generated protocol headers
The system may come with conflicting headers generated by wayland-scanner.

Change-Id: I1aef7e32683ab02d0712ee65970f010a86854e43
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2013-06-28 16:07:11 +02:00
Jørgen Lind
3d91a472fc Add close event to the surface extension
Change-Id: Iacbd83d5551b3a5c2152ff80bb0085ce3f853306
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
2013-06-06 10:52:16 +02:00
Jørgen Lind
11d5c5fda4 Remove the unsecure security protocol extensions
Change-Id: I99a5f964520f801070744ca73df394e1107f3dbf
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
2013-05-22 14:44:52 +02:00
Jørgen Lind
56688a228d Namespace Qt extensions qt_ instead of wl_
Change-Id: I6882f1747fa42b11e795252cba169f65e2fe08e5
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
2013-05-22 14:39:02 +02:00
Jørgen Lind
7e4adbb7a5 Update to 1.1
Change-Id: Iab806693d2ee940c29b5d0dcc08a7b1e88bcd97f
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
2013-05-21 16:16:50 +02:00
Samuel Rødal
fdaf8642fc Adapted Surface and Region to use the qtwaylandscanner.
This requires some slight additions to the qtwaylandscanner to handle
the pattern of the wl_resource not being owned by the generated class.

Change-Id: Ia49c8129cee3a203ca9a727e83fafd3dfc653e75
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2013-04-23 14:18:36 +02:00
Samuel Rødal
f16ae84d4c Adapted code to use qtwaylandscanner.
We include the wayland.xml since we need to generate bindings for the
core protocol as well.

Also, WAYLANDSOURCES has been split into WAYLANDSERVERSOURCES and
WAYLANDCLIENTSOURCES since we need to produce different output in the
server and client cases.

Change-Id: I0bd493d41ca6b26dfd2d9b1463d4b762786537f9
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2013-04-17 09:39:21 +02:00
Samuel Rødal
2ba715bbfd Introduced qtwaylandscanner.
Generates C++ headers with Qt types based on the Wayland XML protocol files,
to reduce a lot of code duplication in all the places that interface between
Qt and the wayland protocol headers.

Change-Id: I34a4417d3d3d0238de2f2f74986855d097b50ec9
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2013-04-17 09:30:31 +02:00
Andy Nichols
e4726ae8ac Qt-ify the QtCompositor module
Currently the QtCompositor library and API do not follow the Qt API
naming conventions.  This commit intends to fix these inconsistencies.

filenames start with q
headers containing private API's end in _p
public API classes begin with Q
use the qt namespace macros where necessary

Wayland namespace is now QtWayland
wayland_wrapper classes are now private API's

It's important to make these changes not just for stylistic reasons, but
also because when qmake builds the module in checks for these
conventions to determine how to deploy the include files.

Change-Id: I8bfadeceda92a0f52cb73c704551da75540e7587
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
2013-02-08 12:34:56 +01:00
Samuel Rødal
223130c2c1 Cleaned out usages of removed or to be removed APIs.
Change-Id: Iabbada23d010ac0fdf99f88af3f109f94814b5ea
Reviewed-by: Jørgen Lind <jorgen.lind@gmail.com>
2012-12-06 20:23:32 +01:00
Andy Nichols
59c86ce6bf Cleanup QtWayland module
Now that both xkbcommon 0.2.0 and libWayland 1.0.0 have been
released, we should no longer be building against sha1's and
should be preparing for an eventual release so these build hints
have been removed.

A test has been added for libWayland 1.0.0 which is required to
build QtWayland.

README has been updated to reflect the current situation

src/3rdparty has been removed as it has not been used in some time.

patches folder and contents have been removed as they are no longer
needed.

extensions folder has been moved to the src folder

Change-Id: Iab79b5c164758a4bd0253c90f60b2a2d044e2785
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
2012-12-03 09:50:54 +01:00
Iikka Eklund
2d85b884ec Change copyrights from Nokia to Digia
Change copyrights and license headers from Nokia to Digia

Change-Id: Ie65cbe0c622780d2f0672bce19d267d1167620ff
Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
Reviewed-by: Jørgen Lind <jorgen.lind@gmail.com>
2012-09-25 13:41:54 +02:00
Jorgen Lind
86d6f4a4fd Update Wayland SHA
Change-Id: I3a0adb4b935282b9bb421a87dc8241d6ea8271f0
Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com>
2012-08-17 13:08:30 +02:00
Jorgen Lind
36de23840d Compile fixes
Change-Id: Ie532b5cd87dbcb9546b23c2ce7d013137933fbb8
Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com>
2012-08-13 10:25:37 +02:00
Donald Carr
3ae7c408f9 Introduce standard pkg-config usage
Use our own qualified pkg-config mkspec feature rather than directly
executing the system binary

Change-Id: I4b162cd8d2d9a8bd5d0b3adb9ca935df9ff96a69
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
2012-06-11 12:57:00 +02:00
Laszlo Agocs
ab9a05f213 Migrate from wl_input_device to wl_seat
Change-Id: I0d218c32478c2acce4d7012bdb26b0cde50ee633
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
2012-05-20 16:13:02 +02:00
Samuel Rødal
5e002bc961 Implemented refresh rate support.
Implements QWaylandScreen::refreshRate() based on the wl_output mode
information we get from the compositor.

In the compositor, adds API to override the refresh rate, with the
default set to whatever QScreen reports on the compositor-side.

Change-Id: I5f5175f2498940875c6ec68d29d25cf5993a1e65
Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com>
2012-05-09 14:32:00 +02:00
Laszlo Agocs
837edd2e78 Start using the new wl_fixed_t type properly
The mouse and touch coordinates cannot just be treated as integers
anymore, they need to be converted from/to double using the helper
functions. Some necessary QPoint -> QPointF changes have also been
made.

For the Qt-specific touch extension we will not switch to wl_fixed_t
though. This is because the precision is unfortunately quite small
(factor of 256 vs. 10000).

Change-Id: I23deaaffe478a39495b12d336985bc62e38a6af4
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
2012-05-09 14:17:07 +02:00
Laszlo Agocs
66e41e57a8 Update to wayland head
Change-Id: Ie012861bc40e3bc448d85c9d8c27f798434020ed
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
2012-05-09 09:12:45 +02:00
Thiago Macieira
98c1cf6b4b Change uses of {to,from}Ascii to {to,from}Latin1
This operation should be a no-op anyway, since at this point in time,
the fromAscii and toAscii functions simply call their fromLatin1 and
toLatin1 counterparts.

Task-number: QTBUG-21872
Change-Id: I70205b0d86451d31e81a4be4a521e454e1eff83f
Reviewed-by: Paul Olav Tvete <paul.tvete@nokia.com>
2012-05-04 13:35:55 +02:00
Hannu Lyytinen
d4884fa940 Sync up with the latest wayland developments.
This commit makes the qtwayland module compatible with
wayland sha1 677c5180e67be18b7a0867fafb7f205b57a6e9ff.

Change-Id: I5af0510034b7e4a038313b80f1f6e0b18fa48eb3
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
2012-04-19 09:10:18 +02:00
Jørgen Lind
e009b62037 Update wayland_sha1 and implement buffer_pool interface
Change-Id: I0628a7655a6deb061a5d0b6c6304c89d8655cf11
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
2012-04-10 18:54:33 +02:00
Andy Nichols
fa72d60dbe Fixed mockshell error in client auto test
Change-Id: Ibcb6bd807d281fbc14c35c98f4dabd4d7f82077b
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
2012-03-30 15:27:00 +02:00
Jørgen Lind
c0b041ce05 Make the module not depend on QtBase configure
This is convenient if we want to reconfigure without reconfiguring
QtBase.

Change-Id: I719ba0d89905287a557e962ed6d804514e44b7f5
Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com>
2012-03-12 12:00:28 +01:00
Samuel Rødal
d862ff8c7f Added missing header for client autotest.
Change-Id: Iabfaf1b570be7a2082f15fc25d5e715a9613b4d7
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
2012-03-12 08:59:10 +01:00
Samuel Rødal
621af3b836 Added testing of QBackingStore backend in wayland plugin.
Change-Id: I4db26cbee88f329a926914ff878e6efa9b0c8395
Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com>
2012-03-07 15:51:39 +01:00
Samuel Rødal
54331754cb Added testing of key events to client auto test.
This requires passing on the native key code as well when calling into
QWindowSystemInterface from QWaylandInputDevice.

Change-Id: Iea1f98dcc9e050bb42cc48927da17aa54085a5e8
Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com>
2012-03-07 11:04:45 +01:00
Samuel Rødal
8feb960ff8 Added auto-test for wayland plugin.
Similar to the compositor auto-test, except this time we mock the
compositor, and test the client code, by forcing the wayland plugin to
be used.

Change-Id: I363019ff7e136db6822993f1881fec48a02a7db4
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
2012-03-07 09:06:52 +01:00
Jason McDonald
b3da8baef1 Remove "All rights reserved" line from license headers.
As in the past, to avoid rewriting various autotests that contain
line-number information, an extra blank line has been inserted at the
end of the license text to ensure that this commit does not change the
total number of lines in the license header.

Change-Id: I08d8673382f0230d5c5a22a25efaf5c45cef539a
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2012-01-30 06:40:14 +01:00
Jason McDonald
3192828437 Update obsolete contact address.
Replace Nokia contact email address with Qt Project website.

Change-Id: Ib67c393df41c539deae0ef71e0acc13029ceb46d
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
2012-01-23 02:58:37 +01:00
Laszlo Agocs
a46d4baad8 Implement selection offers from compositor to clients.
It is a hack but works beautifully. It allows the compositor to
participate in copy-paste which becomes mandatory when there is UI
running in the compositor process.

Change-Id: I1993d8705a26159eff0c9947244b66e954b9f460
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
2012-01-17 17:30:52 +01:00
Paul Olav Tvete
19262dae33 Remove Wayland copy, now that we have wayland_sha1.txt 2011-05-11 14:14:44 +02:00
Jørgen Lind
49adfa9d0f Update 3rd party Wayland
and reapplied e039efc63cf36ef7f521bf5570d23b9e33ec4ed6
2011-05-03 12:59:30 +02:00
Jørgen Lind
e039efc63c Dont use accept4 && SOCK_CLOEXEC 2011-04-19 09:03:33 +02:00
Jørgen Lind
6981020be6 Updating src/3rdparty/wayland to head of Wayland master
In git://anongit.freedesktop.org/wayland/wayland its sha
f04e05ad76cd6af890b7b741a9e0f5181bd0ac10
2011-04-14 10:04:50 +02:00
Jørgen Lind
7b34bad810 Adding destination directory for wayland build 2011-03-22 12:50:02 +01:00
Jørgen Lind
abb03aa734 Fix how wayland is compiled so that we can pick up libffi from
pkg-config
2011-03-22 12:50:02 +01:00
Paul Olav Tvete
e5df2dd4c5 Add the DRM protocol files
This interface was removed from Wayland, and is now the responsibility
of the EGL implementation.
2011-03-04 17:30:22 +01:00
Paul Olav Tvete
b667ca007e Update to latest Wayland version 2011-03-02 15:35:37 +01:00
Jørgen Lind
27207edfca Initial commit for the Qt-Compositor.
The project goal is to be a toolbox which all Qt based Wayland compositors use.

Initial work is done by:
Samuel Rødal <samuel.rodal@nokia.com>
Paul Olav Tvete <paul.tvete@nokia.com>
and myself
2011-03-02 13:46:19 +01:00
3208 changed files with 461635 additions and 285676 deletions

View File

@ -7,7 +7,7 @@ if (NOT DEFINED QT_SUPERBUILD OR DEFINED QT_REPO_MODULE_VERSION)
set(QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_LEAN_HEADERS=1")
endif()
set(QT_REPO_MODULE_VERSION "6.9.0")
set(QT_REPO_MODULE_VERSION "6.11.0")
set(QT_REPO_MODULE_PRERELEASE_VERSION_SEGMENT "alpha1")
set(QT_COPYRIGHT "Copyright (C) The Qt Company Ltd. and other contributors.")
@ -51,13 +51,13 @@ set(QT_MAX_NEW_POLICY_CMAKE_VERSION_QT_APPLE "3.21")
set(QT_SUPPORTED_MIN_MACOS_SDK_VERSION "14")
set(QT_SUPPORTED_MAX_MACOS_SDK_VERSION "15")
set(QT_SUPPORTED_MIN_MACOS_XCODE_VERSION "15")
set(QT_SUPPORTED_MIN_MACOS_VERSION "12")
set(QT_SUPPORTED_MIN_MACOS_VERSION "13")
set(QT_SUPPORTED_MAX_MACOS_VERSION_TESTED "15")
set(QT_SUPPORTED_MIN_IOS_SDK_VERSION "17")
set(QT_SUPPORTED_MAX_IOS_SDK_VERSION "18")
set(QT_SUPPORTED_MIN_IOS_XCODE_VERSION "15")
set(QT_SUPPORTED_MIN_IOS_VERSION "16")
set(QT_SUPPORTED_MIN_IOS_VERSION "17")
set(QT_SUPPORTED_MAX_IOS_VERSION_TESTED "18")
set(QT_SUPPORTED_MIN_VISIONOS_SDK_VERSION "1")

4
.gitreview Normal file
View File

@ -0,0 +1,4 @@
[gerrit]
host=codereview.qt-project.org
project=qt/qtbase
defaultbranch=dev

View File

@ -1,33 +0,0 @@
extraction:
cpp:
prepare:
packages:
- libgl-dev
- libglu-dev
- libpcre2-dev
- libz-dev
- libfreetype6-dev
- libpng-dev
- libjpeg-dev
- libsqlite3-dev
after_prepare:
- mkdir $HOME/cmake-3.17 \
\ && wget -qO- "https://cmake.org/files/v3.17/cmake-3.17.3-Linux-x86_64.tar.gz" \
\ | tar -xzf - --strip-components=1 -C $HOME/cmake-3.17
- export PATH=$HOME/cmake-3.17/bin:$PATH
# Pre-analysis step.
configure:
command:
- "./configure -cmake -opensource -confirm-license -debug -no-pch \
\ -nomake tests -nomake examples -no-harfbuzz \
\ -system-pcre -system-zlib -system-freetype -system-libpng \
\ -system-libjpeg -system-sqlite"
# We skip analyzing the bootstrap library, since the same code is
# built with non-standard flags and false-positives are flagged.
- ninja bootstrap_tools
# Actual analysis.
index:
build_command:
- ninja

View File

@ -24,9 +24,13 @@ project(QtBase
VERSION "${QT_REPO_MODULE_VERSION}"
DESCRIPTION "Qt Base Libraries"
HOMEPAGE_URL "https://qt.io/"
LANGUAGES CXX C ASM
LANGUAGES CXX C
)
if(UNIX AND NOT ANDROID)
enable_language(ASM)
endif()
set(QT_BUILD_EXTRA_IDE_FILE_PATTERNS bin/* libexec/*)
qt_internal_qtbase_build_repo()

View File

@ -0,0 +1,468 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts as the
successor of the GNU Library Public License, version 2, hence the version
number 2.1.]
Preamble
The licenses for most software are designed to take away your freedom to share
and change it. By contrast, the GNU General Public Licenses are intended to
guarantee your freedom to share and change free software--to make sure the
software is free for all its users.
This license, the Lesser General Public License, applies to some specially
designated software packages--typically libraries--of the Free Software Foundation
and other authors who decide to use it. You can use it too, but we suggest
you first think carefully about whether this license or the ordinary General
Public License is the better strategy to use in any particular case, based
on the explanations below.
When we speak of free software, we are referring to freedom of use, not price.
Our General Public Licenses are designed to make sure that you have the freedom
to distribute copies of free software (and charge for this service if you
wish); that you receive source code or can get it if you want it; that you
can change the software and use pieces of it in new free programs; and that
you are informed that you can do these things.
To protect your rights, we need to make restrictions that forbid distributors
to deny you these rights or to ask you to surrender these rights. These restrictions
translate to certain responsibilities for you if you distribute copies of
the library or if you modify it.
For example, if you distribute copies of the library, whether gratis or for
a fee, you must give the recipients all the rights that we gave you. You must
make sure that they, too, receive or can get the source code. If you link
other code with the library, you must provide complete object files to the
recipients, so that they can relink them with the library after making changes
to the library and recompiling it. And you must show them these terms so they
know their rights.
We protect your rights with a two-step method: (1) we copyright the library,
and (2) we offer you this license, which gives you legal permission to copy,
distribute and/or modify the library.
To protect each distributor, we want to make it very clear that there is no
warranty for the free library. Also, if the library is modified by someone
else and passed on, the recipients should know that what they have is not
the original version, so that the original author's reputation will not be
affected by problems that might be introduced by others.
Finally, software patents pose a constant threat to the existence of any free
program. We wish to make sure that a company cannot effectively restrict the
users of a free program by obtaining a restrictive license from a patent holder.
Therefore, we insist that any patent license obtained for a version of the
library must be consistent with the full freedom of use specified in this
license.
Most GNU software, including some libraries, is covered by the ordinary GNU
General Public License. This license, the GNU Lesser General Public License,
applies to certain designated libraries, and is quite different from the ordinary
General Public License. We use this license for certain libraries in order
to permit linking those libraries into non-free programs.
When a program is linked with a library, whether statically or using a shared
library, the combination of the two is legally speaking a combined work, a
derivative of the original library. The ordinary General Public License therefore
permits such linking only if the entire combination fits its criteria of freedom.
The Lesser General Public License permits more lax criteria for linking other
code with the library.
We call this license the "Lesser" General Public License because it does Less
to protect the user's freedom than the ordinary General Public License. It
also provides other free software developers Less of an advantage over competing
non-free programs. These disadvantages are the reason we use the ordinary
General Public License for many libraries. However, the Lesser license provides
advantages in certain special circumstances.
For example, on rare occasions, there may be a special need to encourage the
widest possible use of a certain library, so that it becomes a de-facto standard.
To achieve this, non-free programs must be allowed to use the library. A more
frequent case is that a free library does the same job as widely used non-free
libraries. In this case, there is little to gain by limiting the free library
to free software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free programs
enables a greater number of people to use a large body of free software. For
example, permission to use the GNU C Library in non-free programs enables
many more people to use the whole GNU operating system, as well as its variant,
the GNU/Linux operating system.
Although the Lesser General Public License is Less protective of the users'
freedom, it does ensure that the user of a program that is linked with the
Library has the freedom and the wherewithal to run that program using a modified
version of the Library.
The precise terms and conditions for copying, distribution and modification
follow. Pay close attention to the difference between a "work based on the
library" and a "work that uses the library". The former contains code derived
from the library, whereas the latter must be combined with the library in
order to run.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other program
which contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Lesser General
Public License (also called "this License"). Each licensee is addressed as
"you".
A "library" means a collection of software functions and/or data prepared
so as to be conveniently linked with application programs (which use some
of those functions and data) to form executables.
The "Library", below, refers to any such software library or work which has
been distributed under these terms. A "work based on the Library" means either
the Library or any derivative work under copyright law: that is to say, a
work containing the Library or a portion of it, either verbatim or with modifications
and/or translated straightforwardly into another language. (Hereinafter, translation
is included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for making modifications
to it. For a library, complete source code means all the source code for all
modules it contains, plus any associated interface definition files, plus
the scripts used to control compilation and installation of the library.
Activities other than copying, distribution and modification are not covered
by this License; they are outside its scope. The act of running a program
using the Library is not restricted, and output from such a program is covered
only if its contents constitute a work based on the Library (independent of
the use of the Library in a tool for writing it). Whether that is true depends
on what the Library does and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's complete source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and disclaimer
of warranty; keep intact all the notices that refer to this License and to
the absence of any warranty; and distribute a copy of this License along with
the Library.
You may charge a fee for the physical act of transferring a copy, and you
may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Library or any portion of it,
thus forming a work based on the Library, and copy and distribute such modifications
or work under the terms of Section 1 above, provided that you also meet all
of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices stating that
you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no charge to all
third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a table of
data to be supplied by an application program that uses the facility, other
than as an argument passed when the facility is invoked, then you must make
a good faith effort to ensure that, in the event an application does not supply
such function or table, the facility still operates, and performs whatever
part of its purpose remains meaningful.
(For example, a function in a library to compute square roots has a purpose
that is entirely well-defined independent of the application. Therefore, Subsection
2d requires that any application-supplied function or table used by this function
must be optional: if the application does not supply it, the square root function
must still compute square roots.)
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Library, and can be reasonably
considered independent and separate works in themselves, then this License,
and its terms, do not apply to those sections when you distribute them as
separate works. But when you distribute the same sections as part of a whole
which is a work based on the Library, the distribution of the whole must be
on the terms of this License, whose permissions for other licensees extend
to the entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest your
rights to work written entirely by you; rather, the intent is to exercise
the right to control the distribution of derivative or collective works based
on the Library.
In addition, mere aggregation of another work not based on the Library with
the Library (or with a work based on the Library) on a volume of a storage
or distribution medium does not bring the other work under the scope of this
License.
3. You may opt to apply the terms of the ordinary GNU General Public License
instead of this License to a given copy of the Library. To do this, you must
alter all the notices that refer to this License, so that they refer to the
ordinary GNU General Public License, version 2, instead of to this License.
(If a newer version than version 2 of the ordinary GNU General Public License
has appeared, then you can specify that version instead if you wish.) Do not
make any other change in these notices.
Once this change is made in a given copy, it is irreversible for that copy,
so the ordinary GNU General Public License applies to all subsequent copies
and derivative works made from that copy.
This option is useful when you wish to copy part of the code of the Library
into a program that is not a library.
4. You may copy and distribute the Library (or a portion or derivative of
it, under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you accompany it with the complete corresponding
machine-readable source code, which must be distributed under the terms of
Sections 1 and 2 above on a medium customarily used for software interchange.
If distribution of object code is made by offering access to copy from a designated
place, then offering equivalent access to copy the source code from the same
place satisfies the requirement to distribute the source code, even though
third parties are not compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the Library, but
is designed to work with the Library by being compiled or linked with it,
is called a "work that uses the Library". Such a work, in isolation, is not
a derivative work of the Library, and therefore falls outside the scope of
this License.
However, linking a "work that uses the Library" with the Library creates an
executable that is a derivative of the Library (because it contains portions
of the Library), rather than a "work that uses the library". The executable
is therefore covered by this License. Section 6 states terms for distribution
of such executables.
When a "work that uses the Library" uses material from a header file that
is part of the Library, the object code for the work may be a derivative work
of the Library even though the source code is not. Whether this is true is
especially significant if the work can be linked without the Library, or if
the work is itself a library. The threshold for this to be true is not precisely
defined by law.
If such an object file uses only numerical parameters, data structure layouts
and accessors, and small macros and small inline functions (ten lines or less
in length), then the use of the object file is unrestricted, regardless of
whether it is legally a derivative work. (Executables containing this object
code plus portions of the Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may distribute
the object code for the work under the terms of Section 6. Any executables
containing that work also fall under Section 6, whether or not they are linked
directly with the Library itself.
6. As an exception to the Sections above, you may also combine or link a "work
that uses the Library" with the Library to produce a work containing portions
of the Library, and distribute that work under terms of your choice, provided
that the terms permit modification of the work for the customer's own use
and reverse engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the Library
is used in it and that the Library and its use are covered by this License.
You must supply a copy of this License. If the work during execution displays
copyright notices, you must include the copyright notice for the Library among
them, as well as a reference directing the user to the copy of this License.
Also, you must do one of these things:
a) Accompany the work with the complete corresponding machine-readable source
code for the Library including whatever changes were used in the work (which
must be distributed under Sections 1 and 2 above); and, if the work is an
executable linked with the Library, with the complete machine-readable "work
that uses the Library", as object code and/or source code, so that the user
can modify the Library and then relink to produce a modified executable containing
the modified Library. (It is understood that the user who changes the contents
of definitions files in the Library will not necessarily be able to recompile
the application to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the Library. A
suitable mechanism is one that (1) uses at run time a copy of the library
already present on the user's computer system, rather than copying library
functions into the executable, and (2) will operate properly with a modified
version of the library, if the user installs one, as long as the modified
version is interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at least three years,
to give the same user the materials specified in Subsection 6a, above, for
a charge no more than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy from a designated
place, offer equivalent access to copy the above specified materials from
the same place.
e) Verify that the user has already received a copy of these materials or
that you have already sent this user a copy.
For an executable, the required form of the "work that uses the Library" must
include any data and utility programs needed for reproducing the executable
from it. However, as a special exception, the materials to be distributed
need not include anything that is normally distributed (in either source or
binary form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component itself
accompanies the executable.
It may happen that this requirement contradicts the license restrictions of
other proprietary libraries that do not normally accompany the operating system.
Such a contradiction means you cannot use both them and the Library together
in an executable that you distribute.
7. You may place library facilities that are a work based on the Library side-by-side
in a single library together with other library facilities not covered by
this License, and distribute such a combined library, provided that the separate
distribution of the work based on the Library and of the other library facilities
is otherwise permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work based on the
Library, uncombined with any other library facilities. This must be distributed
under the terms of the Sections above.
b) Give prominent notice with the combined library of the fact that part of
it is a work based on the Library, and explaining where to find the accompanying
uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute the Library
except as expressly provided under this License. Any attempt otherwise to
copy, modify, sublicense, link with, or distribute the Library is void, and
will automatically terminate your rights under this License. However, parties
who have received copies, or rights, from you under this License will not
have their licenses terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not signed
it. However, nothing else grants you permission to modify or distribute the
Library or its derivative works. These actions are prohibited by law if you
do not accept this License. Therefore, by modifying or distributing the Library
(or any work based on the Library), you indicate your acceptance of this License
to do so, and all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the Library),
the recipient automatically receives a license from the original licensor
to copy, distribute, link with or modify the Library subject to these terms
and conditions. You may not impose any further restrictions on the recipients'
exercise of the rights granted herein. You are not responsible for enforcing
compliance by third parties with this License.
11. If, as a consequence of a court judgment or allegation of patent infringement
or for any other reason (not limited to patent issues), conditions are imposed
on you (whether by court order, agreement or otherwise) that contradict the
conditions of this License, they do not excuse you from the conditions of
this License. If you cannot distribute so as to satisfy simultaneously your
obligations under this License and any other pertinent obligations, then as
a consequence you may not distribute the Library at all. For example, if a
patent license would not permit royalty-free redistribution of the Library
by all those who receive copies directly or indirectly through you, then the
only way you could satisfy both it and this License would be to refrain entirely
from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents
or other property right claims or to contest validity of any such claims;
this section has the sole purpose of protecting the integrity of the free
software distribution system which is implemented by public license practices.
Many people have made generous contributions to the wide range of software
distributed through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing to
distribute software through any other system and a licensee cannot impose
that choice.
This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in certain
countries either by patents or by copyrighted interfaces, the original copyright
holder who places the Library under this License may add an explicit geographical
distribution limitation excluding those countries, so that distribution is
permitted only in or among countries not thus excluded. In such case, this
License incorporates the limitation as if written in the body of this License.
13. The Free Software Foundation may publish revised and/or new versions of
the Lesser General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to address
new problems or concerns.
Each version is given a distinguishing version number. If the Library specifies
a version number of this License which applies to it and "any later version",
you have the option of following the terms and conditions either of that version
or of any later version published by the Free Software Foundation. If the
Library does not specify a license version number, you may choose any version
ever published by the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free programs
whose distribution conditions are incompatible with these, write to the author
to ask for permission. For software which is copyrighted by the Free Software
Foundation, write to the Free Software Foundation; we sometimes make exceptions
for this. Our decision will be guided by the two goals of preserving the free
status of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest possible
use to the public, we recommend making it free software that everyone can
redistribute and change. You can do so by permitting redistribution under
these terms (or, alternatively, under the terms of the ordinary General Public
License).
To apply these terms, attach the following notices to the library. It is safest
to attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the "copyright"
line and a pointer to where the full notice is found.
<one line to give the library's name and an idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at your option)
any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along
with this library; if not, write to the Free Software Foundation, Inc., 51
Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your school,
if any, to sign a "copyright disclaimer" for the library, if necessary. Here
is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in
the library `Frob' (a library for tweaking knobs) written
by James Random Hacker.
< signature of Ty Coon > , 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@ -24,9 +24,9 @@ SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR GPL-3.0-only"
path = ["bin/*", "coin/**","libexec/*","**_clang-format", "**.cmake", "**.conf", "**.cmake.in",
"**.prf", "libexec/qt-internal-configure-*", "config.tests/.qmake.conf",
"**.pro", "**.pri", "**.yaml", "cmake/**.in", "cmake/ios/LaunchScreen.storyboard",
"cmake/**md", "**.yml", "**.dynlist",
"cmake/**md", "**.yml", "**.dynlist", "cmake/**.plist",
"src/corelib/global/qconfig.cpp.in", "src/corelib/Qt6CoreConfigureFileTemplate.in",
"**.cfg"]
"**.cfg", "**/Makefile", "**/CMakeLists.txt", "**.qrc", ".tag"]
precedence = "closest"
comment = "build system"
SPDX-FileCopyrightText = "Copyright (C) 2024 The Qt Company Ltd."
@ -39,29 +39,48 @@ SPDX-FileCopyrightText = "Copyright (C) 2024 The Qt Company Ltd."
SPDX-License-Identifier = "CC0-1.0"
[[annotations]]
path = [".tag", "**/.gitattributes", "**.gitignore"]
path = ["**/.gitattributes", "**.gitignore", "**.gitreview"]
precedence = "closest"
SPDX-FileCopyrightText = "Copyright (C) 2024 The Qt Company Ltd."
SPDX-License-Identifier = "BSD-3-Clause"
SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR BSD-3-Clause"
[[annotations]]
path = ["**/snippets/**", "**/doc/**/images/**", "examples/**"]
path = ["**/snippets/**", "examples/**", "src/tools/qlalr/examples/**"]
comment = "this must be after the build system table because example and snippets take precedence over build system"
precedence = "closest"
SPDX-FileCopyrightText = "Copyright (C) 2024 The Qt Company Ltd."
SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR BSD-3-Clause"
[[annotations]]
path = ["tests/manual/examples/**", "**/snippets/**"]
precedence = "closest"
SPDX-FileCopyrightText = "Copyright (C) 2024 The Qt Company Ltd."
SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR BSD-3-Clause"
[[annotations]]
path = ["**/README*", "src/plugins/**/README*", "examples/**/README*", "tests/**/README*",
"src/widgets/doc/snippets/common-table-model/README", "cmake/README.md",
"lib/README", "coin/instructions/README.md", "src/3rdparty/README",
"**.qdocconf", "**.qdocinc", "config_help.txt",
"doc/global/template/style/*"]
"doc/global/template/style/*", "**/doc/**/images/**"]
comment = "documentation"
precedence = "closest"
SPDX-FileCopyrightText = "Copyright (C) 2024 The Qt Company Ltd."
SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only"
[[annotations]]
path = ["src/corelib/global/patches/tlexpected/**", "src/corelib/global/qexpected_p.h"]
precedence = "closest"
SPDX-FileCopyrightText = "To the extent possible under law, Sy Brand has waived all copyright and related or neighboring rights to the expected library. This work is published from: United Kingdom."
SPDX-License-Identifier = "CC0-1.0"
[[annotations]]
path = ["src/gui/doc/snippets/textdocument-images/images.qrc"]
precedence = "closest"
comment = "falls under **/doc/**/images/**, which is wrong"
SPDX-FileCopyrightText = "Copyright (C) 2024 The Qt Company Ltd."
SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR BSD-3-Clause"
[[annotations]]
path = ["src/assets/icons/**.png", "src/assets/icons/**.svg", "src/android/**.xml",
"src/gui/**.xml",
@ -73,6 +92,13 @@ precedence = "closest"
SPDX-FileCopyrightText = "Copyright (C) 2024 The Qt Company Ltd."
SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only"
[[annotations]]
path = ["tests/auto/tools/rcc/data/legal/legal.qrc"]
precedence = "override"
comment = "license in file not referring to the file itself"
SPDX-FileCopyrightText = "Copyright (C) 2024 The Qt Company Ltd."
SPDX-License-Identifier = "BSD-3-Clause"
[[annotations]]
path = ["**/qt_attribution.json"]
precedence = "override"
@ -83,7 +109,7 @@ SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-on
path = ["**.toml", "licenseRule.json"]
precedence = "override"
SPDX-FileCopyrightText = "Copyright (C) 2024 The Qt Company Ltd."
SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only"
SPDX-License-Identifier = "LicenseRef-Qt-Commercial OR BSD-3-Clause"
[[annotations]]
path = ["**LICENSE*", "cmake/3rdparty/**/COPYING-CMAKE-SCRIPTS"]

View File

@ -0,0 +1,45 @@
From cbda7ce74d74539ce0baef4a36198081dfb0265c Mon Sep 17 00:00:00 2001
From: Marc Mutz <marc.mutz@qt.io>
Date: Fri, 14 Mar 2025 18:29:20 +0100
Subject: [PATCH] ECMEnableSanitizers.cmake: fix GCC's "note: variable tracking
size limit exceeded" when using asan
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Set the max-vartrack-size parameter to 0 (= unlimited) to avoid GCC's
"note: variable tracking size limit exceeded with
-fvar-tracking-assignments, retrying without" message you get when you
compile with asan sometimes.
This is reported¹ to speed up compilation, not slow it down.
¹ https://stackoverflow.com/a/75704837/134841
---
modules/ECMEnableSanitizers.cmake | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/modules/ECMEnableSanitizers.cmake b/modules/ECMEnableSanitizers.cmake
index 07db1c80..45236e6d 100644
--- a/modules/ECMEnableSanitizers.cmake
+++ b/modules/ECMEnableSanitizers.cmake
@@ -117,6 +117,16 @@ macro (enable_sanitizer_flags sanitize_option)
set(XSAN_COMPILE_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls")
set(XSAN_LINKER_FLAGS "asan")
endif()
+ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+ # fixes "note: variable tracking size limit exceeded with
+ # -fvar-tracking-assignments, retrying without" (which is
+ # another way of saying "I'll go ahead and compile this
+ # thing _twice_") by making it unlimited
+ # Reference:
+ # https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
+ # -> max-vartrack-size
+ string(APPEND XSAN_COMPILE_FLAGS " --param=max-vartrack-size=0")
+ endif ()
elseif (${sanitize_option} MATCHES "thread")
check_compiler_version("4.8" "3.1" "99.99")
set(XSAN_COMPILE_FLAGS "-fsanitize=thread")
--
2.25.1

View File

@ -0,0 +1,42 @@
From 8907023584ea0936893269aee890af5995746af5 Mon Sep 17 00:00:00 2001
From: Marc Mutz <marc.mutz@qt.io>
Date: Mon, 17 Mar 2025 10:15:03 +0100
Subject: [PATCH] ECMEnableSanitizers.cmake: replace tabs with spaces
Amends cbda7ce74d74539ce0baef4a36198081dfb0265c.
---
modules/ECMEnableSanitizers.cmake | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/modules/ECMEnableSanitizers.cmake b/modules/ECMEnableSanitizers.cmake
index 45236e6d..8686384d 100644
--- a/modules/ECMEnableSanitizers.cmake
+++ b/modules/ECMEnableSanitizers.cmake
@@ -118,15 +118,15 @@ macro (enable_sanitizer_flags sanitize_option)
set(XSAN_LINKER_FLAGS "asan")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
- # fixes "note: variable tracking size limit exceeded with
- # -fvar-tracking-assignments, retrying without" (which is
- # another way of saying "I'll go ahead and compile this
- # thing _twice_") by making it unlimited
- # Reference:
- # https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
- # -> max-vartrack-size
- string(APPEND XSAN_COMPILE_FLAGS " --param=max-vartrack-size=0")
- endif ()
+ # fixes "note: variable tracking size limit exceeded with
+ # -fvar-tracking-assignments, retrying without" (which is
+ # another way of saying "I'll go ahead and compile this
+ # thing _twice_") by making it unlimited
+ # Reference:
+ # https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
+ # -> max-vartrack-size
+ string(APPEND XSAN_COMPILE_FLAGS " --param=max-vartrack-size=0")
+ endif ()
elseif (${sanitize_option} MATCHES "thread")
check_compiler_version("4.8" "3.1" "99.99")
set(XSAN_COMPILE_FLAGS "-fsanitize=thread")
--
2.25.1

View File

@ -120,7 +120,7 @@ list(APPEND CMAKE_REQUIRED_LIBRARIES "${EGL_LIBRARY}")
list(APPEND CMAKE_REQUIRED_INCLUDES "${EGL_INCLUDE_DIR}")
list(APPEND CMAKE_REQUIRED_DEFINITIONS "${EGL_DEFINITIONS}")
find_package(PlatformGraphics)
find_package(PlatformGraphics QUIET)
if(TARGET PlatformGraphics::PlatformGraphics)
platform_graphics_extend_check_cxx_source_required_variables()
endif()

View File

@ -145,7 +145,7 @@ endforeach()
set(XCB_XCB_component_deps)
set(XCB_COMPOSITE_component_deps XCB XFIXES)
set(XCB_DAMAGE_component_deps XCB XFIXES)
set(XCB_IMAGE_component_deps XCB SHM)
set(XCB_IMAGE_component_deps XCB SHM AUX)
set(XCB_RENDERUTIL_component_deps XCB RENDER)
set(XCB_XFIXES_component_deps XCB RENDER SHAPE)
set(XCB_XVMC_component_deps XCB XV)

View File

@ -118,6 +118,16 @@ macro (enable_sanitizer_flags sanitize_option)
set(XSAN_COMPILE_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls")
set(XSAN_LINKER_FLAGS "asan")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
# fixes "note: variable tracking size limit exceeded with
# -fvar-tracking-assignments, retrying without" (which is
# another way of saying "I'll go ahead and compile this
# thing _twice_") by making it unlimited
# Reference:
# https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
# -> max-vartrack-size
string(APPEND XSAN_COMPILE_FLAGS " --param=max-vartrack-size=0")
endif ()
elseif (${sanitize_option} MATCHES "thread")
check_compiler_version("4.8" "3.1" "99.99")
set(XSAN_COMPILE_FLAGS "-fsanitize=thread")

View File

@ -21,25 +21,31 @@
# ``DB2::DB2``
# The db2 client library
if(NOT DEFINED DB2_ROOT)
if(DEFINED ENV{DB2_ROOT})
set(DB2_ROOT "$ENV{DB2_ROOT}")
endif()
endif()
if (NOT DEFINED DB2_INCLUDE_DIR)
find_path(DB2_INCLUDE_DIR
NAMES sqlcli1.h
HINTS ENV DB2_HOME
HINTS "${DB2_ROOT}" ENV DB2_HOME
PATH_SUFFIXES include)
else()
find_path(DB2_INCLUDE_DIR
NAMES sqlcli1.h
HINTS ${DB2_INCLUDE_DIR})
HINTS "${DB2_INCLUDE_DIR}")
endif()
if (NOT DEFINED DB2_LIBRARY_DIR)
find_library(DB2_LIBRARY
NAMES db2
HINTS ENV DB2LIB)
NAMES db2 db2cli64
HINTS "${DB2_ROOT}" ENV DB2LIB)
else()
find_library(DB2_LIBRARY
NAMES db2
HINTS ${DB2_LIBRARY_DIR})
HINTS "${DB2_LIBRARY_DIR}")
endif()
include(FindPackageHandleStandardArgs)

View File

@ -21,7 +21,7 @@ else()
set(_includes "${CMAKE_REQUIRED_INCLUDES}")
list(APPEND CMAKE_REQUIRED_INCLUDES "${GLESv2_INCLUDE_DIR}")
find_package(PlatformGraphics)
find_package(PlatformGraphics QUIET)
if(TARGET PlatformGraphics::PlatformGraphics)
platform_graphics_extend_check_cxx_source_required_variables()
endif()

10
cmake/FindJeMalloc.cmake Normal file
View File

@ -0,0 +1,10 @@
# Copyright (C) 2025 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
find_package(PkgConfig QUIET)
pkg_check_modules(JeMalloc IMPORTED_TARGET "jemalloc")
if (NOT TARGET PkgConfig::JeMalloc)
set(JeMalloc_FOUND 0)
endif()

View File

@ -37,16 +37,7 @@ if (OpenGL_FOUND)
set(__opengl_fw_path "-framework OpenGL")
endif()
find_library(WrapOpenGL_AGL NAMES AGL)
if(WrapOpenGL_AGL)
set(__opengl_agl_fw_path "${WrapOpenGL_AGL}")
endif()
if(NOT __opengl_agl_fw_path)
set(__opengl_agl_fw_path "-framework AGL")
endif()
target_link_libraries(WrapOpenGL::WrapOpenGL INTERFACE ${__opengl_fw_path})
target_link_libraries(WrapOpenGL::WrapOpenGL INTERFACE ${__opengl_agl_fw_path})
else()
target_link_libraries(WrapOpenGL::WrapOpenGL INTERFACE OpenGL::GL)
endif()

View File

@ -25,13 +25,22 @@ if(LIBRESOLV)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBRESOLV}")
endif()
cmake_policy(PUSH)
if(POLICY CMP0067)
cmake_policy(SET CMP0067 NEW)
endif()
if(DEFINED CMAKE_CXX_STANDARD)
set(_WrapResolv_CMAKE_CXX_STANDARD_back ${CMAKE_CXX_STANDARD})
endif()
set(CMAKE_CXX_STANDARD 11)
check_cxx_source_compiles("
#include <netinet/in.h>
#include <resolv.h>
int main(int, char **argv)
{
res_state statep = 0;
res_state statep = {};
int n = res_nmkquery(statep, 0, argv[1], 0, 0, NULL, 0, NULL, NULL, 0);
n = res_nsend(statep, NULL, 0, NULL, 0);
n = dn_expand(NULL, NULL, NULL, NULL, 0);
@ -39,6 +48,14 @@ int main(int, char **argv)
}
" HAVE_LIBRESOLV_FUNCTIONS)
if(DEFINED _WrapResolv_CMAKE_CXX_STANDARD_back)
set(CMAKE_CXX_STANDARD ${_WrapResolv_CMAKE_CXX_STANDARD_back})
unset(_WrapResolv_CMAKE_CXX_STANDARD_back)
else()
unset(CMAKE_CXX_STANDARD)
endif()
cmake_policy(POP)
cmake_pop_check_state()
if(HAVE_LIBRESOLV_FUNCTIONS)

View File

@ -9,6 +9,6 @@ $<1: >
Name: @pkgconfig_name@
Description: @pkgconfig_description@
Version: @PROJECT_VERSION@
Libs: $<$<NOT:@is_interface_library@>:-L${libdir} -l@pkgconfig_file@> @link_options@
Libs: @link_options@
Cflags: @include_dirs@ @compile_defs@
Requires: $<JOIN:$<REMOVE_DUPLICATES:@target_requires@>, >

View File

@ -7,9 +7,6 @@ cmake_minimum_required(VERSION @min_new_policy_version@...@max_new_policy_versio
include(CMakeFindDependencyMacro)
get_filename_component(_import_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_import_prefix "${_import_prefix}" REALPATH)
# Extra cmake code begin
@extra_cmake_code@
# Extra cmake code end

View File

@ -105,27 +105,30 @@ function(qt_internal_add_cmake_library target)
)
endif()
_qt_internal_forward_function_args(
FORWARD_PREFIX arg
FORWARD_OUT_VAR extend_target_args
FORWARD_MULTI
SOURCES
NO_PCH_SOURCES
INCLUDE_DIRECTORIES
SYSTEM_INCLUDE_DIRECTORIES
PUBLIC_INCLUDE_DIRECTORIES
PUBLIC_DEFINES
DEFINES
PUBLIC_LIBRARIES
COMPILE_OPTIONS
PUBLIC_COMPILE_OPTIONS
LINK_OPTIONS
PUBLIC_LINK_OPTIONS
MOC_OPTIONS
ENABLE_AUTOGEN_TOOLS
DISABLE_AUTOGEN_TOOLS
)
qt_internal_extend_target("${target}"
SOURCES ${arg_SOURCES}
INCLUDE_DIRECTORIES
${arg_INCLUDE_DIRECTORIES}
SYSTEM_INCLUDE_DIRECTORIES
${arg_SYSTEM_INCLUDE_DIRECTORIES}
PUBLIC_INCLUDE_DIRECTORIES
${arg_PUBLIC_INCLUDE_DIRECTORIES}
PUBLIC_DEFINES
${arg_PUBLIC_DEFINES}
DEFINES
${arg_DEFINES}
PUBLIC_LIBRARIES ${arg_PUBLIC_LIBRARIES}
${extend_target_args}
LIBRARIES ${arg_LIBRARIES} Qt::PlatformCommonInternal
COMPILE_OPTIONS ${arg_COMPILE_OPTIONS}
PUBLIC_COMPILE_OPTIONS ${arg_PUBLIC_COMPILE_OPTIONS}
LINK_OPTIONS ${arg_LINK_OPTIONS}
PUBLIC_LINK_OPTIONS ${arg_PUBLIC_LINK_OPTIONS}
MOC_OPTIONS ${arg_MOC_OPTIONS}
ENABLE_AUTOGEN_TOOLS ${arg_ENABLE_AUTOGEN_TOOLS}
DISABLE_AUTOGEN_TOOLS ${arg_DISABLE_AUTOGEN_TOOLS}
NO_UNITY_BUILD # Disabled by default
)
endfunction()
@ -227,7 +230,7 @@ function(qt_internal_add_3rdparty_library target)
qt_autogen_tools_initial_setup(${target})
endif()
if(NOT DEFINED arg_EXCEPTIONS)
if(NOT arg_EXCEPTIONS)
qt_internal_set_exceptions_flags("${target}" "DEFAULT")
else()
qt_internal_set_exceptions_flags("${target}" "${arg_EXCEPTIONS}")
@ -379,7 +382,7 @@ function(qt_internal_add_3rdparty_library target)
${__qt_internal_sbom_multi_args}
)
_qt_internal_extend_sbom(${target} ${sbom_args})
qt_internal_extend_qt_entity_sbom(${target} ${sbom_args})
endif()
qt_add_list_file_finalizer(qt_internal_finalize_3rdparty_library ${target})

View File

@ -287,3 +287,189 @@ function(qt_internal_android_dependencies target)
COMPONENT
Devel)
endfunction()
function(qt_internal_set_up_build_host_java_docs)
if("${ANDROID_SDK_ROOT}" STREQUAL "")
message(FATAL_ERROR
"QT_HOST_DOCUMENT_JAVA_SOURCES=ON requires setting ANDROID_SDK_ROOT."
)
endif()
_qt_internal_locate_android_jar()
set(QT_ANDROID_JAR "${QT_ANDROID_JAR}" PARENT_SCOPE)
set(QT_ANDROID_API_USED_FOR_JAVA "${QT_ANDROID_API_USED_FOR_JAVA}" PARENT_SCOPE)
endfunction()
# Collect the Java source files that were recorded by qt_internal_add_jar.
# If we're not building for Android, qt_internal_add_jar is not called, and we simple collect
# all java files under the current directory.
function(qt_internal_collect_jar_sources out_var)
if(NOT ANDROID)
file(GLOB_RECURSE sources LIST_DIRECTORIES FALSE "*.java")
set("${out_var}" "${sources}" PARENT_SCOPE)
return()
endif()
set(no_value_options "")
set(single_value_options DIRECTORY)
set(multi_value_options "")
cmake_parse_arguments(PARSE_ARGV 1 arg
"${no_value_options}" "${single_value_options}" "${multi_value_options}"
)
_qt_internal_validate_all_args_are_parsed(arg)
set(directory_arg "")
if(DEFINED arg_DIRECTORY)
set(directory_arg DIRECTORY ${arg_DIRECTORY})
endif()
get_directory_property(result ${directory_arg} _qt_jar_sources)
get_directory_property(subdirs ${directory_arg} SUBDIRECTORIES)
foreach(subdir IN LISTS subdirs)
qt_internal_collect_jar_sources(subdir_result DIRECTORY ${subdir})
if(NOT "${subdir_result}" STREQUAL "")
list(APPEND result ${subdir_result})
endif()
endforeach()
set("${out_var}" "${result}" PARENT_SCOPE)
endfunction()
function(qt_internal_add_javadoc_target)
set(no_value_options "")
set(single_value_options
MODULE
OUTPUT_DIR
)
set(multi_value_options
SOURCES
)
cmake_parse_arguments(PARSE_ARGV 0 arg
"${no_value_options}" "${single_value_options}" "${multi_value_options}"
)
_qt_internal_validate_all_args_are_parsed(arg)
if(TARGET ${arg_MODULE})
get_target_property(skip ${arg_MODULE} _qt_skip_javadoc)
if(skip)
message(VERBOSE "Skipping generation of Android HTML docs for ${arg_MODULE}.")
return()
endif()
endif()
# Collect source directories from source file paths.
set(source_dirs "")
foreach(source_path IN LISTS arg_SOURCES)
get_filename_component(dir_path "${source_path}" DIRECTORY)
list(APPEND source_dirs "${dir_path}")
endforeach()
list(REMOVE_DUPLICATES source_dirs)
# Retrieve package names from source dirs.
set(package_names "")
foreach(source_dir IN LISTS source_dirs)
string(REGEX MATCH "/(org/qtproject/qt/android(/.*|$))" package_dir "${source_dir}")
if(package_dir STREQUAL "")
message(VERBOSE "Java source dir is not a package directory: ${source_dir}")
continue()
endif()
# Store package_dir without leading slash.
set(package_dir "${CMAKE_MATCH_1}")
# Use dots instead of slashes for the package name.
string(REPLACE "/" "." package_name "${package_dir}")
list(APPEND package_names "${package_name}")
endforeach()
# Strip package paths from the source dirs.
list(TRANSFORM source_dirs REPLACE "/org/qtproject/qt/android.*" "")
list(REMOVE_DUPLICATES source_dirs)
# Use the correct separator for the --source-path argument.
if(NOT CMAKE_HOST_WIN32)
string(REPLACE ";" ":" source_dirs "${source_dirs}")
endif()
# Use a response file to avoid quoting issues with the space-separated package names.
set(javadoc_output_dir "${arg_OUTPUT_DIR}/android")
set(response_file "${CMAKE_CURRENT_BINARY_DIR}/doc/.javadocargs")
string(REPLACE ";" " " package_names_space_separated "${package_names}")
file(CONFIGURE
OUTPUT "${response_file}"
CONTENT "${package_names_space_separated}
--class-path \"${QT_ANDROID_JAR}\"
-d \"${javadoc_output_dir}\"
--source-path \"${source_dirs}\""
)
set(module ${arg_MODULE})
set(javadoc_target android_html_docs_${module})
add_custom_target(${javadoc_target} ${command_args}
COMMAND ${Java_JAVADOC_EXECUTABLE} "@${response_file}"
COMMENT "Generating Java documentation"
VERBATIM
)
add_dependencies(docs_android ${javadoc_target})
if (QT_WILL_INSTALL)
install(DIRECTORY "${arg_OUTPUT_DIR}/"
DESTINATION "${INSTALL_DOCDIR}/${module}"
COMPONENT _install_docs_android_${module}
EXCLUDE_FROM_ALL
)
add_custom_target(install_docs_android_${module}
COMMAND ${CMAKE_COMMAND}
--install "${CMAKE_BINARY_DIR}"
--component _install_docs_android_${module}
COMMENT "Installing Android html docs for ${module}"
)
else()
add_custom_target(install_docs_android_${module})
endif()
add_dependencies(install_docs_android_${module} ${javadoc_target})
add_dependencies(install_docs_android install_docs_android_${module})
endfunction()
function(qt_internal_create_source_jar)
set(no_value_options "")
set(single_value_options MODULE)
set(multi_value_options SOURCES)
cmake_parse_arguments(PARSE_ARGV 0 arg
"${no_value_options}" "${single_value_options}" "${multi_value_options}"
)
_qt_internal_validate_all_args_are_parsed(arg)
set(module ${arg_MODULE})
set(jar_target android_source_jar_${module})
set(jar_name ${CMAKE_INSTALL_NAMESPACE}AndroidSources${module})
add_jar(${jar_target}
SOURCES ${arg_SOURCES}
VERSION ${PROJECT_VERSION}
INCLUDE_JARS "${QT_ANDROID_JAR}"
OUTPUT_NAME ${jar_name}
)
set_target_properties(${jar_target} PROPERTIES EXCLUDE_FROM_ALL ON)
add_dependencies(android_source_jars ${jar_target})
if(QT_WILL_INSTALL)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${jar_name}-${PROJECT_VERSION}.jar"
DESTINATION "${INSTALL_DATADIR}/android/${module}"
COMPONENT _install_android_source_jar_${module}
EXCLUDE_FROM_ALL
)
add_custom_target(install_android_source_jar_${module}
COMMAND ${CMAKE_COMMAND}
--install "${CMAKE_BINARY_DIR}"
--component _install_android_source_jar_${module}
COMMENT "Installing Android source jar for ${module}"
)
else()
add_custom_target(install_android_source_jar_${module})
endif()
add_dependencies(install_android_source_jar_${module} ${jar_target})
add_dependencies(install_android_source_jars install_android_source_jar_${module})
endfunction()

View File

@ -154,7 +154,7 @@ function(qt_internal_add_app target)
${__qt_internal_sbom_multi_args}
)
_qt_internal_extend_sbom(${target} ${sbom_args})
qt_internal_extend_qt_entity_sbom(${target} ${sbom_args})
endif()
qt_add_list_file_finalizer(qt_internal_finalize_app ${target})

View File

@ -65,6 +65,11 @@ function(qt_auto_detect_wasm)
endfunction()
function(qt_auto_detect_android)
# Don't assume an Android build if we're requesting to build Java documentation on the host.
if(QT_BUILD_HOST_JAVA_DOCS)
return()
endif()
# We assume an Android build if any of the ANDROID_* cache variables are set.
if(DEFINED ANDROID_SDK_ROOT
OR DEFINED ANDROID_NDK_ROOT
@ -152,7 +157,12 @@ function(qt_auto_detect_android)
endfunction()
function(qt_auto_detect_vcpkg)
if(QT_USE_VCPKG AND DEFINED ENV{VCPKG_ROOT})
if(QT_USE_VCPKG)
if(NOT DEFINED ENV{VCPKG_ROOT})
message(FATAL_ERROR
"Usage of vcpkg was requested but the environment variable VCPKG_ROOT is not set."
)
endif()
set(vcpkg_toolchain_file "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
get_filename_component(vcpkg_toolchain_file "${vcpkg_toolchain_file}" ABSOLUTE)
@ -269,6 +279,9 @@ function(qt_auto_detect_apple)
endif()
endif()
_qt_internal_get_apple_sdk_path(apple_sdk_path)
set(QT_APPLE_SDK_PATH "${apple_sdk_path}" CACHE STRING "Darwin SDK path.")
_qt_internal_get_apple_sdk_version(apple_sdk_version)
set(QT_MAC_SDK_VERSION "${apple_sdk_version}" CACHE STRING "Darwin SDK version.")

View File

@ -123,10 +123,7 @@ function(qt_manual_moc result)
set(dep "${QT_CMAKE_EXPORT_NAMESPACE}::${dep}")
endif()
get_target_property(alias_dep ${dep} ALIASED_TARGET)
if(alias_dep)
set(dep ${alias_dep})
endif()
_qt_internal_dealias_target(dep)
get_target_property(loc ${dep} IMPORTED_LOCATION)
string(REGEX REPLACE "(.*)/Qt[^/]+\\.framework.*" "\\1" loc "${loc}")
@ -169,6 +166,9 @@ function(qt_manual_moc result)
set(metatypes_byproducts "${outfile}.json")
endif()
_qt_internal_get_moc_compiler_flavor_flags(flavor_flags)
list(APPEND moc_parameters ${flavor_flags})
if (TARGET Qt::Platform)
get_target_property(_abi_tag Qt::Platform qt_libcpp_abi_tag)
if (_abi_tag)
@ -199,8 +199,8 @@ function(qt_make_output_file infile prefix suffix source_dir binary_dir result)
get_filename_component(outfilename "${infile}" NAME_WE)
set(base_dir "${source_dir}")
string(FIND "${infile}" "${binary_dir}/" in_binary)
if (in_binary EQUAL 0)
_qt_internal_path_is_prefix(binary_dir "${infile}" in_binary)
if(in_binary)
set(base_dir "${binary_dir}")
endif()
@ -214,3 +214,50 @@ function(qt_make_output_file infile prefix suffix source_dir binary_dir result)
file(MAKE_DIRECTORY "${outpath}")
set("${result}" "${outpath}/${prefix}${outfilename}${suffix}" PARENT_SCOPE)
endfunction()
# Work around AUTOGEN issue when a library is added as a dependency more than once, and the autogen
# library dependency results in being discarded. To mitigate that, add all autogen dependencies
# manually, based on the passed in dependencies.
# CMake 4.0+ has a fix, so we don't need the extra logic.
# See https://gitlab.kitware.com/cmake/cmake/-/issues/26700
function(qt_internal_work_around_autogen_discarded_dependencies target)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 4.0
OR QT_NO_AUTOGEN_DISCARDED_DEPENDENCIES_WORKAROUND)
return()
endif()
set(libraries ${ARGN})
set(final_libraries "")
foreach(lib IN LISTS libraries)
# Skip non-target dependencies.
if(NOT TARGET "${lib}")
continue()
endif()
# Resolve alias targets, because AUTOGEN_TARGET_DEPENDS doesn't seem to handle them.
_qt_internal_dealias_target(lib)
# Skip imported targets, they don't have sync_headers targets.
get_target_property(imported "${lib}" IMPORTED)
if(imported)
continue()
endif()
# Resolve Qt private modules to their public counterparts.
get_target_property(is_private_module "${lib}" _qt_is_private_module)
get_target_property(public_module_target "${lib}" _qt_public_module_target_name)
if(is_private_module AND public_module_target)
set(lib "${public_module_target}")
endif()
# Another TARGET check, just in case.
if(TARGET "${lib}")
list(APPEND final_libraries "${lib}")
endif()
endforeach()
if(final_libraries)
set_property(TARGET ${target} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS "${final_libraries}")
endif()
endfunction()

View File

@ -187,7 +187,7 @@ function(qt_run_config_test_architecture)
list(APPEND QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT TEST_buildAbi)
set(QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT ${QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT} CACHE INTERNAL "Test variables that should be exported")
list(JOIN _sub_architecture " " subarch_summary)
list(JOIN sub_architecture_${first_arch} " " subarch_summary)
set_property(GLOBAL PROPERTY qt_configure_subarch_summary "${subarch_summary}")
endfunction()
@ -274,6 +274,7 @@ function(qt_internal_print_cmake_darwin_info)
endif()
message(STATUS "CMAKE_OSX_ARCHITECTURES: \"${CMAKE_OSX_ARCHITECTURES}\"${default_osx_arch}")
message(STATUS "CMAKE_OSX_SYSROOT: \"$CACHE{CMAKE_OSX_SYSROOT}\" / \"${CMAKE_OSX_SYSROOT}\"")
message(STATUS "QT_APPLE_SDK_PATH: \"${QT_APPLE_SDK_PATH}\"")
message(STATUS "CMAKE_OSX_DEPLOYMENT_TARGET: \"${CMAKE_OSX_DEPLOYMENT_TARGET}\"")
message(STATUS "QT_MAC_SDK_VERSION: \"${QT_MAC_SDK_VERSION}\"")
message(STATUS "QT_MAC_XCODE_VERSION: \"${QT_MAC_XCODE_VERSION}\"")

View File

@ -55,13 +55,40 @@ qt_install(FILES
DESTINATION "${__build_internals_install_dir}"
COMPONENT Devel
)
qt_path_join(__build_internals_standalone_test_template_path
"${CMAKE_CURRENT_SOURCE_DIR}"
"cmake/QtBuildInternals/${__build_internals_standalone_test_template_dir}")
qt_copy_or_install(
DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtBuildInternals/${__build_internals_standalone_test_template_dir}"
DIRECTORY "${__build_internals_standalone_test_template_path}"
DESTINATION "${__build_internals_install_dir}")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtBuildInternals/${__build_internals_standalone_test_template_dir}/CMakeLists.txt")
# In prefix builds we also need to copy the files into the build dir.
if(QT_WILL_INSTALL)
file(COPY "${__build_internals_standalone_test_template_path}"
DESTINATION "${__build_internals_install_dir}")
endif()
set(__build_internals_extra_files
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtBuildInternals/QtBuildInternalsHelpers.cmake"
)
qt_copy_or_install(
FILES ${__build_internals_extra_files}
DESTINATION "${__build_internals_install_dir}")
# In prefix builds we also need to copy the files into the build dir.
if(QT_WILL_INSTALL)
foreach(__build_internals_file ${__build_internals_extra_files})
file(COPY "${__build_internals_file}" DESTINATION "${__build_internals_install_dir}")
endforeach()
endif()
_qt_internal_append_cmake_configure_depends(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtBuildInternals/${__build_internals_standalone_test_template_dir}/CMakeLists.txt"
${__build_internals_extra_files}
)
qt_internal_create_toolchain_file()
@ -258,14 +285,24 @@ qt_copy_or_install(DIRECTORY
)
# Install qt-internal-strip and qt-internal-ninja files.
set(__qt_internal_strip_wrappers
set(__qt_internal_strip_wrapper_programs
libexec/qt-internal-strip.in
libexec/qt-internal-strip.bat.in
libexec/qt-internal-ninja.in
)
set(__qt_internal_strip_wrapper_files
libexec/qt-internal-strip.bat.in
libexec/qt-internal-ninja.bat.in
)
set(__qt_internal_strip_wrappers
${__qt_internal_strip_wrapper_programs}
${__qt_internal_strip_wrapper_files}
)
qt_copy_or_install(PROGRAMS
${__qt_internal_strip_wrappers}
${__qt_internal_strip_wrapper_programs}
DESTINATION "${__GlobalConfig_install_dir}/libexec"
)
qt_copy_or_install(FILES
${__qt_internal_strip_wrapper_files}
DESTINATION "${__GlobalConfig_install_dir}/libexec"
)
if(QT_WILL_INSTALL)
@ -366,7 +403,15 @@ if(APPLE)
DESTINATION "${__GlobalConfig_build_dir}/${platform_shortname}"
)
if(IOS)
if(MACOS)
# Test entitlements
qt_copy_or_install(FILES "cmake/${platform_shortname}/test.entitlements.plist"
DESTINATION "${__GlobalConfig_install_dir}/${platform_shortname}"
)
file(COPY "cmake/${platform_shortname}/test.entitlements.plist"
DESTINATION "${__GlobalConfig_build_dir}/${platform_shortname}"
)
elseif(IOS)
qt_copy_or_install(FILES "cmake/ios/LaunchScreen.storyboard"
DESTINATION "${__GlobalConfig_install_dir}/ios"
)
@ -378,9 +423,23 @@ if(APPLE)
elseif(WASM)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/util/wasm/wasmtestrunner/qt-wasmtestrunner.py"
"${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/qt-wasmtestrunner.py" @ONLY)
qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/qt-wasmtestrunner.py"
DESTINATION "${INSTALL_LIBEXECDIR}")
if(QT_FEATURE_shared)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/util/wasm/preload/preload_qml_imports.py"
"${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/preload_qml_imports.py" COPYONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/util/wasm/preload/preload_qt_plugins.py"
"${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/preload_qt_plugins.py" COPYONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/util/wasm/preload/generate_default_preloads.sh.in"
"${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/generate_default_preloads.sh.in" COPYONLY)
qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/preload_qml_imports.py"
DESTINATION "${INSTALL_LIBEXECDIR}")
qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/preload_qt_plugins.py"
DESTINATION "${INSTALL_LIBEXECDIR}")
qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_LIBEXECDIR}/generate_default_preloads.sh.in"
DESTINATION "${INSTALL_LIBEXECDIR}")
endif()
endif()
# Install CI support files to libexec.

View File

@ -97,6 +97,8 @@ macro(qt_internal_qtbase_pre_project_setup)
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtPublicCMakeVersionHelpers.cmake")
qt_internal_check_and_warn_about_unsuitable_cmake_version()
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtPublicCMakeEarlyPolicyHelpers.cmake")
## Add some paths to check for cmake modules:
list(PREPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
@ -135,7 +137,7 @@ macro(qt_internal_qtbase_install_mkspecs)
LIST_DIRECTORIES TRUE
"${PROJECT_SOURCE_DIR}/mkspecs/*")
foreach(entry IN LISTS mkspecs_subdirs)
if (IS_DIRECTORY ${entry})
if(IS_DIRECTORY ${entry})
qt_copy_or_install(DIRECTORY "${entry}"
DESTINATION ${mkspecs_install_dir}
USE_SOURCE_PERMISSIONS)
@ -143,9 +145,70 @@ macro(qt_internal_qtbase_install_mkspecs)
qt_copy_or_install(FILES "${entry}"
DESTINATION ${mkspecs_install_dir})
endif()
# In prefix builds we also need to copy the files into the build dir.
if(QT_WILL_INSTALL)
file(COPY "${entry}" DESTINATION "${mkspecs_install_dir}")
endif()
endforeach()
endmacro()
function(qt_internal_qtbase_install_wayland_files)
qt_path_join(wlprotocols_build_dir
${QT_BUILD_DIR}
${INSTALL_QT_SHAREDIR}/wayland/protocols)
qt_path_join(wlprotocols_install_dir
${QT_INSTALL_DIR}
${INSTALL_QT_SHAREDIR}/wayland/protocols)
file(GLOB wlprotocols_subdirs
LIST_DIRECTORIES TRUE
"${PROJECT_SOURCE_DIR}/src/3rdparty/wayland/protocols/*")
foreach(entry IN LISTS wlprotocols_subdirs)
if (IS_DIRECTORY "${entry}")
qt_copy_or_install(DIRECTORY "${entry}"
DESTINATION "${wlprotocols_install_dir}"
USE_SOURCE_PERMISSIONS)
if(QT_WILL_INSTALL)
file(COPY "${entry}" DESTINATION "${wlprotocols_build_dir}")
endif()
else()
qt_copy_or_install(FILES "${entry}"
DESTINATION "${wlprotocols_install_dir}")
if(QT_WILL_INSTALL)
file(COPY "${entry}" DESTINATION "${wlprotocols_build_dir}")
endif()
endif()
endforeach()
qt_path_join(wlextensions_build_dir
${QT_BUILD_DIR}
${INSTALL_QT_SHAREDIR}/wayland/extensions)
qt_path_join(wlextensions_install_dir
${QT_INSTALL_DIR}
${INSTALL_QT_SHAREDIR}/wayland/extensions)
file(GLOB wlextensions_subdirs
LIST_DIRECTORIES TRUE
"${PROJECT_SOURCE_DIR}/src/3rdparty/wayland/extensions/*")
foreach(entry IN LISTS wlextensions_subdirs)
if (IS_DIRECTORY "${entry}")
qt_copy_or_install(DIRECTORY "${entry}"
DESTINATION "${wlextensions_install_dir}"
USE_SOURCE_PERMISSIONS)
if(QT_WILL_INSTALL)
file(COPY "${entry}" DESTINATION "${wlextensions_build_dir}")
endif()
else()
qt_copy_or_install(FILES "${entry}"
DESTINATION "${wlextensions_install_dir}")
if(QT_WILL_INSTALL)
file(COPY "${entry}" DESTINATION "${wlextensions_build_dir}")
endif()
endif()
endforeach()
endfunction()
macro(qt_internal_qtbase_build_repo)
qt_internal_qtbase_pre_project_setup()
@ -182,6 +245,8 @@ macro(qt_internal_qtbase_build_repo)
include(src/corelib/Qt6WasmMacros.cmake)
endif()
include(src/tools/qtwaylandscanner/Qt6WaylandCompositorMacros.cmake)
## Targets for global features, etc.:
include(QtBaseGlobalTargets)
@ -217,6 +282,7 @@ macro(qt_internal_qtbase_build_repo)
endif()
qt_internal_qtbase_install_mkspecs()
qt_internal_qtbase_install_wayland_files()
endif()
qt_build_repo_post_process()

View File

@ -34,6 +34,23 @@ endmacro()
macro(qt_internal_top_level_setup_after_project)
qt_internal_top_level_setup_testing()
qt_internal_top_level_setup_cmake_and_export_namespace()
endmacro()
# Setting QT_CMAKE_EXPORT_NAMESPACE in the top-level scope is needed for any deferred call that is
# run on the top-level scope (CMAKE_BINARY_DIR).
macro(qt_internal_top_level_setup_cmake_and_export_namespace)
# Include the file that defines qt_internal_setup_cmake_and_export_namespace.
# We don't try to call find_package(QtBuildInternals) because that has a lot more side
# effects.
set(__qt6_build_internals_helpers_path
"${__qt6_qtbase_src_path}/cmake/QtBuildInternals/QtBuildInternalsHelpers.cmake")
if(NOT EXISTS "${__qt6_build_internals_helpers_path}")
message(FATAL_ERROR "Required file does not exist: '${__qt6_build_internals_helpers_path}'")
endif()
include("${__qt6_build_internals_helpers_path}")
qt_internal_setup_cmake_and_export_namespace()
endmacro()
macro(qt_internal_top_level_setup_testing)

View File

@ -227,6 +227,7 @@ function(qt_internal_get_qt_build_private_files_to_install out_var)
ModuleDescription.json.in
PkgConfigLibrary.pc.in
Qt3rdPartyLibraryConfig.cmake.in
QtTransitiveExtras.cmake.in
QtBaseTopLevelHelpers.cmake
QtBuild.cmake
QtBuildHelpers.cmake
@ -246,6 +247,7 @@ function(qt_internal_get_qt_build_private_files_to_install out_var)
QtGenerateLibPri.cmake
QtGenerateVersionScript.cmake
QtModuleConfig.cmake.in
QtModuleConfigPrivate.cmake.in
QtModuleDependencies.cmake.in
QtModuleHeadersCheck.cmake
QtModuleToolsConfig.cmake.in
@ -292,8 +294,18 @@ function(qt_internal_get_qt_build_public_helpers out_var)
QtPublicGitHelpers
QtPublicPluginHelpers
QtPublicPluginHelpers_v2
QtPublicSbomAttributionHelpers
QtPublicSbomCpeHelpers
QtPublicSbomDepHelpers
QtPublicSbomFileHelpers
QtPublicSbomGenerationHelpers
QtPublicSbomHelpers
QtPublicSbomLicenseHelpers
QtPublicSbomOpsHelpers
QtPublicSbomPurlHelpers
QtPublicSbomPythonHelpers
QtPublicSbomQtEntityHelpers
QtPublicSbomSystemDepHelpers
QtPublicTargetHelpers
QtPublicTestHelpers
QtPublicToolHelpers
@ -310,6 +322,7 @@ function(qt_internal_get_qt_build_public_files_to_install out_var)
set(${out_var}
QtCopyFileIfDifferent.cmake
QtInitProject.cmake
QtPublicCMakeEarlyPolicyHelpers.cmake
# Public CMake files that are installed next Qt6Config.cmake, but are NOT included by it.
# Instead they are included by the generated CMake toolchain file.
@ -350,7 +363,8 @@ endfunction()
macro(qt_internal_setup_find_host_info_package)
_qt_internal_determine_if_host_info_package_needed(__qt_build_requires_host_info_package)
_qt_internal_find_host_info_package("${__qt_build_requires_host_info_package}")
_qt_internal_find_host_info_package("${__qt_build_requires_host_info_package}"
${INSTALL_CMAKE_NAMESPACE})
endmacro()
macro(qt_internal_setup_poor_mans_scope_finalizer)
@ -432,8 +446,10 @@ macro(qt_internal_setup_build_and_global_variables)
qt_internal_setup_build_examples()
qt_internal_set_qt_host_path()
qt_internal_setup_find_host_info_package()
qt_internal_setup_build_docs()
qt_internal_setup_build_java_docs_on_host()
qt_internal_include_qt_platform_android()
@ -453,7 +469,6 @@ macro(qt_internal_setup_build_and_global_variables)
qt_internal_check_msvc_versions()
qt_internal_check_host_path_set_for_cross_compiling()
qt_internal_setup_android_platform_specifics()
qt_internal_setup_find_host_info_package()
qt_internal_setup_tool_path_command()
qt_internal_setup_default_target_function_options()
qt_internal_set_default_rpath_settings()
@ -478,4 +493,3 @@ macro(qt_internal_setup_build_and_global_variables)
qt_internal_detect_dirty_features()
endmacro()

View File

@ -555,11 +555,54 @@ function(qt_configure_add_report_error error)
qt_configure_add_report_entry(TYPE ERROR MESSAGE "${error}" CONDITION TRUE ${ARGN})
endfunction()
# Goes through each token in given in `CONDITION` or `COMPILE_TESTS_TO_SHOW_ON_ERROR`, checks if
# the token starts with TEST_ which means it represents a Qt compile test, queries its
# compile output if available, and appends it to `out_var`.
# The compile output for a test is only available on first configuration, because we don't cache it
# across cmake invocations.
function(qt_internal_get_try_compile_output_from_tests_in_condition out_var)
set(opt_args "")
set(single_args "")
set(multi_args
CONDITION
COMPILE_TESTS_TO_SHOW_ON_ERROR
)
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
set(content "")
foreach(token IN LISTS arg_CONDITION arg_COMPILE_TESTS_TO_SHOW_ON_ERROR)
if(token MATCHES "TEST_(.+)")
set(name "${CMAKE_MATCH_1}")
get_cmake_property(try_compile_output _qt_run_config_compile_test_output_${name})
if(try_compile_output)
string(APPEND content "\n TEST_${name} output: \n\n${try_compile_output}")
endif()
else()
continue()
endif()
endforeach()
if(content)
string(PREPEND content "\n Compile test outputs:\n")
endif()
set(${out_var} "${content}" PARENT_SCOPE)
endfunction()
function(qt_configure_process_add_report_entry)
cmake_parse_arguments(PARSE_ARGV 0 arg
""
"TYPE;MESSAGE"
"CONDITION")
set(opt_args "")
set(single_args
TYPE
MESSAGE
)
set(multi_args
CONDITION
COMPILE_TESTS_TO_SHOW_ON_ERROR
)
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
set(possible_types NOTE WARNING ERROR FATAL_ERROR)
@ -591,6 +634,23 @@ function(qt_configure_process_add_report_entry)
if("${arg_CONDITION}" STREQUAL "" OR condition_result)
set(new_report "${prefix}${arg_MESSAGE}")
set(compile_test_args "")
if(arg_CONDITION)
list(APPEND compile_test_args CONDITION ${arg_CONDITION})
endif()
if(arg_COMPILE_TESTS_TO_SHOW_ON_ERROR)
list(APPEND compile_test_args
COMPILE_TESTS_TO_SHOW_ON_ERROR ${arg_COMPILE_TESTS_TO_SHOW_ON_ERROR})
endif()
qt_internal_get_try_compile_output_from_tests_in_condition(extra_output
${compile_test_args}
)
if(extra_output)
string(APPEND new_report "\n${extra_output}")
endif()
string(APPEND "${contents_var}" "\n${new_report}")
if(arg_TYPE STREQUAL "ERROR" OR arg_TYPE STREQUAL "FATAL_ERROR")

View File

@ -11,18 +11,7 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/QtBuildInternalsExtra.cmake")
include(${CMAKE_CURRENT_LIST_DIR}/QtBuildInternalsExtra.cmake)
endif()
macro(qt_internal_setup_cmake_and_export_namespace)
# The variables might have already been set in QtBuildInternalsExtra.cmake if the file is
# included while building a new module and not QtBase. In that case, stop overriding the value.
if(NOT INSTALL_CMAKE_NAMESPACE)
set(INSTALL_CMAKE_NAMESPACE "Qt${PROJECT_VERSION_MAJOR}"
CACHE STRING "CMake namespace [Qt${PROJECT_VERSION_MAJOR}]")
endif()
if(NOT QT_CMAKE_EXPORT_NAMESPACE)
set(QT_CMAKE_EXPORT_NAMESPACE "Qt${PROJECT_VERSION_MAJOR}"
CACHE STRING "CMake namespace used when exporting targets [Qt${PROJECT_VERSION_MAJOR}]")
endif()
endmacro()
include(${CMAKE_CURRENT_LIST_DIR}/QtBuildInternalsHelpers.cmake)
macro(qt_set_up_build_internals_paths)
# Set up the paths for the cmake modules located in the prefix dir. Prepend, so the paths are

View File

@ -0,0 +1,15 @@
# Copyright (C) 2025 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
macro(qt_internal_setup_cmake_and_export_namespace)
# The variables might have already been set in QtBuildInternalsExtra.cmake if the file is
# included while building a new module and not QtBase. In that case, stop overriding the value.
if(NOT INSTALL_CMAKE_NAMESPACE)
set(INSTALL_CMAKE_NAMESPACE "Qt${PROJECT_VERSION_MAJOR}"
CACHE STRING "CMake namespace [Qt${PROJECT_VERSION_MAJOR}]")
endif()
if(NOT QT_CMAKE_EXPORT_NAMESPACE)
set(QT_CMAKE_EXPORT_NAMESPACE "Qt${PROJECT_VERSION_MAJOR}"
CACHE STRING "CMake namespace used when exporting targets [Qt${PROJECT_VERSION_MAJOR}]")
endif()
endmacro()

View File

@ -28,7 +28,7 @@ endif()
# Get the project name base on test directory name
get_filename_component(project_name "${absolute_project_path}" NAME)
project(${project_name} VERSION 6.0.0 LANGUAGES C CXX ASM)
project(${project_name} VERSION 6.0.0 LANGUAGES C CXX)
find_package(Qt6 REQUIRED COMPONENTS BuildInternals Core)

View File

@ -4,6 +4,9 @@
# Includes QtSetup and friends for private CMake API.
set(QT_INTERNAL_IS_STANDALONE_TEST TRUE)
# Make find_package(Qt6 COMPONENTS Foo) pull in FooPrivate too.
set(QT_FIND_PRIVATE_MODULES TRUE)
# Checks minimum CMake version and upgrades policies.
qt_internal_project_setup()

View File

@ -344,17 +344,9 @@ endfunction()
macro(qt_internal_setup_sbom)
qt_internal_compute_sbom_default(_qt_generate_sbom_default)
option(QT_GENERATE_SBOM "Generate SBOM documents in SPDX v2.3 tag:value format."
"${_qt_generate_sbom_default}")
option(QT_SBOM_GENERATE_JSON
"Generate SBOM documents in SPDX v2.3 JSON format if dependencies are available" ON)
option(QT_SBOM_REQUIRE_GENERATE_JSON
"Error out if JSON SBOM generation dependencies are not found." OFF)
option(QT_SBOM_VERIFY "Verify generated SBOM documents." ON)
option(QT_SBOM_REQUIRE_VERIFY
"Error out if SBOM verification dependencies are not found." OFF)
_qt_internal_setup_sbom(
GENERATE_SBOM_DEFAULT "${_qt_generate_sbom_default}"
)
endmacro()
macro(qt_internal_setup_build_examples)
@ -411,6 +403,16 @@ macro(qt_internal_setup_build_docs)
option(QT_BUILD_DOCS "Generate Qt documentation targets" ON)
endmacro()
macro(qt_internal_setup_build_java_docs_on_host)
option(QT_BUILD_HOST_JAVA_DOCS "Generate Java documentation targets on host" OFF)
if(QT_BUILD_HOST_JAVA_DOCS)
find_package(Java)
if(Java_FOUND)
include(UseJava)
endif()
endif()
endmacro()
macro(qt_internal_set_use_ccache)
option(QT_USE_CCACHE "Enable the use of ccache")
if(QT_USE_CCACHE)

View File

@ -160,6 +160,9 @@ macro(qt_internal_setup_configure_install_paths)
qt_configure_process_path(INSTALL_INCLUDEDIR "include" "Header files [PREFIX/include]")
qt_configure_process_path(INSTALL_LIBDIR "lib" "Libraries [PREFIX/lib]")
qt_configure_process_path(INSTALL_MKSPECSDIR "mkspecs" "Mkspecs files [PREFIX/mkspecs]")
qt_configure_process_path(INSTALL_SHAREDIR "share" "Share files [PREFIX/share]")
qt_configure_process_path(INSTALL_QT_SHAREDIR "${INSTALL_SHAREDIR}/qt6"
"Qt namespaced sharedir [SHAREDIR/qt6]")
qt_configure_process_path(INSTALL_ARCHDATADIR "." "Arch-dependent data [PREFIX]")
qt_configure_process_path(INSTALL_PLUGINSDIR
"${INSTALL_ARCHDATADIR}/plugins"
@ -202,6 +205,15 @@ macro(qt_internal_setup_configure_install_paths)
"Module description files directory")
qt_configure_process_path(INSTALL_SBOMDIR "${INSTALL_ARCHDATADIR}/sbom"
"SBOM [PREFIX/sbom]")
# INSTALL_PUBLICBINDIR is processed only if it is not empty
# See usage in qt_internal_generate_user_facing_tools_info
if(NOT "${INSTALL_PUBLICBINDIR}" STREQUAL "")
# A default value is not needed because it is always manually defined
# but as per the documentation it is typically `bin`
qt_configure_process_path(INSTALL_PUBLICBINDIR "bin"
"Symlinked user-facing executables")
endif()
endmacro()
macro(qt_internal_set_cmake_install_libdir)
@ -254,3 +266,20 @@ macro(qt_internal_setup_paths_and_prefixes)
qt_internal_set_qt_apple_support_files_path()
endmacro()
# Returns the prefix for the variables defined by HostInfo package. The prefix
# is based on version information provided by HostInfo. Falls back to current
# project version if ${INSTALL_CMAKE_NAMESPACE}HostInfo_VERSION_MAJOR is not
# defined.
function(qt_internal_get_host_info_var_prefix out_var)
if(${INSTALL_CMAKE_NAMESPACE}HostInfo_VERSION_MAJOR)
set(${out_var} "QT${${INSTALL_CMAKE_NAMESPACE}HostInfo_VERSION_MAJOR}_HOST_INFO"
PARENT_SCOPE)
else()
# This is not a valid way to define the host info versioned prefix, but
# it's backward compatible with Qt versions older than 6.10.
#
# TODO: remove once Qt LTS versions older than 6.10 reach end of life.
set(${out_var} "QT${PROJECT_VERSION_MAJOR}_HOST_INFO" PARENT_SCOPE)
endif()
endfunction()

View File

@ -224,7 +224,7 @@ function(qt_internal_get_example_install_prefix out_var)
# Allow customizing the installation path of the examples. Will be used in CI.
if(QT_INTERNAL_EXAMPLES_INSTALL_PREFIX)
set(qt_example_install_prefix "${QT_INTERNAL_EXAMPLES_INSTALL_PREFIX}")
elseif(QT_BUILD_STANDALONE_EXAMPLES)
elseif(QT_BUILD_STANDALONE_EXAMPLES AND NOT QT_NO_FAKE_STANDALONE_EXAMPLE_INSTALL_PREFIX)
# TODO: We might need to reset and pipe through an empty CMAKE_STAGING_PREFIX if we ever
# try to run standalone examples in the CI when cross-compiling, similar how it's done in
# qt_internal_set_up_fake_standalone_parts_install_prefix.

View File

@ -756,6 +756,13 @@ macro(qt_build_tests)
# Indicates that we are configuring tests now
set(QT_INTERNAL_CONFIGURING_TESTS TRUE)
# Set this as a directory scoped variable, so we can easily check the variable in child
# directories, to prevent certain code from running, like sbom file checks for all targets
# created in tests subdir.
if(NOT QT_BUILD_TESTS_BY_DEFAULT)
set(QT_INTERNAL_TEST_TARGETS_EXCLUDE_FROM_ALL TRUE)
endif()
# Tests are not unity-ready.
set(CMAKE_UNITY_BUILD OFF)

View File

@ -178,6 +178,10 @@ function(qt_internal_configure_qt)
-skip qtactiveqt,qtimageformats,qtlanguageserver,qtsvg
--
-DWARNINGS_ARE_ERRORS=OFF
# When 6.x.y version bumps are not merged in DAG-dependency order, this avoids
# blocking integrations due to mismatch of qtools package version and any of its
# dependencies.
-DQT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING=ON
--log-level STATUS
--fresh
-GNinja

View File

@ -1,52 +1,24 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# The common implementation of qt_configure_file functionality.
macro(qt_configure_file_impl)
if(NOT arg_OUTPUT)
message(FATAL_ERROR "No output file provided to qt_configure_file.")
endif()
# We use this check for the cases when the specified CONTENT is empty. The value of arg_CONTENT
# is undefined, but we still want to create a file with empty content.
if(NOT "CONTENT" IN_LIST arg_KEYWORDS_MISSING_VALUES)
if(arg_INPUT)
message(WARNING "Both CONTENT and INPUT are specified. CONTENT will be used to generate"
" output")
endif()
set(template_name "QtFileConfigure.txt.in")
# When building qtbase, use the source template file.
# Otherwise use the installed file (basically wherever Qt6 package is found).
# This should work for non-prefix and superbuilds as well.
if(QtBase_SOURCE_DIR)
set(input_file "${QtBase_SOURCE_DIR}/cmake/${template_name}")
else()
set(input_file "${_qt_6_config_cmake_dir}/${template_name}")
endif()
set(__qt_file_configure_content "${arg_CONTENT}")
elseif(arg_INPUT)
set(input_file "${arg_INPUT}")
else()
message(FATAL_ERROR "No input value provided to qt_configure_file.")
endif()
configure_file("${input_file}" "${arg_OUTPUT}" @ONLY)
endmacro()
# qt_configure_file(OUTPUT output-file <INPUT input-file | CONTENT content>)
# input-file is relative to ${CMAKE_CURRENT_SOURCE_DIR}
# output-file is relative to ${CMAKE_CURRENT_BINARY_DIR}
#
# This function is similar to file(GENERATE OUTPUT) except it writes the content
# to the file at configure time, rather than at generate time.
#
# TODO: Once we require 3.18+, this can use file(CONFIGURE) in its implementation,
# or maybe its usage can be replaced by file(CONFIGURE). Until then, it uses
# configure_file() with a generic input file as source, when used with the CONTENT
# signature.
# This function is the universal replacement for file(CONFIGURE CMake command.
function(qt_configure_file)
cmake_parse_arguments(PARSE_ARGV 0 arg "" "OUTPUT;INPUT;CONTENT" "")
qt_configure_file_impl()
if("CONTENT" IN_LIST ARGV)
if(arg_INPUT)
message(WARNING "Both CONTENT and INPUT are specified. CONTENT will be used to generate"
" output")
endif()
_qt_internal_configure_file(CONFIGURE OUTPUT "${arg_OUTPUT}" CONTENT "${arg_CONTENT}")
elseif(arg_INPUT)
_qt_internal_configure_file(CONFIGURE OUTPUT "${arg_OUTPUT}" INPUT "${arg_INPUT}")
else()
message(FATAL_ERROR "No input value provided to _qt_internal_configure_file.")
endif()
endfunction()
# A version of cmake_parse_arguments that makes sure all arguments are processed and errors out

View File

@ -169,9 +169,8 @@ function(qt_internal_force_allow_unsuitable_cmake_version_for_building_qt out_va
# Temporarily allow any version when building in Qt's CI, so we can decouple the provisioning
# of the minimum CMake version from the bump of the minimum CMake version.
# The COIN_UNIQUE_JOB_ID env var is set in Qt's CI for both build and test work items.
# Current state is that this check is enabled.
# TODO: Disable it once provisioning is merged.
set(allow_any_version_in_ci TRUE)
# Current state is that this check is disabled.
set(allow_any_version_in_ci FALSE)
if(allow_any_version_in_ci AND DEFINED ENV{COIN_UNIQUE_JOB_ID})
set(allow_any_version TRUE)

View File

@ -12,12 +12,27 @@ set(_qt_compiler_warning_flags_off -w)
if (MSVC)
list(APPEND _qt_compiler_warning_flags_on /W3)
# MSVC warns about macros expanding to `defined` when using the
# new preprocessor (so far, default for C11 code, but not C++).
# Suppress the warning, see also the comment below for GCC.
list(APPEND _qt_compiler_warning_flags_on /wd5105)
else()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GHS") # There is no -Wextra flag for GHS compiler.
list(APPEND _qt_compiler_warning_flags_on -Wall)
else()
list(APPEND _qt_compiler_warning_flags_on -Wall -Wextra)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "17.0.0")
# GCC warns if a macro is expanded to `defined`, but doesn't
# differentiate between object-like and function-like macros.
# The latter generally work everywhere. We don't have fine-grained
# control, so disable the warning (tst_qglobal tests for this
# behavior.)
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118542
list(APPEND _qt_compiler_warning_flags_on -Wno-expansion-to-defined)
endif()
endif()
endif()
set(_qt_compiler_warning_flags_condition

View File

@ -105,7 +105,7 @@ if(MSVC)
if(NOT CLANG)
# -Ob3 was introduced in Visual Studio 2019 version 16.0
# However clang-cl can't recognize it.
string(APPEND QT_CFLAGS_OPTIMIZE " -Ob3 ")
string(APPEND QT_CFLAGS_OPTIMIZE " -Ob3")
endif()
set(QT_CFLAGS_OPTIMIZE_DEBUG "-Od")
set(QT_CFLAGS_OPTIMIZE_SIZE "-O1")

View File

@ -3,6 +3,10 @@
@PACKAGE_INIT@
# This is included before the cmake_minimum_required on purpose.
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicCMakeEarlyPolicyHelpers.cmake")
__qt_internal_save_directory_scope_policy_cmp0156()
cmake_minimum_required(VERSION @min_new_policy_version@...@max_new_policy_version@)
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@ConfigExtras.cmake")
@ -39,9 +43,15 @@ if(TARGET @INSTALL_CMAKE_NAMESPACE@::PlatformCommonInternal)
if(NOT _qt_platform_internal_common_target)
set(_qt_platform_internal_common_target @INSTALL_CMAKE_NAMESPACE@::PlatformCommonInternal)
endif()
set(_qt_internal_clang_msvc_frontend FALSE)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
set(_qt_internal_clang_msvc_frontend TRUE)
endif()
set_target_properties(${_qt_platform_internal_common_target}
PROPERTIES
_qt_internal_cmake_generator "${CMAKE_GENERATOR}"
_qt_internal_clang_msvc_frontend "${_qt_internal_clang_msvc_frontend}"
)
unset(_qt_platform_internal_common_target)
endif()
@ -128,7 +138,12 @@ if(QT_DISABLE_NO_DEFAULT_PATH_IN_QT_PACKAGES)
set(__qt_use_no_default_path_for_qt_packages "")
endif()
foreach(module ${@INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS})
set(__qt_umbrella_find_components ${@INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS})
__qt_internal_handle_find_all_qt_module_packages(__qt_umbrella_find_components
COMPONENTS ${__qt_umbrella_find_components}
)
foreach(module ${__qt_umbrella_find_components})
if(NOT "${QT_HOST_PATH}" STREQUAL ""
AND "${module}" MATCHES "Tools$"
AND NOT "${module}" MATCHES "UiTools$"
@ -139,7 +154,7 @@ foreach(module ${@INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS})
# But don't match QtShaderTools and QtTools which are cross-compiled target package names.
# Allow opt out just in case.
get_filename_component(__qt_find_package_host_qt_path
"${Qt@PROJECT_VERSION_MAJOR@HostInfo_DIR}/.." ABSOLUTE)
"${@INSTALL_CMAKE_NAMESPACE@HostInfo_DIR}/.." ABSOLUTE)
set(__qt_backup_cmake_prefix_path "${CMAKE_PREFIX_PATH}")
set(__qt_backup_cmake_find_root_path "${CMAKE_FIND_ROOT_PATH}")
list(PREPEND CMAKE_PREFIX_PATH "${__qt_find_package_host_qt_path}"
@ -150,7 +165,18 @@ foreach(module ${@INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS})
_qt_internal_save_find_package_context_for_debugging(@INSTALL_CMAKE_NAMESPACE@${module})
if(NOT @INSTALL_CMAKE_NAMESPACE@${module}_FOUND)
if(@INSTALL_CMAKE_NAMESPACE@${module}_FOUND)
# Tools packages don't usually provide a qt module, so there's no target.
if(TARGET @INSTALL_CMAKE_NAMESPACE@::${module})
get_target_property(__qt_${module}_is_private @INSTALL_CMAKE_NAMESPACE@::${module}
_qt_is_private_module
)
if(__qt_${module}_is_private)
_qt_internal_show_private_module_warning(${module})
endif()
unset(__qt_${module}_is_private)
endif()
else()
find_package(@INSTALL_CMAKE_NAMESPACE@${module}
${@INSTALL_CMAKE_NAMESPACE@_FIND_VERSION}
${_@INSTALL_CMAKE_NAMESPACE@_FIND_PARTS_QUIET}

View File

@ -17,7 +17,8 @@ _qt_internal_setup_qt_host_path(
"${__qt_platform_requires_host_info_package}"
"${__qt_platform_initial_qt_host_path}"
"${__qt_platform_initial_qt_host_path_cmake_dir}")
_qt_internal_find_host_info_package(${__qt_platform_requires_host_info_package})
_qt_internal_find_host_info_package(${__qt_platform_requires_host_info_package}
@INSTALL_CMAKE_NAMESPACE@)
# note: _third_party_deps example: "ICU\\;FALSE\\;1.0\\;i18n uc data;ZLIB\\;FALSE\\;\\;"
set(__qt_third_party_deps "@third_party_deps@")

View File

@ -79,4 +79,9 @@ function(qt_create_qdbusxml2cpp_command target infile)
"${header_file_full}"
"${source_file_full}"
)
set_source_files_properties(
"${header_file_full}"
"${source_file_full}"
PROPERTIES
_qt_syncqt_exclude_from_docs TRUE)
endfunction()

View File

@ -16,6 +16,43 @@ function(qt_internal_add_doc_tool_dependency doc_target tool_name)
endif()
endfunction()
# Adds custom build and install targets to generate documentation for a documentation project
# identified by a cmake target and a path to a .qdocconf file.
#
# Creates custom targets of the form:
# - generate_docs_${target}
# - prepare_docs_${target}
# - html_docs_${target}
# - install_html_docs_${target}
# - etc.
#
# The first two arguments to the function should be <target> <path-to-qdocconf>.
#
# Additional options are:
# INDEX_DIRECTORIES - a list of index directories to pass to qdoc.
#
# DEFINES - extra environment variable assignments of the form ENV_VAR=VALUE, which should be set
# during qdoc execution.
#
# QDOC_EXTRA_ARGS - extra command-line arguments to pass to qdoc in both prepare and generate
# phases.
#
# QDOC_PREPARE_EXTRA_ARGS - extra command-line arguments to pass to qdoc in the prepare phase.
#
# QDOC_GENERATE_EXTRA_ARGS - extra command-line arguments to pass to qdoc in the generate phase.
#
# SHOW_INTERNAL - if set, the --showinternal option is passed to qdoc.
#
# Additional environment variables considered:
# QT_INSTALL_DOCS - directory path where the qt docs were expected to be installed, used for
# linking to other built docs. If not set, defaults to the qtbase or qt5 build directory, or the
# install directory extracted from the BuildInternals package.
#
# QT_QDOC_EXTRA_ARGS, QT_QDOC_PREPARE_EXTRA_ARGS, QT_QDOC_GENERATE_EXTRA_ARGS - same as the options
# but can be set as either environment or cmake variables.
#
# QT_QDOC_SHOW_INTERNAL - same as the option but can be set as either an environment or
# cmake variable.
function(qt_internal_add_docs)
if(NOT QT_BUILD_DOCS)
return()
@ -23,39 +60,68 @@ function(qt_internal_add_docs)
if(${ARGC} EQUAL 1)
# Function called from old generated CMakeLists.txt that was missing the target parameter
if(QT_FEATURE_developer_build)
message(AUTHOR_WARNING
"qt_internal_add_docs called with old signature. Skipping doc generation.")
endif()
return()
endif()
set(error_msg "qt_add_docs called with wrong number of arguments. ")
list(APPEND error_msg
"Should be qt_add_docs\(target_name qdocconf "
"\[INDEX_DIRECTORIES EXTRA_INDEX_DIRS_LIST_TO_ENABLE_QDOC_RESOLVE_LINKS\]\)")
if(NOT ${ARGC} GREATER_EQUAL 2)
message(FATAL_ERROR ${error_msg})
return()
message(FATAL_ERROR
"qt_internal_add_docs called with a wrong number of arguments. "
"The call should be qt_internal_add_docs\(<target> <path-to-qdocconf> [other-options])"
)
endif()
set(target ${ARGV0})
set(doc_project ${ARGV1})
set(qdoc_conf_path ${ARGV1})
set(opt_args
SHOW_INTERNAL
SKIP_JAVADOC
)
set(single_args "")
set(multi_args
INDEX_DIRECTORIES
DEFINES
QDOC_EXTRA_ARGS
QDOC_PREPARE_EXTRA_ARGS
QDOC_GENERATE_EXTRA_ARGS
)
cmake_parse_arguments(PARSE_ARGV 2 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
set(qdoc_extra_args "")
# Check if there are more than 2 arguments and pass them
# as extra --indexdir arguments to qdoc in prepare and
# The INDEX_DIRECTORIES key should enable passing a list of index
# directories as extra command-line arguments to qdoc, in prepare and
# generate phases.
if (${ARGC} GREATER 2)
# The INDEX_DIRECTORIES key should enable passing a list of index
# directories as extra command-line arguments to qdoc.
set(qdocExtraArgs "INDEX_DIRECTORIES;DEFINES")
cmake_parse_arguments(PARSE_ARGV 2 arg "" "" "${qdocExtraArgs}")
if(arg_UNPARSED_ARGUMENTS)
message(FATAL_ERROR ${error_msg})
return()
endif()
if(arg_INDEX_DIRECTORIES)
foreach(index_directory ${arg_INDEX_DIRECTORIES})
list(APPEND qdoc_extra_args "--indexdir" ${index_directory})
endforeach()
endif()
if(arg_INDEX_DIRECTORIES)
foreach(index_directory ${arg_INDEX_DIRECTORIES})
list(APPEND qdoc_extra_args "--indexdir" ${index_directory})
endforeach()
endif()
set(show_internal_env FALSE)
if(DEFINED ENV{QT_QDOC_SHOW_INTERNAL})
set(show_internal_env $ENV{QT_QDOC_SHOW_INTERNAL})
endif()
if(arg_SHOW_INTERNAL OR QT_QDOC_SHOW_INTERNAL OR show_internal_env)
list(APPEND qdoc_extra_args "--showinternal")
endif()
if(arg_QDOC_EXTRA_ARGS)
list(APPEND qdoc_extra_args ${arg_QDOC_EXTRA_ARGS})
endif()
if(QT_QDOC_EXTRA_ARGS)
list(APPEND qdoc_extra_args ${QT_QDOC_EXTRA_ARGS})
endif()
if(DEFINED ENV{QT_QDOC_EXTRA_ARGS})
list(APPEND qdoc_extra_args $ENV{QT_QDOC_EXTRA_ARGS})
endif()
# If a target is not built (which can happen for tools when crosscompiling), we shouldn't try
# to generate docs.
@ -66,8 +132,9 @@ function(qt_internal_add_docs)
set(tool_dependencies_enabled TRUE)
if(NOT "${QT_HOST_PATH}" STREQUAL "")
set(tool_dependencies_enabled FALSE)
set(doc_tools_bin "${QT_HOST_PATH}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_BINDIR}")
set(doc_tools_libexec "${QT_HOST_PATH}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_LIBEXECDIR}")
qt_internal_get_host_info_var_prefix(host_info_var_prefix)
set(doc_tools_bin "${QT_HOST_PATH}/${${host_info_var_prefix}_BINDIR}")
set(doc_tools_libexec "${QT_HOST_PATH}/${${host_info_var_prefix}_LIBEXECDIR}")
elseif(NOT "${QT_OPTIONAL_TOOLS_PATH}" STREQUAL "")
set(tool_dependencies_enabled FALSE)
set(doc_tools_bin "${QT_OPTIONAL_TOOLS_PATH}/${INSTALL_BINDIR}")
@ -77,7 +144,8 @@ function(qt_internal_add_docs)
set(doc_tools_libexec "${QtBase_BINARY_DIR}/${INSTALL_LIBEXECDIR}")
else()
set(doc_tools_bin "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_BINDIR}")
set(doc_tools_libexec "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_LIBEXECDIR}")
set(doc_tools_libexec
"${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_LIBEXECDIR}")
endif()
if(CMAKE_HOST_WIN32)
@ -121,15 +189,18 @@ function(qt_internal_add_docs)
set(include_path_args "")
endif()
get_filename_component(doc_target "${doc_project}" NAME_WLE)
get_filename_component(doc_target "${qdoc_conf_path}" NAME_WLE)
if (QT_WILL_INSTALL)
set(qdoc_output_dir "${CMAKE_BINARY_DIR}/${INSTALL_DOCDIR}/${doc_target}")
set(qdoc_qch_output_dir "${CMAKE_BINARY_DIR}/${INSTALL_DOCDIR}")
set(index_dir "${CMAKE_BINARY_DIR}/${INSTALL_DOCDIR}")
else()
set(qdoc_output_dir "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_DOCDIR}/${doc_target}")
set(qdoc_qch_output_dir "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_DOCDIR}")
set(index_dir "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_DOCDIR}")
set(qdoc_output_dir
"${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_DOCDIR}/${doc_target}")
set(qdoc_qch_output_dir
"${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_DOCDIR}")
set(index_dir
"${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_DOCDIR}")
endif()
# qtattributionsscanner
@ -139,12 +210,13 @@ function(qt_internal_add_docs)
--basedir "${PROJECT_SOURCE_DIR}/.."
--filter "QDocModule=${doc_target}"
-o "${target_bin_dir}/codeattributions.qdoc"
COMMENT "Scanning attributions for ${target}..."
)
# prepare docs target
set(prepare_qdoc_args
-outputdir "${qdoc_output_dir}"
"${target_source_dir}/${doc_project}"
"${target_source_dir}/${qdoc_conf_path}"
-prepare
-indexdir "${index_dir}"
-no-link-errors
@ -157,6 +229,18 @@ function(qt_internal_add_docs)
)
endif()
if(arg_QDOC_PREPARE_EXTRA_ARGS)
list(APPEND prepare_qdoc_args ${arg_QDOC_PREPARE_EXTRA_ARGS})
endif()
if(QT_QDOC_PREPARE_EXTRA_ARGS)
list(APPEND prepare_qdoc_args ${QT_QDOC_PREPARE_EXTRA_ARGS})
endif()
if(DEFINED ENV{QT_QDOC_PREPARE_EXTRA_ARGS})
list(APPEND prepare_qdoc_args $ENV{QT_QDOC_PREPARE_EXTRA_ARGS})
endif()
if(DEFINED ENV{QT_INSTALL_DOCS})
if(NOT EXISTS "$ENV{QT_INSTALL_DOCS}")
message(FATAL_ERROR
@ -167,7 +251,8 @@ function(qt_internal_add_docs)
elseif(QT_SUPERBUILD OR "${PROJECT_NAME}" STREQUAL "QtBase")
set(qt_install_docs_env "${QtBase_BINARY_DIR}/${INSTALL_DOCDIR}")
else()
set(qt_install_docs_env "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_DOCDIR}")
set(qt_install_docs_env
"${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_DOCDIR}")
endif()
set(qdoc_env_args
@ -187,6 +272,7 @@ function(qt_internal_add_docs)
COMMAND ${CMAKE_COMMAND} -E env ${qdoc_env_args}
${qdoc_bin}
${prepare_qdoc_args}
COMMENT "Running qdoc for ${target}..."
)
add_dependencies(prepare_docs_${target} qattributionsscanner_${target})
@ -198,7 +284,7 @@ function(qt_internal_add_docs)
# generate docs target
set(generate_qdoc_args
-outputdir "${qdoc_output_dir}"
"${target_source_dir}/${doc_project}"
"${target_source_dir}/${qdoc_conf_path}"
-generate
-indexdir "${index_dir}"
"${include_path_args}"
@ -210,6 +296,18 @@ function(qt_internal_add_docs)
)
endif()
if(arg_QDOC_GENERATE_EXTRA_ARGS)
list(APPEND generate_qdoc_args ${arg_QDOC_GENERATE_EXTRA_ARGS})
endif()
if(QT_QDOC_GENERATE_EXTRA_ARGS)
list(APPEND generate_qdoc_args ${QT_QDOC_GENERATE_EXTRA_ARGS})
endif()
if(DEFINED ENV{QT_QDOC_GENERATE_EXTRA_ARGS})
list(APPEND generate_qdoc_args $ENV{QT_QDOC_GENERATE_EXTRA_ARGS})
endif()
foreach(target_prefix generate_top_level_docs generate_repo_docs generate_docs)
set(depends_arg "")
if(tool_dependencies_enabled)
@ -217,7 +315,9 @@ function(qt_internal_add_docs)
endif()
add_custom_target(${target_prefix}_${target}
${depends_arg}
COMMAND ${CMAKE_COMMAND} -E env ${qdoc_env_args} ${qdoc_bin} ${generate_qdoc_args})
COMMAND ${CMAKE_COMMAND} -E env ${qdoc_env_args} ${qdoc_bin} ${generate_qdoc_args}
COMMENT "Generating documentation for ${target}..."
)
endforeach()
add_dependencies(generate_docs_${target} prepare_docs_${target})
@ -243,6 +343,7 @@ function(qt_internal_add_docs)
COMMAND ${qhelpgenerator_bin}
"${qdoc_output_dir}/${doc_target}.qhp"
-o "${qch_file_path}"
COMMENT "Building QtHelp files for ${target}..."
)
endforeach()
add_dependencies(qch_docs_${target} generate_docs_${target})
@ -252,9 +353,9 @@ function(qt_internal_add_docs)
if (QT_WILL_INSTALL)
install(DIRECTORY "${qdoc_output_dir}/"
DESTINATION "${INSTALL_DOCDIR}/${doc_target}"
COMPONENT _install_html_docs_${target}
EXCLUDE_FROM_ALL
DESTINATION "${INSTALL_DOCDIR}/${doc_target}"
COMPONENT _install_html_docs_${target}
EXCLUDE_FROM_ALL
)
add_custom_target(install_html_docs_${target}
@ -265,9 +366,9 @@ function(qt_internal_add_docs)
)
install(FILES "${qch_file_path}"
DESTINATION "${INSTALL_DOCDIR}"
COMPONENT _install_qch_docs_${target}
EXCLUDE_FROM_ALL
DESTINATION "${INSTALL_DOCDIR}"
COMPONENT _install_qch_docs_${target}
EXCLUDE_FROM_ALL
)
add_custom_target(install_qch_docs_${target}
@ -303,4 +404,73 @@ function(qt_internal_add_docs)
qt_internal_add_doc_tool_dependency(prepare_docs_${target} qdoc)
qt_internal_add_doc_tool_dependency(qch_docs_${target} qhelpgenerator)
endif()
_qt_internal_forward_function_args(
FORWARD_PREFIX arg
FORWARD_OUT_VAR add_java_documentation_args
FORWARD_OPTIONS
SKIP_JAVADOC
)
qt_internal_add_java_documentation(${target} ${add_java_documentation_args}
OUTPUT_DIR "${qdoc_output_dir}"
)
endfunction()
function(qt_internal_add_java_documentation target)
if(NOT ANDROID AND NOT QT_BUILD_HOST_JAVA_DOCS)
return()
endif()
set(no_value_options
SKIP_JAVADOC
)
set(single_value_options
OUTPUT_DIR
)
set(multi_value_options "")
cmake_parse_arguments(PARSE_ARGV 1 arg
"${no_value_options}" "${single_value_options}" "${multi_value_options}"
)
_qt_internal_validate_all_args_are_parsed(arg)
# Use a default output directory based on the project name.
if(NOT DEFINED arg_OUTPUT_DIR)
if (QT_WILL_INSTALL)
set(arg_OUTPUT_DIR "${CMAKE_BINARY_DIR}/${INSTALL_DOCDIR}")
else()
set(arg_OUTPUT_DIR "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_DOCDIR}")
endif()
string(APPEND arg_OUTPUT_DIR "/${PROJECT_NAME}")
endif()
qt_internal_collect_jar_sources(sources)
# Bail out if we haven't found relevant sources.
if(sources STREQUAL "")
return()
endif()
if(NOT TARGET docs_android)
add_custom_target(docs_android)
add_custom_target(install_docs_android)
add_dependencies(install_docs_android docs_android)
add_custom_target(android_source_jars)
add_custom_target(install_android_source_jars)
add_dependencies(install_android_source_jars android_source_jars)
endif()
if(NOT ANDROID)
qt_internal_set_up_build_host_java_docs()
endif()
if(NOT arg_SKIP_JAVADOC)
qt_internal_add_javadoc_target(
MODULE ${target}
SOURCES ${sources}
OUTPUT_DIR "${arg_OUTPUT_DIR}"
)
endif()
qt_internal_create_source_jar(SOURCES ${sources} MODULE ${target})
endfunction()

View File

@ -71,7 +71,12 @@ function(qt_internal_add_executable name)
endif()
endif()
if(arg_QT_APP AND QT_FEATURE_debug_and_release AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.19.0")
get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG)
if(arg_QT_APP
AND QT_FEATURE_debug_and_release
AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.19.0"
AND is_multi_config
)
set_property(TARGET "${name}"
PROPERTY EXCLUDE_FROM_ALL "$<NOT:$<CONFIG:${QT_MULTI_CONFIG_FIRST_CONFIG}>>")
endif()
@ -179,11 +184,18 @@ function(qt_internal_add_executable name)
set_target_properties("${name}" PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}"
LIBRARY_OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}"
WIN32_EXECUTABLE "${arg_GUI}"
MACOSX_BUNDLE "${arg_GUI}"
)
if(NOT DEFINED arg_EXCEPTIONS)
if(arg_GUI)
# Only override if GUI is set. Otherwise leave up to
# CMake defaults, which may be set by the user elsewhere.
set_target_properties("${name}" PROPERTIES
MACOSX_BUNDLE ON
WIN32_EXECUTABLE ON
)
endif()
if(NOT arg_EXCEPTIONS)
qt_internal_set_exceptions_flags("${name}" "DEFAULT")
else()
qt_internal_set_exceptions_flags("${name}" "${arg_EXCEPTIONS}")
@ -194,8 +206,9 @@ function(qt_internal_add_executable name)
set(exclude_from_all FALSE)
if(__qt_exclude_tool_directories)
foreach(absolute_dir ${__qt_exclude_tool_directories})
string(FIND "${CMAKE_CURRENT_SOURCE_DIR}" "${absolute_dir}" dir_starting_pos)
if(dir_starting_pos EQUAL 0)
_qt_internal_path_is_prefix(absolute_dir "${CMAKE_CURRENT_SOURCE_DIR}"
in_current_source)
if(in_current_source)
set(exclude_from_all TRUE)
set_target_properties("${name}" PROPERTIES
EXCLUDE_FROM_ALL TRUE
@ -252,23 +265,6 @@ function(qt_internal_add_executable name)
qt_internal_install_pdb_files(${name} "${arg_INSTALL_DIRECTORY}")
endif()
if(QT_GENERATE_SBOM)
set(sbom_args "")
_qt_internal_forward_function_args(
FORWARD_APPEND
FORWARD_PREFIX arg
FORWARD_OUT_VAR sbom_args
FORWARD_OPTIONS
${__qt_internal_sbom_optional_args}
FORWARD_SINGLE
${__qt_internal_sbom_single_args}
FORWARD_MULTI
${__qt_internal_sbom_multi_args}
)
_qt_internal_extend_sbom(${name} ${sbom_args})
endif()
qt_add_list_file_finalizer(qt_internal_finalize_executable "${name}")
endfunction()

View File

@ -115,6 +115,263 @@ function(qt_feature feature)
set(__QtFeature_internal_features ${__QtFeature_internal_features} PARENT_SCOPE)
endfunction()
# Define an alternative alias for the main feature definition.
#
# If the main feature is defined, it takes precedence and all others are ignored. Otherwise
# only one alias may be defined.
#
# Currently, we need this to be a dedicated function because we are gathering all aliases of
# the main feature and check its real value as part of
# `qt_feature_check_and_save_user_provided_value`
#
# TODO: See how to move this into the main `qt_feature` definition flow.
# TODO: How to add `CONDITION` and how does it interact with the main feature's `EMIT_IF`
#
# Synopsis
#
# qt_feature_alias(<alias_feature>
# {ALIAS_OF_FEATURE <real_feature> | ALIAS_OF_CACHE <cache>}
# [PRIVATE | PUBLIC]
# [LABEL <string>]
# [PURPOSE <string>]
# [SECTION <string>]
# [NEGATE]
# )
#
# Arguments
#
# `<alias_feature>`
# The feature alias to be created.
#
# `ALIAS_OF_FEATURE`
# The true canonical feature to consider.
#
# `ALIAS_OF_CACHE`
# The true cache variable that this value must synchronize with.
#
# `NEGATE`
# Populate the main FEATURE variable with the opposite of the alias's value
#
# `LABEL`, `PURPOSE`, `SECTION`
# Same as in `qt_feature`
#
# `PRIVATE`, `PUBLIC`
# Same as in `qt_feature`. When `ALIAS_OF_FEATURE` is used, these have no effect, instead the
# value of the the true feature is used.
function(qt_feature_alias alias_feature)
set(option_args
NEGATE
PRIVATE
PUBLIC
)
set(single_args
ALIAS_OF_FEATURE
ALIAS_OF_CACHE
LABEL
PURPOSE
SECTION
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 1 arg "${option_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_ALIAS_OF_FEATURE AND NOT arg_ALIAS_OF_CACHE)
message(FATAL_ERROR "One of ALIAS_OF_FEATURE,ALIAS_OF_CACHE must be passed.")
endif()
if(arg_ALIAS_OF_FEATURE AND arg_ALIAS_OF_CACHE)
message(FATAL_ERROR "ALIAS_OF_FEATURE and ALIAS_OF_CACHE are mutually exclusive.")
endif()
set(original_name "${alias_feature}")
qt_feature_normalize_name("${alias_feature}" alias_feature)
set_property(GLOBAL PROPERTY QT_FEATURE_ORIGINAL_NAME_${alias_feature} "${original_name}")
set(forward_args "")
if(arg_ALIAS_OF_FEATURE)
qt_feature_normalize_name("${arg_ALIAS_OF_FEATURE}" arg_ALIAS_OF_FEATURE)
if(NOT DEFINED _QT_FEATURE_DEFINITION_${arg_ALIAS_OF_FEATURE})
message(FATAL_ERROR "Primary feature ${arg_ALIAS_OF_FEATURE} was not defined yet.")
endif()
list(APPEND _QT_FEATURE_ALIASES_${arg_ALIAS_OF_FEATURE} "${alias_feature}")
list(APPEND forward_args ALIAS_OF_FEATURE "${arg_ALIAS_OF_FEATURE}")
endif()
if(arg_ALIAS_OF_CACHE)
list(APPEND forward_args ALIAS_OF_CACHE "${arg_ALIAS_OF_CACHE}")
endif()
if(arg_NEGATE)
list(APPEND forward_args ALIAS_NEGATE)
endif()
if(arg_LABEL)
list(APPEND forward_args LABEL "${arg_LABEL}")
endif()
if(arg_PURPOSE)
list(APPEND forward_args PURPOSE "${arg_PURPOSE}")
endif()
if(arg_SECTION)
list(APPEND forward_args SECTION "${arg_SECTION}")
endif()
set(_QT_FEATURE_DEFINITION_${alias_feature} ${forward_args} PARENT_SCOPE)
if(arg_ALIAS_OF_FEATURE)
# Register alias as a feature type similar to the true one
foreach(type IN ITEMS public private internal)
if(arg_ALIAS_OF_FEATURE IN_LIST __QtFeature_${type}_features)
list(APPEND __QtFeature_${type}_features "${alias_feature}")
set(__QtFeature_${type}_features ${__QtFeature_${type}_features} PARENT_SCOPE)
endif()
endforeach()
set(_QT_FEATURE_ALIASES_${arg_ALIAS_OF_FEATURE}
"${_QT_FEATURE_ALIASES_${arg_ALIAS_OF_FEATURE}}" PARENT_SCOPE)
else()
# Otherwise use the same logic as qt_feature
if (arg_PUBLIC)
list(APPEND __QtFeature_public_features "${alias_feature}")
endif()
if (arg_PRIVATE)
list(APPEND __QtFeature_private_features "${alias_feature}")
endif()
if (NOT arg_PUBLIC AND NOT arg_PRIVATE)
list(APPEND __QtFeature_internal_features "${alias_feature}")
endif()
set(__QtFeature_public_features ${__QtFeature_public_features} PARENT_SCOPE)
set(__QtFeature_private_features ${__QtFeature_private_features} PARENT_SCOPE)
set(__QtFeature_internal_features ${__QtFeature_internal_features} PARENT_SCOPE)
endif()
endfunction()
# Create a deprecated feature
#
# Synopsis
#
# qt_feature_deprecated(<feature>
# REMOVE_BY <version>
# [MESSAGE <string>] [VALUE <val>]
# [PRIVATE | PUBLIC]
# [LABEL <string>] [PURPOSE <string>] [SECTION <string>]
# )
#
# Arguments
#
# `<feature>`
# The feature to be created.
#
# `REMOVE_BY`
# Qt version when this feature is going to be removed
#
# `MESSAGE`
# Additional deprecation message to be printed.
#
# `VALUE`
# Value of the `QT_FEATURE_<feature>` that this is forced to. If undefined,
# `QT_FEATURE_<feature>` is not populated
#
# `LABEL`, `PURPOSE`, `SECTION`, `PRIVATE`, `PUBLIC`
# Same as in `qt_feature`
function(qt_feature_deprecated feature)
set(option_args
PRIVATE
PUBLIC
)
set(single_args
REMOVE_BY
MESSAGE
VALUE
LABEL
PURPOSE
SECTION
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 1 arg "${option_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_REMOVE_BY)
message(FATAL_ERROR "qt_feature_deprecated requires REMOVE_BY keyword")
elseif(PROJECT_VERSION VERSION_GREATER_EQUAL arg_REMOVE_BY)
message(FATAL_ERROR
"Deprecated feature ${feature} must be removed before Qt version ${arg_REMOVE_BY}"
)
endif()
set(original_name "${feature}")
qt_feature_normalize_name("${feature}" feature)
# Check if the values were manually passed
if(DEFINED FEATURE_${feature})
set(deprecation_msg "FEATURE_${feature} is deprecated. ")
if(arg_VALUE)
string(APPEND deprecation_msg "The value is always: ${arg_VALUE}")
else()
string(APPEND deprecation_msg "The value is not used.")
endif()
if(arg_MESSAGE)
string(APPEND deprecation_msg "\n${arg_MESSAGE}")
endif()
qt_configure_add_report_entry(RECORD_ON_FEATURE_EVALUATION TYPE WARNING
MESSAGE "${deprecation_msg}")
unset(FEATURE_${feature} CACHE)
endif()
# Make sure the `QT_FEATURE_*` value is set/unset accordingly
unset(err_msg)
if(arg_VALUE)
if(DEFINED QT_FEATURE_${feature} AND NOT QT_FEATURE_${feature} STREQUAL arg_VALUE)
string(CONCAT err_msg
"QT_FEATURE_${feature} was manually set to ${QT_FEATURE_${feature}}, but"
"the only supported value is: ${arg_VALUE}\n"
"Overwriting QT_FEATURE_${feature} cache to ${arg_VALUE}"
)
endif()
set(QT_FEATURE_${feature} "${arg_VALUE}" CACHE INTERNAL
"Deprecated: Always ${arg_VALUE}. ${arg_MESSAGE}"
)
else()
if(DEFINED QT_FEATURE_${feature})
string(CONCAT msg
"QT_FEATURE_${feature} was manually set to ${QT_FEATURE_${feature}}, but"
"the value must **NOT** be set.\n"
"Unsetting QT_FEATURE_${feature} cache"
)
unset(QT_FEATURE_${feature} CACHE)
endif()
endif()
# Emit the error message if we have an unexpected `QT_FEATURE_*`
if(err_msg)
if(arg_MESSAGE)
string(APPEND err_msg "\n${arg_MESSAGE}")
endif()
qt_configure_add_report_error("${err_msg}")
endif()
# Register the feature as a normal feature
set(forward_args "")
foreach(arg IN ITEMS LABEL PURPOSE SECTION)
if(arg_${arg})
list(APPEND forward_args ${arg} "${arg_${arg}}")
endif()
endforeach()
set(_QT_FEATURE_DEFINITION_${feature} ${forward_args} PARENT_SCOPE)
# Do the feature register
if (arg_PUBLIC)
list(APPEND __QtFeature_public_features "${feature}")
set(__QtFeature_public_features ${__QtFeature_public_features} PARENT_SCOPE)
endif()
if (arg_PRIVATE)
list(APPEND __QtFeature_private_features "${feature}")
set(__QtFeature_private_features ${__QtFeature_private_features} PARENT_SCOPE)
endif()
if (NOT arg_PUBLIC AND NOT arg_PRIVATE)
list(APPEND __QtFeature_internal_features "${feature}")
set(__QtFeature_internal_features ${__QtFeature_internal_features} PARENT_SCOPE)
endif()
endfunction()
function(qt_evaluate_to_boolean expressionVar)
if(${${expressionVar}})
set(${expressionVar} ON PARENT_SCOPE)
@ -292,6 +549,146 @@ function(_qt_internal_dump_expression_values expression_dump expression)
set(${expression_dump} "${${expression_dump}}" PARENT_SCOPE)
endfunction()
# Check the actual value of a given feature/alias.
# The value can come from `FEATURE_<alias>` being set or from another alias.
# The out_var is sanitized to 0/1 and it is not set if the feature was not defined.
function(_qt_feature_evaluate_alias out_var alias)
# Evaluate the alias against the aliases of the alias
_qt_feature_check_feature_alias(${alias})
if(NOT DEFINED FEATURE_${alias})
# If the alias was not defined, don't set value
return()
endif()
# Check if we need to negate the value to be set or not
set(not_kw)
_qt_internal_parse_feature_definition("${alias}")
if(arg_ALIAS_NEGATE)
set(not_kw "NOT")
endif()
# Evaluate the value and return it
qt_set01(${out_var} ${not_kw} FEATURE_${alias})
set(${out_var} "${${out_var}}" PARENT_SCOPE)
# Also set `not_kw` since it would be reused by the caller
set(not_kw "${not_kw}" PARENT_SCOPE)
endfunction()
# Check that the feature value is consistent with any of its aliases.
# If the feature was not set via `FEATURE_<feature>`, it may be set by the aliases.
function(_qt_feature_check_feature_alias feature)
if(DEFINED "FEATURE_${feature}")
# The main feature was already defined, use the current value.
# Just check if the other aliases have agreeing values.
qt_set01(expected_value FEATURE_${feature})
unset(alias_value)
foreach(alias IN LISTS _QT_FEATURE_ALIASES_${feature})
_qt_feature_evaluate_alias(alias_value ${alias})
if(DEFINED alias_value)
if(NOT expected_value EQUAL alias_value)
string(CONCAT msg
"Alias FEATURE_${alias}(${FEATURE_${alias}}) is an alias of ${not_kw} "
"FEATURE_${feature}(${FEATURE_${alias}}), and their values conflict"
)
qt_configure_add_report_error(${msg})
endif()
unset(alias_value)
endif()
endforeach()
return()
endif()
# Otherwise try to set the `feature` value from the aliases
set(aliases_set "")
set(expected_value "")
set(alias_not_kws "")
unset(value)
foreach(alias IN LISTS _QT_FEATURE_ALIASES_${feature})
_qt_feature_evaluate_alias(value ${alias})
if(DEFINED value)
list(APPEND aliases_set "${alias}")
list(APPEND expected_value "${value}")
list(APPEND alias_not_kws "${not_kw}")
unset(value)
endif()
endforeach()
# If there were no aliases set, do not set the feature either
if(NOT aliases_set)
return()
endif()
# Check if all values are consistent
list(REMOVE_DUPLICATES expected_value)
list(LENGTH expected_value expected_value_length)
if(expected_value_length GREATER 1)
string(CONCAT msg
"Multiple aliases of FEATURE_${feature} were defined, with conflicting values.\n"
"Aliases:"
)
while(aliases_set)
list(POP_FRONT aliases_set alias)
list(POP_FRONT alias_not_kws not_kw)
string(CONCAT msg
"${msg}\n"
" - ${not_kw} FEATURE_${alias}(${FEATURE_${alias}})"
)
endwhile()
qt_configure_add_report_error(${msg})
return()
endif()
# All aliased values are agreeing
set("FEATURE_${feature}" ${expected_value} PARENT_SCOPE)
endfunction()
# Check that the alias value is consistent with its cache source
function(_qt_feature_check_cache_alias feature)
_qt_internal_parse_feature_definition("${feature}")
if(NOT arg_ALIAS_OF_CACHE)
# Not an alias of a cache variable, skip this check
return()
endif()
if(DEFINED "${arg_ALIAS_OF_CACHE}")
# Check if the feature is set by another alias
unset(expected_value)
_qt_feature_evaluate_alias(expected_value "${feature}")
qt_set01(cache_sanitized ${arg_ALIAS_OF_CACHE})
if(NOT DEFINED expected_value)
# If nothing else set the alias value, use the primary cache value
set("FEATURE_${feature}" "${${arg_ALIAS_OF_CACHE}}" PARENT_SCOPE)
return()
endif()
# Otherwise, just check for consistency
if(NOT cache_sanitized EQUAL expected_value)
string(CONCAT msg
"FEATURE_${feature}(${FEATURE_${feature}}) is an alias of ${not_kw} "
"${arg_ALIAS_OF_CACHE}(${${arg_ALIAS_OF_CACHE}}), and their values conflict."
)
qt_configure_add_report_error(${msg})
endif()
endif()
endfunction()
# Make sure all the direct alias values are set after the final evaluation of the feature value.
# Must be run after `_qt_feature_check_feature_alias` which checks for user-defined values and
# any inconsistencies
function(_qt_feature_save_alias feature)
foreach(alias IN LISTS _QT_FEATURE_ALIASES_${feature})
# We only need to set the alias values if they were not explicitly set. The consistency
# check for those was done prior to this function call.
if(NOT DEFINED FEATURE_${alias})
# Evaluate the alias value based on the original
set(not_kw)
_qt_internal_parse_feature_definition("${alias}")
if(arg_ALIAS_NEGATE)
set(not_kw "NOT")
endif()
qt_set01(value ${not_kw} FEATURE_${feature})
qt_evaluate_to_boolean(value)
# Set the values based on the main feature's value
set(FEATURE_${alias} ${value} CACHE BOOL
# Using a temporary docstring that should be overwritten if everything works well
"(temporarily set by _qt_feature_save_alias)"
)
endif()
endforeach()
endfunction()
# Stores the user provided value to FEATURE_${feature} if provided.
# If not provided, stores ${computed} instead.
# ${computed} is also stored when reconfiguring and the condition does not align with the user
@ -299,6 +696,8 @@ endfunction()
#
function(qt_feature_check_and_save_user_provided_value
resultVar feature condition condition_expression computed label)
_qt_feature_check_cache_alias(${feature})
_qt_feature_check_feature_alias(${feature})
if (DEFINED "FEATURE_${feature}")
# Revisit new user provided value
set(user_value "${FEATURE_${feature}}")
@ -351,8 +750,24 @@ function(qt_feature_check_and_save_user_provided_value
# Initial setup:
set(result "${computed}")
set("FEATURE_${feature}" "${result}" CACHE BOOL "${label}")
# Update the HELPSTRING if needed
set_property(CACHE "FEATURE_${feature}" PROPERTY
HELPSTRING "${label}"
)
endif()
# Check for potential typo
get_property(original_name GLOBAL PROPERTY "QT_FEATURE_ORIGINAL_NAME_${feature}")
if(NOT original_name STREQUAL feature AND DEFINED "FEATURE_${original_name}")
unset("FEATURE_${original_name}" CACHE)
qt_configure_add_report_error(
"FEATURE_${original_name} does not exist. Consider using: FEATURE_${feature}"
)
endif()
# Set the values of each direct alias
_qt_feature_save_alias("${feature}")
set("${resultVar}" "${result}" PARENT_SCOPE)
endfunction()
@ -384,8 +799,8 @@ endmacro()
macro(_qt_internal_parse_feature_definition feature)
cmake_parse_arguments(arg
"PRIVATE;PUBLIC"
"LABEL;PURPOSE;SECTION;"
"PRIVATE;PUBLIC;ALIAS_NEGATE"
"LABEL;PURPOSE;SECTION;ALIAS_OF_FEATURE;ALIAS_OF_CACHE"
"AUTODETECT;CONDITION;ENABLE;DISABLE;EMIT_IF"
${_QT_FEATURE_DEFINITION_${feature}})
endmacro()
@ -427,6 +842,12 @@ function(qt_evaluate_feature feature)
_qt_internal_parse_feature_definition("${feature}")
if(arg_ALIAS_OF)
# If the current feature is an alias of another, we have to check the original source first
# in order to be consistent with the original source if set
qt_evaluate_feature("${arg_ALIAS_OF}")
endif()
if("${arg_ENABLE}" STREQUAL "")
set(arg_ENABLE OFF)
endif()
@ -465,6 +886,17 @@ function(qt_evaluate_feature feature)
qt_evaluate_config_expression(emit_if ${arg_EMIT_IF})
endif()
set(actual_label "${arg_LABEL}")
if(arg_ALIAS_OF_FEATURE OR arg_ALIAS_OF_CACHE)
set(not_kw)
if(arg_ALIAS_NEGATE)
set(not_kw "NOT")
endif()
# Only one of ALIAS_OF_FEATURE/ALIAS_OF_CACHE will be set, so we can just combine them
set(alias_source "${not_kw} ${arg_ALIAS_OF_FEATURE}${arg_ALIAS_OF_CACHE}")
string(APPEND actual_label " (alias of ${alias_source})")
endif()
# Warn about a feature which is not emitted, but the user explicitly provided a value for it.
if(NOT emit_if AND DEFINED FEATURE_${feature})
set(msg "")
@ -482,17 +914,17 @@ function(qt_evaluate_feature feature)
if(emit_if)
qt_feature_check_and_save_user_provided_value(
saved_user_value
"${feature}" "${condition}" "${arg_CONDITION}" "${computed}" "${arg_LABEL}")
"${feature}" "${condition}" "${arg_CONDITION}" "${computed}" "${actual_label}")
else()
# Make sure the feature internal value is OFF if not emitted.
set(saved_user_value OFF)
endif()
qt_feature_check_and_save_internal_value(
"${feature}" "${saved_user_value}" "${condition}" "${arg_LABEL}" "${arg_CONDITION}")
"${feature}" "${saved_user_value}" "${condition}" "${actual_label}" "${arg_CONDITION}")
# Store each feature's label for summary info.
set(QT_FEATURE_LABEL_${feature} "${arg_LABEL}" CACHE INTERNAL "")
set(QT_FEATURE_LABEL_${feature} "${actual_label}" CACHE INTERNAL "")
endfunction()
# Collect feature names that ${feature} depends on, by inspecting the given expression.
@ -801,6 +1233,7 @@ function(qt_feature_module_end)
foreach(feature ${all_features})
unset(_QT_FEATURE_DEFINITION_${feature} PARENT_SCOPE)
unset(_QT_FEATURE_ALIASES_${feature} PARENT_SCOPE)
endforeach()
if(NOT arg_ONLY_EVALUATE_FEATURES)
@ -1168,17 +1601,9 @@ function(qt_run_config_compile_test name)
set(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
set(CMAKE_REQUIRED_LIBRARIES "${arg_LIBRARIES}")
# OUTPUT_VARIABLE is an internal undocumented variable of check_cxx_source_compiles
# since 3.23. Allow an opt out in case this breaks in the future.
set(try_compile_output "")
set(output_var "")
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.23"
AND NOT QT_INTERNAL_NO_TRY_COMPILE_OUTPUT_VARIABLE)
set(output_var OUTPUT_VARIABLE try_compile_output)
endif()
_qt_internal_get_check_cxx_source_compiles_out_var(try_compile_output extra_args)
check_cxx_source_compiles(
"${arg_UNPARSED_ARGUMENTS} ${arg_CODE}" HAVE_${name} ${output_var}
"${arg_UNPARSED_ARGUMENTS} ${arg_CODE}" HAVE_${name} ${extra_args}
)
set(CMAKE_REQUIRED_LIBRARIES "${_save_CMAKE_REQUIRED_LIBRARIES}")
@ -1191,7 +1616,14 @@ function(qt_run_config_compile_test name)
endif()
endif()
# Note this is assigned to the parent scope, and is not a CACHE var, which means the value is
# only available on first configuration.
set(TEST_${name}_OUTPUT "${try_compile_output}" PARENT_SCOPE)
# Story the compile output for a test in a global property. It will only be available on first
# configuration, because we don't cache it across cmake invocations.
set_property(GLOBAL PROPERTY _qt_run_config_compile_test_output_${name} "${try_compile_output}")
set(TEST_${name} "${HAVE_${name}}" CACHE INTERNAL "${arg_LABEL}")
endfunction()

View File

@ -162,10 +162,7 @@ macro(qt_find_package)
foreach(qt_find_package_target_name ${arg_PROVIDED_TARGETS})
if(TARGET ${qt_find_package_target_name})
# Allow usage of aliased targets by setting properties on the actual target
get_target_property(aliased_target ${qt_find_package_target_name} ALIASED_TARGET)
if(aliased_target)
set(qt_find_package_target_name ${aliased_target})
endif()
_qt_internal_dealias_target(qt_find_package_target_name)
if("${qt_find_package_target_name}" MATCHES "${QT_CMAKE_EXPORT_NAMESPACE}::"
AND QT_FEATURE_developer_build
@ -387,6 +384,8 @@ endfunction()
# dep_target_name = EntryPointPrivate
# This is just a convenience function that deals with Qt targets and their associated packages
# instead of raw package names.
#
# Deprecated since 6.9.
function(qt_record_extra_qt_package_dependency main_target_name dep_target_name
dep_package_version)
# EntryPointPrivate -> Qt6EntryPointPrivate.
@ -571,17 +570,26 @@ function(qt_internal_get_package_name_of_target target package_name_out_var)
set(${package_name_out_var} "${package_name}" PARENT_SCOPE)
endfunction()
# This function stores the list of Qt targets a library depend on,
# along with their version info, for usage in ${target}Depends.cmake file
function(qt_register_target_dependencies target public_libs private_libs)
# This function collects the list of Qt targets a library depend on,
# along with their version info, for usage in ${target}Dependencies.cmake file
# Multi-value Arguments:
# PUBLIC
# public dependencies
# PRIVATE
# private dependencies
function(qt_internal_register_target_dependencies target)
cmake_parse_arguments(PARSE_ARGV 1 arg "" "" "PUBLIC;PRIVATE")
get_target_property(target_deps "${target}" _qt_target_deps)
if(NOT target_deps)
set(target_deps "")
endif()
get_target_property(target_type ${target} TYPE)
set(lib_list ${public_libs})
set(lib_list "")
if(arg_PUBLIC)
set(lib_list "${arg_PUBLIC}")
endif()
get_target_property(target_type ${target} TYPE)
set(target_is_shared FALSE)
set(target_is_static FALSE)
if(target_type STREQUAL "SHARED_LIBRARY")
@ -595,8 +603,8 @@ function(qt_register_target_dependencies target public_libs private_libs)
#
# Private static library dependencies will become $<LINK_ONLY:> dependencies in
# INTERFACE_LINK_LIBRARIES.
if(target_is_static)
list(APPEND lib_list ${private_libs})
if(target_is_static AND arg_PRIVATE)
list(APPEND lib_list ${arg_PRIVATE})
endif()
foreach(lib IN LISTS lib_list)
@ -622,8 +630,8 @@ function(qt_register_target_dependencies target public_libs private_libs)
# See QTBUG-86533 for some details.
# We filter out static libraries and common platform targets, but include both SHARED and
# INTERFACE libraries. INTERFACE libraries in most cases will be FooPrivate libraries.
if(target_is_shared AND private_libs)
foreach(lib IN LISTS private_libs)
if(target_is_shared AND arg_PRIVATE)
foreach(lib IN LISTS arg_PRIVATE)
set(lib_namespaced "${lib}")
if("${lib}" MATCHES "^Qt::(.*)")
set(lib "${CMAKE_MATCH_1}")

View File

@ -66,7 +66,26 @@ macro(qt_find_package_system_or_bundled _unique_prefix)
endif()
if(NOT TARGET "${${_unique_prefix}_qt_package_target_to_use}")
find_package("${${_unique_prefix}_qt_package_name_to_use}")
if(QT_USE_BUNDLED_${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_TARGET})
set(${_unique_prefix}_qt_use_no_default_path_for_qt_packages "NO_DEFAULT_PATH")
if(QT_DISABLE_NO_DEFAULT_PATH_IN_QT_PACKAGES)
set(${_unique_prefix}_qt_use_no_default_path_for_qt_packages "")
endif()
# For bundled targets, we want to limit search paths to the relevant Qt search paths.
find_package("${${_unique_prefix}_qt_package_name_to_use}"
PATHS
${QT_BUILD_CMAKE_PREFIX_PATH}
"${CMAKE_CURRENT_LIST_DIR}/.."
${_qt_cmake_dir}
${_qt_additional_packages_prefix_paths}
${${_unique_prefix}_qt_use_no_default_path_for_qt_packages}
)
else()
# For the non-bundled case we will look for FindWrapSystemFoo.cmake module files,
# which means we should not specify any PATHS.
find_package("${${_unique_prefix}_qt_package_name_to_use}")
endif()
endif()
if(TARGET "${${_unique_prefix}_qt_package_target_to_use}")

View File

@ -160,19 +160,21 @@ function(qt_internal_add_link_flags_no_undefined target)
return()
endif()
if ((GCC OR CLANG) AND NOT MSVC)
if(CLANG AND QT_FEATURE_sanitizer)
if((GCC OR CLANG) AND QT_FEATURE_sanitizer)
return()
endif()
set(previous_CMAKE_REQUIRED_LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
set(CMAKE_REQUIRED_LINK_OPTIONS "-Wl,-undefined,error")
check_cxx_source_compiles("int main() {}" HAVE_DASH_UNDEFINED_SYMBOLS)
_qt_internal_get_check_cxx_source_compiles_out_var(test_output_undefined_error extra_args)
check_cxx_source_compiles("int main() {}" HAVE_DASH_UNDEFINED_SYMBOLS ${extra_args})
if(HAVE_DASH_UNDEFINED_SYMBOLS)
set(no_undefined_flag "-Wl,-undefined,error")
endif()
set(CMAKE_REQUIRED_LINK_OPTIONS "-Wl,--no-undefined")
check_cxx_source_compiles("int main() {}" HAVE_DASH_DASH_NO_UNDEFINED)
_qt_internal_get_check_cxx_source_compiles_out_var(test_output_no_undefined extra_args)
check_cxx_source_compiles("int main() {}" HAVE_DASH_DASH_NO_UNDEFINED ${extra_args})
if(HAVE_DASH_DASH_NO_UNDEFINED)
set(no_undefined_flag "-Wl,--no-undefined")
endif()
@ -180,7 +182,10 @@ function(qt_internal_add_link_flags_no_undefined target)
set(CMAKE_REQUIRED_LINK_OPTIONS ${previous_CMAKE_REQUIRED_LINK_OPTIONS})
if (NOT HAVE_DASH_UNDEFINED_SYMBOLS AND NOT HAVE_DASH_DASH_NO_UNDEFINED)
message(FATAL_ERROR "Platform linker doesn't support erroring upon encountering undefined symbols. Target:\"${target}\".")
message(FATAL_ERROR
"Platform linker doesn't support erroring upon encountering undefined symbols. "
"Target:\"${target}\". "
"Test errors: \n ${test_output_undefined_error} \n ${test_output_no_undefined}")
endif()
target_link_options("${target}" PRIVATE "${no_undefined_flag}")
endif()
@ -465,21 +470,21 @@ endfunction()
function(qt_internal_print_optimization_flags_values_helper languages configs target_link_types)
foreach(lang ${languages})
set(flag_var_name "CMAKE_${lang}_FLAGS")
message(STATUS "${flag_var_name}: ${${flag_var_name}}")
message(STATUS "${flag_var_name}: '${${flag_var_name}}'")
foreach(config ${configs})
set(flag_var_name "CMAKE_${lang}_FLAGS_${config}")
message(STATUS "${flag_var_name}: ${${flag_var_name}}")
message(STATUS "${flag_var_name}: '${${flag_var_name}}'")
endforeach()
endforeach()
foreach(t ${target_link_types})
set(flag_var_name "CMAKE_${t}_LINKER_FLAGS")
message(STATUS "${flag_var_name}: ${${flag_var_name}}")
message(STATUS "${flag_var_name}: '${${flag_var_name}}'")
foreach(config ${configs})
set(flag_var_name "CMAKE_${t}_LINKER_FLAGS_${config}")
message(STATUS "${flag_var_name}: ${${flag_var_name}}")
message(STATUS "${flag_var_name}: '${${flag_var_name}}'")
endforeach()
endforeach()
endfunction()
@ -713,6 +718,356 @@ function(qt_internal_remove_compiler_flags flags)
endforeach()
endfunction()
# Add a series of compile options as generator expressions
#
# Each condition and compiler requirement are glued by $<AND:> genex.
#
# Synopsis
#
# qt_internal_add_compiler_dependent_flags(<target> <INTERFACE|PUBLIC|PRIVATE>
# COMPILERS <compiler> ...
# [ CONDITIONS <condition> ... ]
# OPTIONS <items> ...
# [ CONDITIONS <condition> ...
# OPTIONS <items> ... ]
# [ COMPILERS ... ]
#
# [LANGUAGES <lang> ...]
# [COMMON_CONDITIONS <condition_genex> ...]
# )
#
# Example
# qt_internal_add_compiler_dependent_flags(tgt PUBLIC
# COMPILERS ALL
# OPTIONS -Werror
# CONDITIONS $<TARGET_PROPERTY:foo> OR $<TARGET_PROPERTY:bar>
# OPTIONS -bar -baz
# COMPILERS GNU
# CONDITIONS VERSION_GREATER_EQUAL 10
# OPTIONS -baz
# )
#
# Is equivalent to:
#
# target_compile_options(tgt PUBLIC
# $<$<AND:$<COMPILE_LANGUAGE:CXX>>:-Werror>
# $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<OR:$<TARGET_PROPERTY:foo>,$<TARGET_PROPERTY:bar>>>:-bar;-baz>
# $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:GNU>,$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,10>>:-baz>
# )
#
# Arguments
#
# `<target>`
# Equivalent to `target_compile_options(<target>)`.
#
# `<INTERFACE|PUBLIC|PRIVATE>`
# Equivalent to `target_compile_options(<INTERFACE|PUBLIC|PRIVATE>)`.
#
# Unlike `target_compile_options`, only one set of target scope is implemented.
#
# `COMPILERS`
# Starts a new set of compiler specific set of options gated by `$<${lang}_COMPILER_ID>`.
# See `LANGUAGES` for how `${lang}` is determined.
#
# Can be any value defined in `CMAKE_<LANG>_COMPILER_ID`, or one of the following shortcuts
# - `ALL`: drops the compiler specific condition
# - `CLANG`: `Clang` and `IntelLLVM` (does not include `AppleClang`)
#
# At least one `COMPILERS` set *must* be defined.
#
# `CONDITIONS`
# Starts a new set of `<condition>` gated options.
#
# `<condition>` can be one of:
# - `VERSION_* <version>`: Equivalent to `$<VERSION_*:$<${lang}_COMPILER_VERSION:>,<version>>`
# See `LANGUAGES` for how `${lang}` is determined.
# - Any genex matching regex: `\$<.*>`
#
# You can use `AND` and `OR` as well as parenthesis `()` to join multiple `<condition>`.
#
# If no `<condition>` is added, the current set only checks for compiler condition and the
# `COMMON_CONDITIONS`.
#
# `OPTIONS`
# Starts the list of compiler options for the current set of `COMPILERS` and `CONDITIONS`
#
# Equivalent to `target_compile_options(<items>)`.
#
# At least one `COMPILERS` set *must* be defined.
#
# `LANGUAGES`
# Language conditions applied to all options.
#
# - If no `LANGUAGES` is passed `$<CXX_COMPILER_*>` is used to compute compiler-dependent
# variables such as `$<CXX_COMPILER_VERSION>`
# - If exactly 1 `LANGUAGES` is passed, this language is used in `$<${lang}_COMPILER_>` like
# variables
#
# `COMMON_CONDITIONS`
# Additional genex conditions to include for all compiler flags.
function(qt_internal_add_compiler_dependent_flags target target_scope)
# We cannot use `cmake_parse_arguments` to parse all the other arguments. We use a special
# parsing for that with the remaining `arg_UNPARSED_ARGUMENTS`
set(option_args "")
set(single_args "")
set(multi_args
LANGUAGES
COMMON_CONDITIONS
)
cmake_parse_arguments(PARSE_ARGV 2 arg
"${option_args}" "${single_args}" "${multi_args}"
)
# For debugging purposes we save the original list of arg_UNPARSED_ARGUMENTS
set(arg_UNPARSED_ARGUMENTS_original ${arg_UNPARSED_ARGUMENTS})
# Set the language for the compiler checks
set(lang CXX)
list(LENGTH arg_LANGUAGES arg_LANGUAGES_length)
if(arg_LANGUAGES_length EQUAL 1)
set(lang ${arg_LANGUAGES})
endif()
# Always add a language genex
set(lang_ex "$<COMPILE_LANGUAGE:${lang}>")
if(arg_LANGUAGES_length GREATER 1)
list(JOIN arg_LANGUAGES "," arg_LANGUAGES_comma_list)
set(lang_ex "$<COMPILE_LANGUAGE:${arg_LANGUAGES_comma_list}>")
endif()
# Helper debugging function
function(_qt_internal_add_compiler_dependent_flags_error msg)
# If you are hitting such a function, something must have gone wrong with
# `qt_internal_add_compiler_flags` implementation.
message(FATAL_ERROR
"${msg}\n"
" curr_arg = ${curr_arg}\n"
" arg_UNPARSED_ARGUMENTS = ${arg_UNPARSED_ARGUMENTS}\n"
" arg_UNPARSED_ARGUMENTS_original = ${arg_UNPARSED_ARGUMENTS_original}"
)
endfunction()
# Helper function finalizing each keyword set
# COMPILERS
function(_qt_internal_add_compiler_dependent_flags_do_COMPILERS)
set(compiler_ex "")
if(NOT curr_COMPILERS)
_qt_internal_add_compiler_dependent_flags_error(
"COMPILERS set cannot be empty"
)
endif()
# If ALL compilers is passed, we can ignore the compiler check
if(NOT "ALL" IN_LIST curr_COMPILERS)
# Check for other aliases
if("CLANG" IN_LIST curr_COMPILERS)
list(REMOVE_ITEM curr_COMPILERS CLANG)
list(APPEND curr_COMPILERS Clang IntelLLVM)
endif()
# Create compiler genex
list(REMOVE_DUPLICATES curr_COMPILERS)
list(JOIN curr_COMPILERS "," compilers)
set(compiler_ex "$<${lang}_COMPILER_ID:${compilers}>" PARENT_SCOPE)
endif()
endfunction()
# CONDITIONS
function(_qt_internal_add_compiler_dependent_flags_do_CONDITIONS)
function(_qt_internal_add_compiler_dependent_flags_do_CONDITIONS_end_stack
stack_in stack_out
)
# Resolve the current stack into a genex list
set(stack_conditions_ex)
set(prev_glue_word)
set(glue_word)
list(POP_FRONT ${stack_in} stack_conditions_ex)
while(${stack_in})
list(POP_FRONT ${stack_in} glue_word)
if(NOT (glue_word STREQUAL "AND" OR glue_word STREQUAL "OR"))
_qt_internal_add_compiler_dependent_flags_error(
"Expected AND/OR glue word, instead got: ${glue_word}"
)
endif()
list(POP_FRONT ${stack_in} next_condition)
if(NOT next_condition)
_qt_internal_add_compiler_dependent_flags_error(
"No other condition provided after ${glue_word}"
)
endif()
if(prev_glue_word STREQUAL glue_word)
# If the glue words are the same, we just add to current genex $<${glue_word}:>
# First trim the last `>` character
string(LENGTH "${stack_conditions_ex}" stack_conditions_ex_length)
math(EXPR stack_conditions_ex_length "${stack_conditions_ex_length} - 1")
string(SUBSTRING "${stack_conditions_ex}" 0 ${stack_conditions_ex_length}
stack_conditions_ex
)
set(stack_conditions_ex "${stack_conditions_ex},${next_condition}>")
else()
# Otherwise create a new $<${glue_word}:>
set(stack_conditions_ex
"$<${glue_word}:${stack_conditions_ex},${next_condition}>"
)
endif()
set(prev_glue_word "${glue_word}")
endwhile()
if(NOT stack_conditions_ex)
_qt_internal_add_compiler_dependent_flags_error(
"Empty parenthesis stack"
)
endif()
# Add the current
list(APPEND ${stack_out} "${stack_conditions_ex}")
set(${stack_out} "${${stack_out}}" PARENT_SCOPE)
endfunction()
set(conditions_ex "")
set(stack_level 0)
set(stack_0)
while(curr_CONDITIONS)
list(POP_FRONT curr_CONDITIONS condition_kw)
# Parenthesis evaluation
if(condition_kw MATCHES "^\\((.*)")
# Start a new stack
math(EXPR stack_level "${stack_level} + 1")
set(stack_${stack_level})
# Check if the parenthesis was glued to another keyword
# Resolve the remaining keyword in the next loop
if(CMAKE_MATCH_1)
list(PREPEND curr_CONDITIONS "${CMAKE_MATCH_1}")
endif()
continue()
elseif(condition_kw MATCHES "(.*)\\)$")
# Check if the parenthesis was glued to another keyword
# Separate them and evaluate each one individually
if(CMAKE_MATCH_1)
set(condition_kw "${CMAKE_MATCH_1}")
list(PREPEND curr_CONDITIONS "${CMAKE_MATCH_1}" ")")
endif()
# Finalize the current stack making it a genex for the next loop
set(curr_stack stack_${stack_level})
math(EXPR stack_level "${stack_level} - 1")
set(prev_stack stack_${stack_level})
_qt_internal_add_compiler_dependent_flags_do_CONDITIONS_end_stack(
${curr_stack} ${prev_stack}
)
if(stack_level LESS 0)
_qt_internal_add_compiler_dependent_flags_error(
"Unbalanced parenthesis."
)
endif()
continue()
endif()
# Glue word evaluation
if(condition_kw STREQUAL "AND" OR condition_kw STREQUAL "OR")
# Insert the operator
list(APPEND stack_${stack_level} "${condition_kw}")
continue()
endif()
# Main condition keyword evaluation
if(condition_kw MATCHES "^VERSION_.*")
# Shortcut for VERSION_* keyword
list(POP_FRONT curr_CONDITIONS version)
list(APPEND stack_${stack_level}
"$<${condition_kw}:$<${lang}_COMPILER_VERSION>,${version}>"
)
continue()
elseif(condition_kw MATCHES "^\\$<.*>$")
# genex expression are added as-is
list(APPEND stack_${stack_level} "${condition_kw}")
continue()
else()
# All other unrecognized forms we do not know how to deal with
_qt_internal_add_compiler_dependent_flags_error(
"Unrecognized condition form: ${condition_kw}"
)
endif()
endwhile()
# Finalize the top-level stack and put it in `conditions_ex`
if(NOT stack_level EQUAL 0)
_qt_internal_add_compiler_dependent_flags_error(
"Unbalanced parenthesis."
)
endif()
_qt_internal_add_compiler_dependent_flags_do_CONDITIONS_end_stack(stack_0 conditions_ex)
set(conditions_ex "${conditions_ex}" PARENT_SCOPE)
endfunction()
# OPTIONS
function(_qt_internal_add_compiler_dependent_flags_do_OPTIONS)
# Check for required keywords
foreach(required_keyword IN ITEMS OPTIONS COMPILERS)
if(curr_${required_keyword} STREQUAL "MISSING")
_qt_internal_add_compiler_dependent_flags_error(
"${required_keyword} keyword was not passed"
)
endif()
endforeach()
# Only handle the current set if the OPTIONS did not evaluate to empty, otherwise
# it is considered a no-op
if(curr_OPTIONS)
# No need to check the length of `all_conditions_ex` because `lang_ex` is
# always defined.
list(JOIN curr_OPTIONS ";" options)
# Combine all conditions in an `AND` statement
set(all_conditions_ex "")
list(APPEND all_conditions_ex
${arg_COMMON_CONDITIONS}
${lang_ex}
${compiler_ex}
${conditions_ex}
)
list(JOIN all_conditions_ex "," all_conditions_ex)
list(APPEND flags
"$<$<AND:${all_conditions_ex}>:${options}>"
)
endif()
# Reset all loop variables
# curr_COMPILERS is inherited from the last loop
set(curr_CONDITIONS "" PARENT_SCOPE)
set(curr_OPTIONS "MISSING" PARENT_SCOPE)
set(conditions_ex "" PARENT_SCOPE)
set(flags "${flags}" PARENT_SCOPE)
endfunction()
# Set initial loop variables
set(compiler_ex "")
set(conditions_ex "")
set(flags "")
# We set (REQUIRED) curr_* loop variables to a special keyword MISSING to identify when
# the keyword was not passed
set(curr_COMPILERS "MISSING")
set(curr_CONDITIONS "")
set(curr_OPTIONS "MISSING")
set(curr_keyword "")
# Parse the remaining arguments
while(arg_UNPARSED_ARGUMENTS)
list(POP_FRONT arg_UNPARSED_ARGUMENTS curr_arg)
# Check for separator keywords
if(curr_arg MATCHES "^(COMPILERS|CONDITIONS|OPTIONS)$")
# Resolve the previous keyword set
# Implicitly we skip the initial loop where curr_keyword == ""
if(curr_keyword STREQUAL "COMPILERS")
_qt_internal_add_compiler_dependent_flags_do_COMPILERS()
elseif(curr_keyword STREQUAL "CONDITIONS")
_qt_internal_add_compiler_dependent_flags_do_CONDITIONS()
elseif(curr_keyword STREQUAL "OPTIONS")
_qt_internal_add_compiler_dependent_flags_do_OPTIONS()
endif()
# Set the new keyword to accumulate the current `curr_*` variable
set(curr_keyword "${curr_arg}")
set(curr_${curr_keyword} "")
continue()
endif()
# If no separator keyword is passed, add the current values to `curr_*` loop variable
# and move on to the next loop
if(NOT curr_keyword)
_qt_internal_add_compiler_dependent_flags_error(
"No keyword was passed: COMPILERS/CONDITIONS/OPTIONS"
)
endif()
list(APPEND curr_${curr_keyword} "${curr_arg}")
endwhile()
# finalize the last set
_qt_internal_add_compiler_dependent_flags_do_OPTIONS()
# Finally add all of the flags to `target_compile_options`
target_compile_options("${target}" ${target_scope} ${flags})
endfunction()
# Adds compiler flags for the given CONFIGS in the calling scope. Can also update the cache
# if asked to do so. The flag variables are always updated in the calling scope, even if they
# did not exist beforehand.

View File

@ -34,10 +34,13 @@ macro(qt_find_apple_system_frameworks)
qt_internal_find_apple_system_framework(FWGameController GameController)
qt_internal_find_apple_system_framework(FWCoreBluetooth CoreBluetooth)
qt_internal_find_apple_system_framework(FWAVFoundation AVFoundation)
qt_internal_find_apple_system_framework(FWPhotos Photos)
qt_internal_find_apple_system_framework(FWContacts Contacts)
qt_internal_find_apple_system_framework(FWEventKit EventKit)
qt_internal_find_apple_system_framework(FWHealthKit HealthKit)
qt_internal_find_apple_system_framework(FWUniformTypeIdentifiers UniformTypeIdentifiers)
qt_internal_find_apple_system_framework(FWNetwork Network)
qt_internal_find_apple_system_framework(FWOpenGL OpenGL)
endif()
endmacro()
@ -169,7 +172,7 @@ function(qt_internal_generate_fake_framework_header target)
file(GENERATE OUTPUT "${fake_header}" CONTENT "// ignore this file\n"
CONDITION "$<CONFIG:${main_config}>")
target_sources(${target} PRIVATE "${fake_header}")
set_source_files_properties("${fake_header}" PROPERTIES GENERATED ON)
_qt_internal_set_source_file_generated(SOURCES "${fake_header}")
set_property(TARGET ${target} APPEND PROPERTY PUBLIC_HEADER "${fake_header}")
endfunction()

View File

@ -10,7 +10,8 @@ function(qt_get_library_name_without_prefix_and_suffix out_var file_path)
if(NOT file_path MATCHES "^-") # not a linker flag
get_filename_component(basename "${file_path}" NAME_WE)
get_filename_component(ext "${file_path}" EXT)
if(NOT ext) # seems like a library name without prefix and suffix
if(NOT ext AND NOT IS_ABSOLUTE "${file_path}")
# seems like a library name without prefix and suffix
set(${out_var} "${file_path}" PARENT_SCOPE)
return()
endif()

View File

@ -239,8 +239,8 @@ function(qt_internal_add_headersclean_target module_target module_headers)
set(possible_base_dirs "${CMAKE_BINARY_DIR}" "${CMAKE_SOURCE_DIR}")
foreach(dir IN LISTS possible_base_dirs)
string(FIND "${input_path}" "${dir}" idx)
if(idx EQUAL "0")
_qt_internal_path_is_prefix(dir "${input_path}" dir_is_prefix)
if(dir_is_prefix)
set(input_base_dir "${dir}")
break()
endif()

View File

@ -18,6 +18,8 @@ set(@var_prefix@SYSCONFDIR "@INSTALL_SYSCONFDIR@")
set(@var_prefix@EXAMPLESDIR "@INSTALL_EXAMPLESDIR@")
set(@var_prefix@TESTSDIR "@INSTALL_TESTSDIR@")
set(@var_prefix@DESCRIPTIONSDIR "@INSTALL_DESCRIPTIONSDIR@")
set(@var_prefix@SHAREDIR "@INSTALL_SHAREDIR@")
set(@var_prefix@QT_SHAREDIR "@INSTALL_QT_SHAREDIR@")
set(@var_prefix@QMAKE_MKSPEC "@QT_QMAKE_TARGET_MKSPEC@")
set(@var_prefix@ARCH "@TEST_architecture_arch@")
set(@var_prefix@SUBARCHS "@TEST_subarch_result@")

View File

@ -93,12 +93,11 @@ handle_type(cpp EXTENSIONS .c .cc .cpp .cxx .h .hh .hxx .hpp MODULES Core TEMPLA
handle_type(qml EXTENSIONS .qml .js .mjs MODULES Gui Qml Quick TEMPLATE
"\n\nqt_add_qml_module(${project_name}
URI ${project_name}
OUTPUT_DIRECTORY qml
VERSION 1.0
RESOURCE_PREFIX /qt/qml
QML_FILES
@files@
)"
)
set_property(TARGET ${project_name} PROPERTY RUNTIME_OUTPUT_NAME \"${project_name}app\")
"
)
handle_type(ui EXTENSIONS .ui MODULES Gui Widgets DEPENDS cpp TEMPLATE
@ -162,7 +161,7 @@ set(content
project(${project_name} LANGUAGES CXX)
find_package(Qt6 REQUIRED COMPONENTS ${packages_string})
qt_standard_project_setup()"
qt_standard_project_setup(REQUIRES 6.8)"
)
set(has_useful_sources FALSE)

View File

@ -14,3 +14,6 @@ set(QT@PROJECT_VERSION_MAJOR@_INSTALL_PLUGINS "@INSTALL_PLUGINSDIR@")
set(QT@PROJECT_VERSION_MAJOR@_INSTALL_QML "@INSTALL_QMLDIR@")
set(QT@PROJECT_VERSION_MAJOR@_INSTALL_TESTS "@INSTALL_TESTSDIR@")
set(QT@PROJECT_VERSION_MAJOR@_INSTALL_TRANSLATIONS "@INSTALL_TRANSLATIONSDIR@")
set(QT@PROJECT_VERSION_MAJOR@_INSTALL_DESCRIPTIONSDIR "@INSTALL_DESCRIPTIONSDIR@")
set(QT@PROJECT_VERSION_MAJOR@_INSTALL_SHAREDIR "@INSTALL_SHAREDIR@")
set(QT@PROJECT_VERSION_MAJOR@_INSTALL_QT_SHAREDIR "@INSTALL_QT_SHAREDIR@")

View File

@ -3,85 +3,124 @@
function(qt_internal_set_warnings_are_errors_flags target target_scope)
set(flags "")
if (CLANG AND NOT MSVC)
list(APPEND flags -Werror -Wno-error=\#warnings -Wno-error=deprecated-declarations)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") # as in: not AppleClang
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "10.0.0")
# We do mixed enum arithmetic all over the place:
list(APPEND flags -Wno-error=deprecated-enum-enum-conversion)
endif()
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "14.0.0")
# Clang 14 introduced these two but we are not clean for it.
list(APPEND flags -Wno-error=deprecated-copy-with-user-provided-copy)
list(APPEND flags -Wno-error=unused-but-set-variable)
endif()
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# using GCC
list(APPEND flags -Werror -Wno-error=cpp -Wno-error=deprecated-declarations)
# GCC prints this bogus warning, after it has inlined a lot of code
# error: assuming signed overflow does not occur when assuming that (X + c) < X is always false
list(APPEND flags -Wno-error=strict-overflow)
# GCC 7 includes -Wimplicit-fallthrough in -Wextra, but Qt is not yet free of implicit fallthroughs.
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "7.0.0")
list(APPEND flags -Wno-error=implicit-fallthrough)
endif()
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "9.0.0")
# GCC 9 introduced these but we are not clean for it.
list(APPEND flags -Wno-error=deprecated-copy -Wno-error=redundant-move -Wno-error=init-list-lifetime)
# GCC 9 introduced -Wformat-overflow in -Wall, but it is buggy:
list(APPEND flags -Wno-error=format-overflow)
endif()
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "10.0.0")
# GCC 10 has a number of bugs in -Wstringop-overflow. Do not make them an error.
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92955
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94335
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101134
list(APPEND flags -Wno-error=stringop-overflow)
endif()
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "11.0.0")
# Ditto
list(APPEND flags -Wno-error=stringop-overread)
# We do mixed enum arithmetic all over the place:
list(APPEND flags -Wno-error=deprecated-enum-enum-conversion -Wno-error=deprecated-enum-float-conversion)
endif()
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "11.0.0" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "11.2.0")
# GCC 11.1 has a regression in the integrated preprocessor, so disable it as a workaround (QTBUG-93360)
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100796
# This in turn triggers a fallthrough warning in cborparser.c, so we disable this warning.
list(APPEND flags -no-integrated-cpp -Wno-implicit-fallthrough)
endif()
# Work-around for bug https://code.google.com/p/android/issues/detail?id=58135
if (ANDROID)
list(APPEND flags -Wno-error=literal-suffix)
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# Only enable for versions of MSVC that are known to work
# 1941 is Visual Studio 2022 version 17.11
if(MSVC_VERSION LESS_EQUAL 1941)
list(APPEND flags /WX)
endif()
endif()
set(warnings_are_errors_enabled_genex
"$<NOT:$<BOOL:$<TARGET_PROPERTY:QT_SKIP_WARNINGS_ARE_ERRORS>>>")
# Gate everything by the target property
set(common_conditions "$<NOT:$<BOOL:$<TARGET_PROPERTY:QT_SKIP_WARNINGS_ARE_ERRORS>>>")
# Apparently qmake only adds -Werror to CXX and OBJCXX files, not C files. We have to do the
# same otherwise MinGW builds break when building 3rdparty\md4c\md4c.c (and probably on other
# platforms too).
set(cxx_only_genex "$<OR:$<COMPILE_LANGUAGE:CXX>,$<COMPILE_LANGUAGE:OBJCXX>>")
set(final_condition_genex "$<AND:${warnings_are_errors_enabled_genex},${cxx_only_genex}>")
set(flags_generator_expression "$<${final_condition_genex}:${flags}>")
target_compile_options("${target}" ${target_scope} "${flags_generator_expression}")
set(language_args LANGUAGES CXX OBJCXX)
# This property is set to True only if we are using Clang and frontend is MSVC
# Currently we do not set any error flags
set(clang_msvc_frontend_args
"$<NOT:$<BOOL:$<TARGET_PROPERTY:Qt6::PlatformCommonInternal,_qt_internal_clang_msvc_frontend>>>"
)
if(GCC OR CLANG OR WIN32)
# Note: the if check is included to mimic the previous selective gating. These need to
# balance reducing unnecessary compile flags that are evaluated by the genex, and making
# sure the developer has appropriate Werror flags enabled when building a module with
# different environment
qt_internal_add_compiler_dependent_flags("${target}" ${target_scope}
COMPILERS CLANG AppleClang
OPTIONS
-Werror -Wno-error=\#warnings -Wno-error=deprecated-declarations
COMPILERS CLANG
CONDITIONS VERSION_GREATER_EQUAL 10
OPTIONS
# We do mixed enum arithmetic all over the place:
-Wno-error=deprecated-enum-enum-conversion
CONDITIONS VERSION_GREATER_EQUAL 14
OPTIONS
# Clang 14 introduced these two but we are not clean for it.
-Wno-error=deprecated-copy-with-user-provided-copy
-Wno-error=unused-but-set-variable
COMMON_CONDITIONS
${common_conditions}
${clang_msvc_frontend_args}
${language_args}
)
qt_internal_add_compiler_dependent_flags("${target}" ${target_scope}
COMPILERS GNU
OPTIONS
-Werror -Wno-error=cpp -Wno-error=deprecated-declarations
# GCC prints this bogus warning, after it has inlined a lot of code
# error: assuming signed overflow does not occur when assuming that (X + c) < X
# is always false
-Wno-error=strict-overflow
CONDITIONS VERSION_GREATER_EQUAL 7
OPTIONS
# GCC 7 includes -Wimplicit-fallthrough in -Wextra, but Qt is not yet free of
# implicit fallthroughs.
-Wno-error=implicit-fallthrough
CONDITIONS VERSION_GREATER_EQUAL 9
OPTIONS
# GCC 9 introduced these but we are not clean for it.
-Wno-error=deprecated-copy
-Wno-error=redundant-move
-Wno-error=init-list-lifetime
# GCC 9 introduced -Wformat-overflow in -Wall, but it is buggy:
-Wno-error=format-overflow
CONDITIONS VERSION_GREATER_EQUAL 10
OPTIONS
# GCC 10 has a number of bugs in -Wstringop-overflow. Do not make them an error.
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92955
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94335
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101134
-Wno-error=stringop-overflow
CONDITIONS VERSION_GREATER_EQUAL 11
OPTIONS
# Ditto
-Wno-error=stringop-overread
# We do mixed enum arithmetic all over the place:
-Wno-error=deprecated-enum-enum-conversion
-Wno-error=deprecated-enum-float-conversion
CONDITIONS VERSION_GREATER_EQUAL 11.0 AND VERSION_LESS 11.2
OPTIONS
# GCC 11.1 has a regression in the integrated preprocessor, so disable it as a
# workaround (QTBUG-93360)
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100796
# This in turn triggers a fallthrough warning in cborparser.c, so we disable
# this warning.
-no-integrated-cpp -Wno-implicit-fallthrough
CONDITIONS VERSION_LESS 15.1
AND $<BOOL:${QT_FEATURE_sanitize_thread}>
AND $<BOOL:${BUILD_WITH_PCH}>
OPTIONS
# GCC < 15 raises a TSAN warning from Qt's own PCHs, despite the warning
# being suppressed (QTBUG-134415)
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64117
-Wno-error=tsan
COMMON_CONDITIONS
${common_conditions}
${language_args}
)
endif()
# Other options are gated at compile time that are not likely to change between different build
# environments of other modules.
if(ANDROID)
qt_internal_add_compiler_dependent_flags("${target}" ${target_scope}
COMPILERS GNU
CONDITIONS $<PLATFORM_ID:ANDROID>
OPTIONS
# Work-around for bug https://code.google.com/p/android/issues/detail?id=58135
-Wno-error=literal-suffix
COMMON_CONDITIONS
${common_conditions}
${language_args}
)
endif()
if(WIN32)
qt_internal_add_compiler_dependent_flags("${target}" ${target_scope}
COMPILERS MSVC
# Only enable for versions of MSVC that are known to work
# 1941 is Visual Studio 2022 version 17.11
CONDITIONS VERSION_LESS_EQUAL 17.11
OPTIONS
/WX
COMMON_CONDITIONS
${common_conditions}
${language_args}
)
endif()
endfunction()
# The function adds a global 'definition' to the platform internal targets and the target
@ -97,7 +136,7 @@ endfunction()
# APP - set the definition for all Qt applications
# TODO: Add a tests specific platform target and the definition scope for it.
function(qt_internal_add_global_definition definition)
set(optional_args)
set(optional_args "")
set(single_value_args VALUE)
set(multi_value_args SCOPE)
cmake_parse_arguments(arg
@ -248,6 +287,13 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
"$<$<AND:${not_disabled},${is_xcode15}>:LINKER:-no_warn_duplicate_libraries>")
endif()
if(CYGWIN)
# CYGWIN doesn't define _GNU_SOURCE by default for better support with W32API
target_compile_definitions(PlatformCommonInternal INTERFACE
"_GNU_SOURCE"
)
endif()
if(MSVC)
target_compile_definitions(PlatformCommonInternal INTERFACE
"_CRT_SECURE_NO_WARNINGS"
@ -310,6 +356,16 @@ if (MSVC AND NOT CLANG)
)
endif()
set(_qt_internal_clang_msvc_frontend False)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
set(_qt_internal_clang_msvc_frontend True)
endif()
set_target_properties(PlatformCommonInternal
PROPERTIES
_qt_internal_clang_msvc_frontend "${_qt_internal_clang_msvc_frontend}"
)
if(MINGW)
target_compile_options(PlatformCommonInternal INTERFACE -Wa,-mbig-obj)
endif()
@ -318,6 +374,22 @@ if (GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "9.2")
target_compile_options(PlatformCommonInternal INTERFACE $<$<COMPILE_LANGUAGE:CXX>:-Wsuggest-override>)
endif()
if(QT_FEATURE_stdlib_libcpp)
# Disable transitive C++ inclusions when using libc++, on all
# language versions. See
# https://libcxx.llvm.org/DesignDocs/HeaderRemovalPolicy.html
target_compile_definitions(PlatformCommonInternal INTERFACE _LIBCPP_REMOVE_TRANSITIVE_INCLUDES)
endif()
if(QT_USE_CCACHE AND CLANG AND BUILD_WITH_PCH)
# The ccache man page says we must compile with -fno-pch-timestamp when using clang and pch.
foreach(language IN ITEMS C CXX OBJC OBJCXX)
target_compile_options(PlatformCommonInternal INTERFACE
"$<$<COMPILE_LANGUAGE:${language}>:SHELL:-Xclang -fno-pch-timestamp>"
)
endforeach()
endif()
# Hardening options
qt_internal_apply_intel_cet_harderning(PlatformCommonInternal)

View File

@ -28,6 +28,7 @@ function(qt_internal_add_jar target)
get_filename_component(absolute_path "${path}" ABSOLUTE)
list(APPEND absolute_sources "${absolute_path}")
endforeach()
set_property(DIRECTORY APPEND PROPERTY _qt_jar_sources "${absolute_sources}")
add_jar(${target} SOURCES ${absolute_sources} ${ARGV})

View File

@ -114,7 +114,8 @@ macro(qt_internal_setup_platform_definitions_and_mkspec)
endif()
if(CMAKE_CROSSCOMPILING)
set(QT_QMAKE_HOST_MKSPEC "${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_QMAKE_MKSPEC}")
qt_internal_get_host_info_var_prefix(host_info_var_prefix)
set(QT_QMAKE_HOST_MKSPEC "${${host_info_var_prefix}_QMAKE_MKSPEC}")
else()
set(QT_QMAKE_HOST_MKSPEC "${QT_QMAKE_TARGET_MKSPEC}")
endif()

View File

@ -7,9 +7,6 @@ cmake_minimum_required(VERSION @min_new_policy_version@...@max_new_policy_versio
include(CMakeFindDependencyMacro)
get_filename_component(_import_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_import_prefix "${_import_prefix}" REALPATH)
# Extra cmake code begin
@extra_cmake_code@
# Extra cmake code end
@ -29,10 +26,61 @@ endif()
if (NOT QT_NO_CREATE_TARGETS AND @INSTALL_CMAKE_NAMESPACE@@target@_FOUND)
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@AdditionalTargetInfo.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@AdditionalTargetInfo.cmake"
OPTIONAL)
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@ExtraProperties.cmake"
OPTIONAL)
endif()
# Find the private module counterpart.
set(__qt_@target@_always_load_private_module @always_load_private_module@)
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@-build.cmake" OPTIONAL)
if (@INSTALL_CMAKE_NAMESPACE@@target@_FOUND
AND NOT @INSTALL_CMAKE_NAMESPACE@@target_private@_FOUND
AND NOT @arg_NO_PRIVATE_MODULE@
AND (
__qt_@target@_always_load_private_module
OR DEFINED QT_REPO_MODULE_VERSION
OR QT_FIND_PRIVATE_MODULES
)
)
if("${_qt_cmake_dir}" STREQUAL "")
set(_qt_cmake_dir "${QT_TOOLCHAIN_RELOCATABLE_CMAKE_DIR}")
endif()
set(__qt_use_no_default_path_for_qt_packages "NO_DEFAULT_PATH")
if(QT_DISABLE_NO_DEFAULT_PATH_IN_QT_PACKAGES)
set(__qt_use_no_default_path_for_qt_packages "")
endif()
find_package(@INSTALL_CMAKE_NAMESPACE@@target_private@ "@PROJECT_VERSION@" EXACT
QUIET
CONFIG
PATHS
${QT_BUILD_CMAKE_PREFIX_PATH}
"${CMAKE_CURRENT_LIST_DIR}/.."
"${_qt_cmake_dir}"
${_qt_additional_packages_prefix_paths}
${__qt_use_no_default_path_for_qt_packages}
)
if(NOT @INSTALL_CMAKE_NAMESPACE@@target_private@_FOUND)
get_property(@INSTALL_CMAKE_NAMESPACE@@target_private@_warning_shown GLOBAL PROPERTY
@INSTALL_CMAKE_NAMESPACE@@target_private@_warning_shown
)
if(NOT @INSTALL_CMAKE_NAMESPACE@@target_private@_warning_shown)
message(VERBOSE
"The private module package '@INSTALL_CMAKE_NAMESPACE@@target_private@' "
"could not be found. It possibly needs to be installed separately with your "
"package manager."
)
set_property(GLOBAL PROPERTY
@INSTALL_CMAKE_NAMESPACE@@target_private@_warning_shown ON
)
endif()
endif()
endif()
unset(__qt_@target@_always_load_private_module)
if (NOT QT_NO_CREATE_TARGETS AND @INSTALL_CMAKE_NAMESPACE@@target@_FOUND)
# DEPRECATED
# Provide old style variables for includes, compile definitions, etc.
# These variables are deprecated and only provided on a best-effort basis to facilitate porting.
@ -120,18 +168,28 @@ if (TARGET @QT_CMAKE_EXPORT_NAMESPACE@::@target@)
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Plugins.cmake")
endif()
list(APPEND QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE "@target@")
if(NOT "@target@" IN_LIST QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE)
list(APPEND QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE "@target@")
list(APPEND QT_ALL_MODULES_VERSIONED_FOUND_VIA_FIND_PACKAGE
"@INSTALL_CMAKE_NAMESPACE@::@target@")
endif()
get_target_property(_qt_module_target_type "@INSTALL_CMAKE_NAMESPACE@::@target@" TYPE)
if(NOT _qt_module_target_type STREQUAL "INTERFACE_LIBRARY")
get_target_property(_qt_module_plugin_types
@INSTALL_CMAKE_NAMESPACE@::@target@ MODULE_PLUGIN_TYPES)
if(_qt_module_plugin_types)
list(APPEND QT_ALL_PLUGIN_TYPES_FOUND_VIA_FIND_PACKAGE "${_qt_module_plugin_types}")
foreach(_qt_module_plugin_type IN LISTS _qt_module_plugin_types)
if(NOT "${_qt_module_plugin_type}"
IN_LIST QT_ALL_PLUGIN_TYPES_FOUND_VIA_FIND_PACKAGE)
list(APPEND QT_ALL_PLUGIN_TYPES_FOUND_VIA_FIND_PACKAGE
"${_qt_module_plugin_type}")
endif()
endforeach()
unset(_qt_module_plugin_type)
endif()
endif()
# Load Module's BuildInternals should any exist
if (@INSTALL_CMAKE_NAMESPACE@BuildInternals_DIR AND
EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@BuildInternals.cmake")

View File

@ -0,0 +1,55 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
@PACKAGE_INIT@
cmake_minimum_required(VERSION @min_new_policy_version@...@max_new_policy_version@)
include(CMakeFindDependencyMacro)
# Find required dependencies, if any.
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target_private@Dependencies.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target_private@Dependencies.cmake")
_qt_internal_suggest_dependency_debugging(@target_private@
__qt_@target_private@_pkg ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE)
endif()
# If *ConfigDependencies.cmake exists, the variable value will be defined there.
# Don't override it in that case.
if(NOT DEFINED "@INSTALL_CMAKE_NAMESPACE@@target_private@_FOUND")
set("@INSTALL_CMAKE_NAMESPACE@@target_private@_FOUND" TRUE)
endif()
if(NOT __qt_@target@_always_load_private_module)
_qt_internal_show_private_module_warning(@target_private@)
endif()
if(NOT QT_NO_CREATE_TARGETS AND @INSTALL_CMAKE_NAMESPACE@@target_private@_FOUND)
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target_private@Targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target_private@AdditionalTargetInfo.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target_private@ExtraProperties.cmake"
OPTIONAL)
endif()
if(TARGET @QT_CMAKE_EXPORT_NAMESPACE@::@target_private@)
if(NOT QT_NO_CREATE_VERSIONLESS_TARGETS)
if(CMAKE_VERSION VERSION_LESS 3.18 OR QT_USE_OLD_VERSION_LESS_TARGETS)
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target_private@VersionlessTargets.cmake")
else()
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target_private@VersionlessAliasTargets.cmake")
endif()
endif()
else()
set(@INSTALL_CMAKE_NAMESPACE@@target_private@_FOUND FALSE)
if(NOT DEFINED @INSTALL_CMAKE_NAMESPACE@@target_private@_NOT_FOUND_MESSAGE)
set(@INSTALL_CMAKE_NAMESPACE@@target_private@_NOT_FOUND_MESSAGE
"Target \"@QT_CMAKE_EXPORT_NAMESPACE@::@target_private@\" was not found.")
if(QT_NO_CREATE_TARGETS)
string(APPEND @INSTALL_CMAKE_NAMESPACE@@target_private@_NOT_FOUND_MESSAGE
"Possibly due to QT_NO_CREATE_TARGETS being set to TRUE and thus "
"${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target_private@Targets.cmake was not "
"included to define the target.")
endif()
endif()
endif()

View File

@ -32,16 +32,20 @@ endif()
set(__qt_@target@_third_party_deps "@third_party_deps@")
@third_party_deps_extra_info@
_qt_internal_find_third_party_dependencies("@target@" __qt_@target@_third_party_deps)
unset(__qt_@target@_third_party_deps)
# Find Qt tool package.
set(__qt_@target@_tool_deps "@main_module_tool_deps@")
_qt_internal_find_tool_dependencies("@target@" __qt_@target@_tool_deps)
unset(__qt_@target@_tool_deps)
# note: target_deps example: "Qt6Core\;5.12.0;Qt6Gui\;5.12.0"
set(__qt_@target@_target_deps "@target_deps@")
set(__qt_@target@_find_dependency_paths "${CMAKE_CURRENT_LIST_DIR}/.." "${_qt_cmake_dir}")
_qt_internal_find_qt_dependencies("@target@" __qt_@target@_target_deps
__qt_@target@_find_dependency_paths)
unset(__qt_@target@_target_deps)
unset(__qt_@target@_find_dependency_paths)
set(_@QT_CMAKE_EXPORT_NAMESPACE@@target@_MODULE_DEPENDENCIES "@qt_module_dependencies@")
set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND TRUE)

View File

@ -5,6 +5,7 @@ macro(qt_internal_get_internal_add_module_keywords option_args single_args multi
set(${option_args}
STATIC
EXCEPTIONS
FIND_PRIVATE_MODULE
INTERNAL_MODULE
HEADER_MODULE
DISABLE_TOOLS_EXPORT
@ -81,7 +82,6 @@ endfunction()
# Options:
# NO_ADDITIONAL_TARGET_INFO
# Don't generate a Qt6*AdditionalTargetInfo.cmake file.
# The caller is responsible for creating one.
#
# MODULE_INTERFACE_NAME
# The custom name of the module interface. This name is used as a part of the include paths
@ -131,6 +131,9 @@ endfunction()
# ignored by syncqt. The specifying this directory allows to skip the parsing of the whole
# CMAKE_CURRENT_SOURCE_DIR for the header files that needs to be synced and only parse the
# single subdirectory, that meanwhile can be outside the CMAKE_CURRENT_SOURCE_DIR tree.
#
# FIND_PRIVATE_MODULE
# A call to find_package(Qt6Foo) will imply a call to find_package(Qt6FooPrivate).
function(qt_internal_add_module target)
qt_internal_get_internal_add_module_keywords(
module_option_args
@ -213,6 +216,17 @@ function(qt_internal_add_module target)
"_qt_package_version"
"_qt_package_name"
)
if(CMAKE_VERSION VERSION_LESS 3.30)
# For the CMake versions higher than 3.30 the corresponding INTERFACE_
# properties will be in Qt<Module>Targets.cmake without extra code
# needed.
list(APPEND export_properties
"_qt_transitive_compile_properties"
"_qt_transitive_link_properties"
)
endif()
if(NOT is_internal_module)
set_target_properties(${target} PROPERTIES
_qt_is_public_module TRUE
@ -251,10 +265,9 @@ function(qt_internal_add_module target)
set(module_config_private_header "qt${arg_CONFIG_MODULE_NAME}-config_p.h")
# qt<module>-config.h/-config_p.h header files are not marked as GENERATED automatically
# for old CMake versions. Set the property explicitly here.
set_source_files_properties("${module_config_header}" "${module_config_private_header}"
PROPERTIES
GENERATED TRUE
SKIP_AUTOGEN TRUE
_qt_internal_set_source_file_generated(
SOURCES "${module_config_header}" "${module_config_private_header}"
SKIP_AUTOGEN
)
# Module define needs to take into account the config module name.
@ -327,7 +340,7 @@ function(qt_internal_add_module target)
set_target_properties(${target_private} PROPERTIES
_qt_config_module_name ${arg_CONFIG_MODULE_NAME}_private
_qt_package_version "${PROJECT_VERSION}"
_qt_package_name "${INSTALL_CMAKE_NAMESPACE}${target}"
_qt_package_name "${INSTALL_CMAKE_NAMESPACE}${target}Private"
_qt_is_private_module TRUE
_qt_public_module_target_name "${target}"
)
@ -340,6 +353,9 @@ function(qt_internal_add_module target)
)
set_property(TARGET "${target_private}" APPEND PROPERTY
EXPORT_PROPERTIES "${export_properties}")
# Let find_package(Qt6FooPrivate) also find_package(Qt6Foo).
qt_internal_register_target_dependencies("${target_private}" PUBLIC "Qt::${target}")
endif()
# FIXME: This workaround is needed because the deployment logic
@ -442,13 +458,31 @@ function(qt_internal_add_module target)
set(module_depends_header
"${module_build_interface_include_dir}/${module_include_name}Depends")
set_source_files_properties("${module_depends_header}" PROPERTIES GENERATED TRUE)
_qt_internal_set_source_file_generated(SOURCES "${module_depends_header}")
set_target_properties(${target} PROPERTIES _qt_module_depends_header
"${module_depends_header}")
if(NOT arg_HEADER_MODULE)
set(module_header "${module_build_interface_include_dir}/${module_include_name}")
set_property(TARGET "${target}" PROPERTY MODULE_HEADER
"${module_header}")
if(QT_FEATURE_no_prefix)
file(RELATIVE_PATH relative_include_dir
"/${QT_CONFIG_INSTALL_DIR}/${module_include_name}"
"/${module_build_interface_include_dir}"
)
else()
file(RELATIVE_PATH relative_include_dir
"/${QT_CONFIG_INSTALL_DIR}/${module_include_name}"
"/${module_install_interface_include_dir}"
)
endif()
set_property(TARGET "${target}" PROPERTY
_qt_module_relative_include_dir "${relative_include_dir}"
)
set_property(TARGET ${target} APPEND PROPERTY
EXPORT_PROPERTIES _qt_module_relative_include_dir
)
endif()
set(qpa_filter_regex "")
@ -659,7 +693,7 @@ function(qt_internal_add_module target)
# thus we can't use qt_internal_extend_target()'s PUBLIC_DEFINES option.
target_compile_definitions(${target} INTERFACE QT_${module_define_infix}_LIB)
if(NOT DEFINED arg_EXCEPTIONS)
if(NOT arg_EXCEPTIONS)
qt_internal_set_exceptions_flags("${target}" "DEFAULT")
else()
qt_internal_set_exceptions_flags("${target}" "${arg_EXCEPTIONS}")
@ -691,6 +725,12 @@ function(qt_internal_add_module target)
set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${target}")
qt_path_join(config_build_dir ${QT_CONFIG_BUILD_DIR} ${path_suffix})
qt_path_join(config_install_dir ${QT_CONFIG_INSTALL_DIR} ${path_suffix})
if(NOT arg_NO_PRIVATE_MODULE)
set(path_suffix "${INSTALL_CMAKE_NAMESPACE}${target_private}")
qt_path_join(private_config_build_dir ${QT_CONFIG_BUILD_DIR} ${path_suffix})
qt_path_join(private_config_install_dir ${QT_CONFIG_INSTALL_DIR} ${path_suffix})
endif()
unset(path_suffix)
set(extra_cmake_files)
set(extra_cmake_includes)
@ -699,6 +739,21 @@ function(qt_internal_add_module target)
list(APPEND extra_cmake_includes "${INSTALL_CMAKE_NAMESPACE}${target}Macros.cmake")
endif()
if(CMAKE_VERSION VERSION_LESS 3.30)
# For the CMake versions higher than 3.30 the corresponding INTERFACE_
# properties will be in Qt<Module>Targets.cmake without extra code
# needed.
configure_file(
"${QT_CMAKE_DIR}/QtTransitiveExtras.cmake.in"
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}TransitiveExtras.cmake"
@ONLY
)
list(APPEND extra_cmake_files
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}TransitiveExtras.cmake")
list(APPEND extra_cmake_includes
"${INSTALL_CMAKE_NAMESPACE}${target}TransitiveExtras.cmake")
endif()
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigExtras.cmake.in")
if(target STREQUAL Core)
if(NOT "${QT_NAMESPACE}" STREQUAL "")
@ -739,12 +794,20 @@ set(QT_ALLOW_MISSING_TOOLS_PACKAGES TRUE)")
endif()
foreach(cmake_file IN LISTS arg_EXTRA_CMAKE_FILES)
get_filename_component(basename ${cmake_file} NAME)
file(COPY ${cmake_file} DESTINATION ${config_build_dir})
list(APPEND extra_cmake_files "${config_build_dir}/${basename}")
get_source_file_property(install_path ${cmake_file} QT_INSTALL_PATH)
if(NOT install_path)
# Sanitize the install_path from `NOTFOUND` to ""
set(install_path "")
endif()
file(COPY ${cmake_file} DESTINATION "${config_build_dir}/${install_path}")
qt_install(FILES
${cmake_file}
DESTINATION "${config_install_dir}/${install_path}"
COMPONENT Devel
)
# Make sure touched extra cmake files cause a reconfigure, so they get re-copied.
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${cmake_file}")
_qt_internal_append_cmake_configure_depends("${cmake_file}")
endforeach()
list(APPEND extra_cmake_includes ${arg_EXTRA_CMAKE_INCLUDES})
@ -781,10 +844,24 @@ set(QT_ALLOW_MISSING_TOOLS_PACKAGES TRUE)")
qt_internal_get_min_new_policy_cmake_version(min_new_policy_version)
qt_internal_get_max_new_policy_cmake_version(max_new_policy_version)
configure_package_config_file(
"${QT_CMAKE_DIR}/QtModuleConfig.cmake.in"
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Config.cmake"
INSTALL_DESTINATION "${config_install_dir}"
if(is_static_lib)
set(write_basic_module_package_args IS_STATIC_LIB)
else()
set(write_basic_module_package_args "")
endif()
if(arg_FIND_PRIVATE_MODULE)
set(write_basic_public_module_package_args FIND_PRIVATE_MODULE)
else()
set(write_basic_public_module_package_args "")
endif()
qt_internal_write_basic_module_package("${target}" "${target_private}"
${write_basic_module_package_args}
${write_basic_public_module_package_args}
CONFIG_BUILD_DIR ${config_build_dir}
CONFIG_INSTALL_DIR ${config_install_dir}
)
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}BuildInternals.cmake")
@ -794,38 +871,40 @@ set(QT_ALLOW_MISSING_TOOLS_PACKAGES TRUE)")
list(APPEND extra_cmake_files "${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}BuildInternals.cmake")
endif()
write_basic_package_version_file(
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigVersionImpl.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
qt_internal_write_qt_package_version_file(
"${INSTALL_CMAKE_NAMESPACE}${target}"
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigVersion.cmake"
)
qt_install(FILES
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Config.cmake"
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigVersion.cmake"
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigVersionImpl.cmake"
${extra_cmake_files}
DESTINATION "${config_install_dir}"
COMPONENT Devel
)
file(COPY ${extra_cmake_files} DESTINATION "${config_build_dir}")
set(exported_targets ${target})
if(NOT ${arg_NO_PRIVATE_MODULE})
list(APPEND exported_targets ${target_private})
if(NOT arg_NO_PRIVATE_MODULE)
qt_internal_write_basic_module_package("${target}" "${target_private}"
${write_basic_module_package_args}
PRIVATE
CONFIG_BUILD_DIR ${private_config_build_dir}
CONFIG_INSTALL_DIR ${private_config_install_dir}
)
endif()
set(export_name "${INSTALL_CMAKE_NAMESPACE}${target}Targets")
qt_install(TARGETS ${exported_targets}
EXPORT ${export_name}
RUNTIME DESTINATION ${INSTALL_BINDIR}
LIBRARY DESTINATION ${INSTALL_LIBDIR}
ARCHIVE DESTINATION ${INSTALL_LIBDIR}
FRAMEWORK DESTINATION ${INSTALL_LIBDIR}
file(COPY ${extra_cmake_files} DESTINATION "${config_build_dir}")
_qt_internal_forward_function_args(
FORWARD_PREFIX arg
FORWARD_OUT_VAR export_module_args
FORWARD_OPTIONS NO_ADDITIONAL_TARGET_INFO
)
qt_internal_export_module(${target}
${export_module_args}
CONFIG_BUILD_DIR ${config_build_dir}
CONFIG_INSTALL_DIR ${config_install_dir}
)
if(NOT arg_NO_PRIVATE_MODULE)
qt_internal_export_module(${target_private}
${export_module_args}
CONFIG_BUILD_DIR ${private_config_build_dir}
CONFIG_INSTALL_DIR ${private_config_install_dir}
)
endif()
if(BUILD_SHARED_LIBS)
qt_apply_rpaths(TARGET "${target}" INSTALL_PATH "${INSTALL_LIBDIR}" RELATIVE_RPATH)
@ -839,29 +918,6 @@ set(QT_ALLOW_MISSING_TOOLS_PACKAGES TRUE)")
QT_ANDROID_MODULE_INSTALL_DIR ${INSTALL_LIBDIR})
endif()
qt_install(EXPORT ${export_name}
NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE}::
DESTINATION ${config_install_dir})
if(NOT arg_NO_ADDITIONAL_TARGET_INFO)
qt_internal_export_additional_targets_file(
TARGETS ${exported_targets}
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}${target}
CONFIG_INSTALL_DIR "${config_install_dir}")
endif()
qt_internal_export_modern_cmake_config_targets_file(
TARGETS ${exported_targets}
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}${target}
CONFIG_BUILD_DIR "${config_build_dir}"
CONFIG_INSTALL_DIR "${config_install_dir}"
)
qt_internal_export_genex_properties(TARGETS ${target}
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}${target}
CONFIG_INSTALL_DIR "${config_install_dir}"
)
### fixme: cmake is missing a built-in variable for this. We want to apply it only to modules and plugins
# that belong to Qt.
if(NOT arg_HEADER_MODULE)
@ -980,12 +1036,133 @@ set(QT_ALLOW_MISSING_TOOLS_PACKAGES TRUE)")
${__qt_internal_sbom_multi_args}
)
_qt_internal_extend_sbom(${target} ${sbom_args})
qt_internal_extend_qt_entity_sbom(${target} ${sbom_args})
endif()
qt_add_list_file_finalizer(qt_finalize_module ${target} ${arg_INTERNAL_MODULE} ${arg_NO_PRIVATE_MODULE})
endfunction()
# Write and install the basic Qt6Foo and Qt6FooPrivate packages.
#
# If PRIVATE is specified, write Qt6FooPrivate.
# Otherwise write its public counterpart.
function(qt_internal_write_basic_module_package target target_private)
set(no_value_options
FIND_PRIVATE_MODULE
IS_STATIC_LIB
PRIVATE
)
set(single_value_options
CONFIG_BUILD_DIR
CONFIG_INSTALL_DIR
)
set(multi_value_options "")
cmake_parse_arguments(PARSE_ARGV 0 arg
"${no_value_options}" "${single_value_options}" "${multi_value_options}"
)
set(always_load_private_module OFF)
if(arg_PRIVATE)
set(package_name "${INSTALL_CMAKE_NAMESPACE}${target_private}")
set(module_config_input_file "QtModuleConfigPrivate.cmake.in")
else()
set(package_name "${INSTALL_CMAKE_NAMESPACE}${target}")
set(module_config_input_file "QtModuleConfig.cmake.in")
if(arg_FIND_PRIVATE_MODULE)
set(always_load_private_module ON)
endif()
endif()
if((QT_FEATURE_no_prefix OR arg_IS_STATIC_LIB)
AND NOT arg_PRIVATE
AND CMAKE_VERSION VERSION_LESS "3.26")
# We auto-load the private module package from the public module package if we have a
# statically built module or a non-prefix build and CMake's version is < 3.26. This is
# needed for the case "Qt6Foo links against Qt6BarPrivate", because CMake generates a check
# for the target Qt6::BarPrivate in Qt6FooTargets.cmake. Once we can require CMake 3.26, we
# can simply link against $<BUILD_LOCAL_INTERFACE:Qt6BarPrivate> in
# qt_internal_extend_target.
#
# For older CMake versions, we create an additional CMake file that's optionally included by
# Qt6FooConfig.cmake to work around the lack of BUILD_LOCAL_INTERFACE.
file(CONFIGURE
OUTPUT "${arg_CONFIG_BUILD_DIR}/${package_name}-build.cmake"
CONTENT "# This file marks this directory as part of Qt's build tree.
set(__qt_${target}_always_load_private_module ON)
"
)
endif()
configure_package_config_file(
"${QT_CMAKE_DIR}/${module_config_input_file}"
"${arg_CONFIG_BUILD_DIR}/${package_name}Config.cmake"
INSTALL_DESTINATION "${arg_CONFIG_INSTALL_DIR}"
)
write_basic_package_version_file(
"${arg_CONFIG_BUILD_DIR}/${package_name}ConfigVersionImpl.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
qt_internal_write_qt_package_version_file(
"${package_name}"
"${arg_CONFIG_BUILD_DIR}/${package_name}ConfigVersion.cmake"
)
qt_install(FILES
"${arg_CONFIG_BUILD_DIR}/${package_name}Config.cmake"
"${arg_CONFIG_BUILD_DIR}/${package_name}ConfigVersion.cmake"
"${arg_CONFIG_BUILD_DIR}/${package_name}ConfigVersionImpl.cmake"
DESTINATION "${arg_CONFIG_INSTALL_DIR}"
COMPONENT Devel
)
endfunction()
function(qt_internal_export_module target)
set(no_value_options
NO_ADDITIONAL_TARGET_INFO
)
set(single_value_options
CONFIG_BUILD_DIR
CONFIG_INSTALL_DIR
)
set(multi_value_options "")
cmake_parse_arguments(PARSE_ARGV 1 arg
"${no_value_options}" "${single_value_options}" "${multi_value_options}"
)
_qt_internal_validate_all_args_are_parsed(arg)
set(export_name "${INSTALL_CMAKE_NAMESPACE}${target}Targets")
qt_install(TARGETS ${target}
EXPORT ${export_name}
RUNTIME DESTINATION ${INSTALL_BINDIR}
LIBRARY DESTINATION ${INSTALL_LIBDIR}
ARCHIVE DESTINATION ${INSTALL_LIBDIR}
FRAMEWORK DESTINATION ${INSTALL_LIBDIR}
)
qt_install(EXPORT ${export_name}
NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE}::
DESTINATION ${arg_CONFIG_INSTALL_DIR})
if(NOT arg_NO_ADDITIONAL_TARGET_INFO)
qt_internal_export_additional_targets_file(
TARGETS ${target}
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}${target}
CONFIG_INSTALL_DIR "${arg_CONFIG_INSTALL_DIR}")
endif()
qt_internal_export_modern_cmake_config_targets_file(
TARGETS ${target}
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}${target}
CONFIG_BUILD_DIR "${arg_CONFIG_BUILD_DIR}"
CONFIG_INSTALL_DIR "${arg_CONFIG_INSTALL_DIR}"
)
qt_internal_export_genex_properties(TARGETS ${target}
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}${target}
CONFIG_INSTALL_DIR "${arg_CONFIG_INSTALL_DIR}"
)
endfunction()
function(qt_internal_apply_apple_privacy_manifest target)
# Avoid "INTERFACE_LIBRARY targets may only have whitelisted properties" error on CMake < 3.17.
get_target_property(target_type ${target} TYPE)
@ -1009,15 +1186,47 @@ function(qt_internal_apply_apple_privacy_manifest target)
endfunction()
function(qt_finalize_module target)
set(no_value_options
INTERNAL_MODULE
NO_PRIVATE_MODULE
)
set(single_value_options "")
set(multi_value_options "")
cmake_parse_arguments(PARSE_ARGV 1 arg
"${no_value_options}" "${single_value_options}" "${multi_value_options}"
)
_qt_internal_validate_all_args_are_parsed(arg)
qt_internal_collect_module_headers(module_headers ${target})
# Issue a warning if we
# - suppressed creation of the private module but have private headers
# - created a private module but don't have any private headers
if(NOT arg_INTERNAL_MODULE)
get_target_property(has_private_headers ${target} _qt_module_has_private_headers)
if(arg_NO_PRIVATE_MODULE AND has_private_headers)
message(AUTHOR_WARNING
"Module ${target} has private headers. "
"Please remove NO_PRIVATE_MODULE from its creation flags."
)
elseif(NOT arg_NO_PRIVATE_MODULE AND NOT has_private_headers)
message(AUTHOR_WARNING
"Module ${target} does not have private headers. "
"Please add NO_PRIVATE_MODULE to its creation flags."
)
endif()
endif()
# qt_internal_install_module_headers needs to be called before
# qt_finalize_framework_headers_copy, because the last uses the QT_COPIED_FRAMEWORK_HEADERS
# property which supposed to be updated inside every qt_internal_install_module_headers
# call.
qt_internal_add_headersclean_target(${target} "${module_headers_public}")
qt_internal_target_sync_headers(${target} "${module_headers_all}"
"${module_headers_generated}")
qt_internal_target_sync_headers(${target}
"${module_headers_all}"
"${module_headers_generated}"
"${module_headers_exclude_from_docs}"
)
get_target_property(module_depends_header ${target} _qt_module_depends_header)
qt_internal_install_module_headers(${target}
PUBLIC ${module_headers_public} "${module_depends_header}"
@ -1231,7 +1440,12 @@ function(qt_describe_module target)
qt_path_join(install_dir ${QT_INSTALL_DIR} ${path_suffix})
set(descfile_in "${QT_CMAKE_DIR}/ModuleDescription.json.in")
# IMPORTANT: If you adjust the file name not to be the exact target name and thus the CMake
# package name, it needs to consider also the code in QtConfig.cmake.in that globs the json
# files.
set(descfile_out "${build_dir}/${target}.json")
string(TOLOWER "${PROJECT_NAME}" lower_case_project_name)
set(extra_module_information "")
set(platforms_information "")
@ -1379,7 +1593,12 @@ function(qt_internal_generate_cpp_global_exports target module_define_infix)
set(${out_public_header} "${generated_header_path}" PARENT_SCOPE)
target_sources(${target} PRIVATE "${generated_header_path}")
set_source_files_properties("${generated_header_path}" PROPERTIES GENERATED TRUE)
_qt_internal_set_source_file_generated(
SOURCES "${generated_header_path}"
CONFIGURE_GENERATED
)
# Make sure the file is installed when processed by `qt_internal_collect_module_headers`
set_source_files_properties("${generated_header_path}" PROPERTIES _qt_syncqt_force_include TRUE)
endfunction()
function(qt_internal_install_module_headers target)
@ -1437,6 +1656,7 @@ endfunction()
function(qt_internal_collect_module_headers out_var target)
set(${out_var}_public "")
set(${out_var}_private "")
set(${out_var}_exclude_from_docs "")
set(${out_var}_qpa "")
set(${out_var}_rhi "")
set(${out_var}_ssg "")
@ -1477,16 +1697,13 @@ function(qt_internal_collect_module_headers out_var target)
get_filename_component(file_path "${file_path}" ABSOLUTE)
string(FIND "${file_path}" "${source_dir}" source_dir_pos)
if(source_dir_pos EQUAL 0)
set(is_outside_module_source_dir FALSE)
else()
set(is_outside_module_source_dir TRUE)
endif()
_qt_internal_path_is_prefix(source_dir "${file_path}" is_inside_module_source_dir)
get_source_file_property(forced_include "${file_path}" _qt_syncqt_force_include)
get_source_file_property(is_generated "${file_path}" GENERATED)
# Skip all header files outside the module source directory, except the generated files.
if(is_outside_module_source_dir AND NOT is_generated)
# Skip all header files outside the module source directory, except the generated files,
# or files explicitly marked to be included for syncqt.
if(NOT (forced_include OR is_inside_module_source_dir OR is_generated))
continue()
endif()
@ -1498,10 +1715,10 @@ function(qt_internal_collect_module_headers out_var target)
"\nCondition:\n ${condition_string}")
endif()
if(is_outside_module_source_dir)
set(base_dir "${binary_dir}")
else()
if(is_inside_module_source_dir)
set(base_dir "${source_dir}")
else()
set(base_dir "${binary_dir}")
endif()
file(RELATIVE_PATH file_path_rel "${base_dir}" "${file_path}")
@ -1511,6 +1728,12 @@ function(qt_internal_collect_module_headers out_var target)
set(is_3rdparty_header FALSE)
endif()
list(APPEND ${out_var}_all "${file_path}")
get_source_file_property(exclude_from_docs "${file_path}" _qt_syncqt_exclude_from_docs)
if(exclude_from_docs)
list(APPEND ${out_var}_exclude_from_docs "${file_path}")
endif()
if(qpa_filter AND file_name MATCHES "${qpa_filter}")
list(APPEND ${out_var}_qpa "${file_path}")
elseif(rhi_filter AND file_name MATCHES "${rhi_filter}")
@ -1553,6 +1776,7 @@ function(qt_internal_collect_module_headers out_var target)
endforeach()
set(${out_var}_all "${${out_var}_all}" PARENT_SCOPE)
set(${out_var}_generated "${${out_var}_generated}" PARENT_SCOPE)
set(${out_var}_exclude_from_docs "${${out_var}_exclude_from_docs}" PARENT_SCOPE)
if(has_header_types_properties)
set_target_properties(${target} PROPERTIES ${has_header_types_properties})
@ -1566,3 +1790,100 @@ function(qt_internal_collect_module_headers out_var target)
_qt_module_has_ssg_headers
)
endfunction()
# Set the value of the respective module properties and make the properties
# transitive. The property is not stored as target property, but is set as
# INTERFACE property, so its value is not considered by target itself, but only
# by depending targets. Also this require all properties have the
# INTERFACE_<property_name> name format.
#
# Synopsis
# qt_internal_set_module_transitive_properties(<target>
# PROPERTIES <prop1> <value1> [<prop2> <value2>] ...
# )
#
# Arguments
#
# `target` Qt module target. Unlike CMake set_target_properties this function
# accepts only one target as argument.
#
# `PROPERTIES` List of the property name-value pairs.
#
# `TYPE` The transitive property type: COMPILE or LINK.
function(qt_internal_set_module_transitive_properties target)
cmake_parse_arguments(PARSE_ARGV 1 arg "" "TYPE" "PROPERTIES")
if(NOT arg_PROPERTIES)
message(FATAL_ERROR "PROPERTIES argument is missing.")
endif()
if(NOT arg_TYPE)
message(FATAL_ERROR "TYPE argument is missing.")
endif()
list(LENGTH arg_PROPERTIES count)
math(EXPR even_args_count "${count} % 2")
if(NOT even_args_count EQUAL 0)
message(FATAL_ERROR "Insufficient number of PROPERTIES values.")
endif()
_qt_internal_dealias_target(target)
set(property_names "")
set(internal_property_names "")
math(EXPR last "${count} - 1")
foreach(name_idx RANGE 0 ${last} 2)
list(GET arg_PROPERTIES ${name_idx} interface_property_name)
if(interface_property_name MATCHES "^INTERFACE_(.+)$")
set(property_name "${CMAKE_MATCH_1}")
else()
message(FATAL_ERROR "Incorrect property name ${interface_property_name}. The property"
" name must have the INTERFACE_ prefix. Use regular set_target_properties call to set"
" the non-transitive property.")
endif()
string(TOLOWER "${property_name}" property_name_lower)
list(APPEND property_names ${property_name})
math(EXPR value_idx "${name_idx} + 1")
list(GET arg_PROPERTIES ${value_idx} property_value)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.30)
# The collected interface properties exposed in module build tree and have the
# same transitive capabilities as after the module is installed. Supported for
# CMake version >= 3.30
set_property(TARGET ${target} PROPERTY ${interface_property_name} "${property_value}")
else()
# Internal properties are exported within the Qt module. They have limitations that
# EXPORT_PROPERTIES apply. These properties are exported even if we are building Qt
# with CMake versions that do not support transitive properties. It allows using
# them as transitive properties in user projects if CMake allows this.
list(APPEND internal_property_names _qt_internal_${property_name_lower})
set_property(TARGET ${target} PROPERTY
_qt_internal_${property_name_lower} "${property_value}")
endif()
_qt_internal_add_transitive_property(${target} ${arg_TYPE} ${property_name})
endforeach()
get_target_property(transitive_properties ${target} _qt_transitive_${type_lower}_properties)
if(NOT transitive_properties)
set(transitive_properties "")
endif()
list(APPEND transitive_properties ${property_names})
list(REMOVE_DUPLICATES transitive_properties)
get_target_property(export_properties ${target} EXPORT_PROPERTIES)
if(NOT export_properties)
set(export_properties "")
endif()
list(APPEND export_properties ${internal_property_names})
list(REMOVE_DUPLICATES export_properties)
string(TOLOWER "${arg_TYPE}" type_lower)
set_target_properties(${target} PROPERTIES
EXPORT_PROPERTIES "${export_properties}"
_qt_transitive_${type_lower}_properties "${transitive_properties}"
)
endfunction()

View File

@ -2,15 +2,10 @@
# SPDX-License-Identifier: BSD-3-Clause
# Find "ModuleTools" dependencies, which are other ModuleTools packages.
set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE)
set(__qt_@target@_tool_deps "@package_deps@")
foreach(__qt_@target@_target_dep ${__qt_@target@_tool_deps})
list(GET __qt_@target@_target_dep 0 __qt_@target@_pkg)
list(GET __qt_@target@_target_dep 1 __qt_@target@_version)
if (NOT ${__qt_@target@_pkg}_FOUND)
find_dependency(${__qt_@target@_pkg} ${__qt_@target@_version})
endif()
endforeach()
set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND TRUE)
set(__qt_@target@_tool_third_party_deps "@third_party_deps@")
_qt_internal_find_third_party_dependencies("@target@" __qt_@target@_tool_third_party_deps)
set(__qt_@target@_tool_deps "@package_deps@")
_qt_internal_find_tool_dependencies("@target@" __qt_@target@_tool_deps)

View File

@ -22,8 +22,7 @@ endmacro()
# Create a Qt6*.pc file intended for pkg-config consumption.
function(qt_internal_generate_pkg_config_file module)
# TODO: PkgConfig is supported under MSVC with pkgconf (github.com/pkgconf/pkgconf)
if((NOT UNIX OR QT_FEATURE_framework)
AND NOT MINGW OR CMAKE_VERSION VERSION_LESS "3.20" OR ANDROID)
if(NOT UNIX AND NOT MINGW OR CMAKE_VERSION VERSION_LESS "3.20" OR ANDROID)
return()
endif()
if(NOT BUILD_SHARED_LIBS)
@ -34,7 +33,6 @@ function(qt_internal_generate_pkg_config_file module)
set(pkgconfig_name "${QT_CMAKE_EXPORT_NAMESPACE} ${module}")
set(pkgconfig_description "Qt ${module} module")
set(target "${QT_CMAKE_EXPORT_NAMESPACE}::${module}")
set(is_interface_library "$<STREQUAL:$<TARGET_PROPERTY:${target},TYPE>,INTERFACE_LIBRARY>")
# The flags macro expanded this variables so it's better to set them at
# their corresponding PkgConfig string.
set(includedir "\${includedir}")
@ -50,6 +48,12 @@ function(qt_internal_generate_pkg_config_file module)
get_target_property(loose_include_dirs ${target} INTERFACE_INCLUDE_DIRECTORIES)
list(TRANSFORM loose_include_dirs REPLACE "${INSTALL_INCLUDEDIR}" "\${includedir}")
list(TRANSFORM loose_include_dirs REPLACE "${INSTALL_MKSPECSDIR}" "\${mkspecsdir}")
if(QT_FEATURE_framework)
# Update the include path for framework headers which are located in INSTALL_LIBDIR,
# e.g. this results in -I${libdir}/Qt*.framework/Headers for Qt6*.pc file.
set(libdir "\${libdir}")
list(TRANSFORM loose_include_dirs REPLACE "${INSTALL_LIBDIR}" "\${libdir}")
endif()
# Remove genex wrapping around gc_sections flag because we can't evaluate genexes like
# $<CXX_COMPILER_ID> in file(GENERATE). And given that .pc files don't support dynamic
@ -69,6 +73,17 @@ function(qt_internal_generate_pkg_config_file module)
set(contains_mkspecs TRUE)
endif()
get_target_property(type ${target} TYPE)
if(NOT type STREQUAL "INTERFACE_LIBRARY")
get_target_property(is_framework ${target} FRAMEWORK)
if(is_framework)
qt_internal_get_framework_info(fw ${target})
string(PREPEND link_options "-F\${libdir} -framework ${fw_name} ")
else()
string(PREPEND link_options "-L\${libdir} -l${pkgconfig_file} ")
endif()
endif()
# TODO: Handle macOS framework builds
qt_internal_collect_direct_target_dependencies(${target} loose_target_requires)
foreach(dep IN LISTS loose_target_requires)

View File

@ -23,59 +23,7 @@ if (NOT IS_DIRECTORY "${ANDROID_SDK_ROOT}")
message(FATAL_ERROR "Could not find ANDROID_SDK_ROOT or path is not a directory: ${ANDROID_SDK_ROOT}")
endif()
function(qt_internal_sort_android_platforms out_var)
if(CMAKE_VERSION GREATER_EQUAL 3.18)
set(platforms ${ARGN})
list(SORT platforms COMPARE NATURAL)
else()
# Simulate natural sorting:
# - prepend every platform with its version as three digits, zero-padded
# - regular sort
# - remove the padded version prefix
set(platforms)
foreach(platform IN LISTS ARGN)
set(version "000")
if(platform MATCHES ".*-([0-9]+)$")
set(version ${CMAKE_MATCH_1})
string(LENGTH "${version}" version_length)
math(EXPR padding_length "3 - ${version_length}")
string(REPEAT "0" ${padding_length} padding)
string(PREPEND version ${padding})
endif()
list(APPEND platforms "${version}~${platform}")
endforeach()
list(SORT platforms)
list(TRANSFORM platforms REPLACE "^.*~" "")
endif()
set("${out_var}" "${platforms}" PARENT_SCOPE)
endfunction()
# This variable specifies the API level used for building Java code, it can be the same as Qt for
# Android's maximum supported Android version or higher.
if(NOT QT_ANDROID_API_USED_FOR_JAVA)
set(QT_ANDROID_API_USED_FOR_JAVA "android-34")
endif()
set(jar_location "${ANDROID_SDK_ROOT}/platforms/${QT_ANDROID_API_USED_FOR_JAVA}/android.jar")
if(NOT EXISTS "${jar_location}")
_qt_internal_detect_latest_android_platform(android_platform_latest)
if(android_platform_latest)
message(NOTICE "The default platform SDK ${QT_ANDROID_API_USED_FOR_JAVA} not found, "
"using the latest installed ${android_platform_latest} instead.")
set(QT_ANDROID_API_USED_FOR_JAVA ${android_platform_latest})
endif()
endif()
set(QT_ANDROID_JAR "${ANDROID_SDK_ROOT}/platforms/${QT_ANDROID_API_USED_FOR_JAVA}/android.jar")
if(NOT EXISTS "${QT_ANDROID_JAR}")
message(FATAL_ERROR
"No suitable Android SDK platform found in '${ANDROID_SDK_ROOT}/platforms'."
" The minimum version required for building Java code is ${QT_ANDROID_API_USED_FOR_JAVA}"
)
endif()
message(STATUS "Using Android SDK API ${QT_ANDROID_API_USED_FOR_JAVA} from "
"${ANDROID_SDK_ROOT}/platforms")
_qt_internal_locate_android_jar()
# Locate Java
include(UseJava)
@ -163,10 +111,12 @@ define_property(TARGET
# Returns test execution arguments for Android targets
function(qt_internal_android_test_runner_arguments target out_test_runner out_test_arguments)
set(${out_test_runner} "${QT_HOST_PATH}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_BINDIR}/androidtestrunner" PARENT_SCOPE)
set(deployment_tool "${QT_HOST_PATH}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_BINDIR}/androiddeployqt")
qt_internal_get_host_info_var_prefix(host_info_var_prefix)
set(host_bin_dir "${QT_HOST_PATH}/${${host_info_var_prefix}_BINDIR}")
set(${out_test_runner} "${host_bin_dir}/androidtestrunner" PARENT_SCOPE)
set(deployment_tool "${host_bin_dir}/androiddeployqt")
qt_internal_android_get_target_android_build_dir(${target} android_build_dir)
_qt_internal_android_get_target_android_build_dir(android_build_dir ${target})
set(${out_test_arguments}
"--path" "${android_build_dir}"
"--adb" "${ANDROID_SDK_ROOT}/platform-tools/adb"

View File

@ -22,15 +22,16 @@ cmake_minimum_required(VERSION @min_new_policy_version@...@max_new_policy_versio
include(CMakeFindDependencyMacro)
get_filename_component(_import_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_import_prefix "${_import_prefix}" REALPATH)
if (NOT QT_NO_CREATE_TARGETS)
# Find required dependencies, if any.
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake")
else()
set(@target@_FOUND TRUE)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@AdditionalTargetInfo.cmake")
if(@target@_FOUND)
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@AdditionalTargetInfo.cmake")
endif()
endif()

View File

@ -1,11 +1,12 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
set(@target@_FOUND FALSE)
set(@target@_FOUND TRUE)
# note: _third_party_deps example: "ICU\\;FALSE\\;1.0\\;i18n uc data;ZLIB\\;FALSE\\;\\;"
set(__qt_@target@_third_party_deps "@third_party_deps@")
_qt_internal_find_third_party_dependencies("@target@" __qt_@target@_third_party_deps)
unset(__qt_@target@_third_party_deps)
set(__qt_use_no_default_path_for_qt_packages "NO_DEFAULT_PATH")
if(QT_DISABLE_NO_DEFAULT_PATH_IN_QT_PACKAGES)
@ -17,5 +18,9 @@ set(__qt_@target@_target_deps "@target_deps@")
set(__qt_@target@_find_dependency_paths "@find_dependency_paths@")
_qt_internal_find_qt_dependencies("@target@" __qt_@target@_target_deps
__qt_@target@_find_dependency_paths)
unset(__qt_@target@_target_deps)
unset(__qt_@target@_find_dependency_paths)
set(@target@_FOUND TRUE)
if(__qt_${target}_missing_deps)
set(@target@_FOUND FALSE)
endif()

View File

@ -115,6 +115,12 @@ function(qt_internal_add_plugin target)
qt_get_sanitized_plugin_type("${plugin_type}" plugin_type_escaped)
if(NOT TARGET qt_${plugin_type_escaped}_plugins_all)
add_custom_target(qt_${plugin_type_escaped}_plugins_all)
endif()
add_dependencies(qt_${plugin_type_escaped}_plugins_all ${target})
set(output_directory_default "${QT_BUILD_DIR}/${INSTALL_PLUGINSDIR}/${plugin_type}")
set(install_directory_default "${INSTALL_PLUGINSDIR}/${plugin_type}")
@ -208,10 +214,7 @@ function(qt_internal_add_plugin target)
set(plugin_install_package_suffix "${qt_module}")
get_target_property(aliased_target ${qt_module_target} ALIASED_TARGET)
if(aliased_target)
set(qt_module_target ${aliased_target})
endif()
_qt_internal_dealias_target(qt_module_target)
get_target_property(is_imported_qt_module ${qt_module_target} IMPORTED)
if(NOT is_imported_qt_module)
@ -229,8 +232,6 @@ function(qt_internal_add_plugin target)
__qt_internal_add_interface_plugin_target(${qt_module_target} ${target})
endif()
set(plugin_target_versioned "${QT_CMAKE_EXPORT_NAMESPACE}::${target}")
get_target_property(type "${plugin_target_versioned}" TYPE)
qt_internal_add_autogen_sync_header_dependencies(${target} ${qt_module_target})
endif()
@ -322,7 +323,7 @@ function(qt_internal_add_plugin target)
qt_internal_add_repo_local_defines("${target}")
if(NOT DEFINED arg_EXCEPTIONS)
if(NOT arg_EXCEPTIONS)
qt_internal_set_exceptions_flags("${target}" "DEFAULT")
else()
qt_internal_set_exceptions_flags("${target}" "${arg_EXCEPTIONS}")
@ -337,7 +338,16 @@ function(qt_internal_add_plugin target)
endif()
endforeach()
qt_register_target_dependencies("${target}" "${arg_PUBLIC_LIBRARIES}" "${qt_libs_private}")
set(qt_register_target_dependencies_args "")
if(arg_PUBLIC_LIBRARIES)
list(APPEND qt_register_target_dependencies_args PUBLIC ${arg_PUBLIC_LIBRARIES})
endif()
if(qt_libs_private)
qt_internal_wrap_private_modules(qt_libs_private ${qt_libs_private})
list(APPEND qt_register_target_dependencies_args PRIVATE ${qt_libs_private})
endif()
qt_internal_register_target_dependencies("${target}"
${qt_register_target_dependencies_args})
if(target_type STREQUAL STATIC_LIBRARY)
if(qt_module_target)
@ -373,8 +383,8 @@ function(qt_internal_add_plugin target)
# when building standalone tests.
if(QT_INTERNAL_CONFIGURING_TESTS OR arg_TEST_PLUGIN)
if(NOT arg_TEST_PLUGIN)
message(WARNING "The installable test plugin ${target} is built as part of test"
" suite, but is not marked as TEST_PLUGIN using the repsective argument."
message(WARNING "The installable test plugin ${target} is built as part of a test"
" suite, but is not marked as TEST_PLUGIN using the respective argument."
"\nThis warning will soon become an error."
)
endif()
@ -470,7 +480,7 @@ endif()"
${__qt_internal_sbom_multi_args}
)
_qt_internal_extend_sbom(${target} ${sbom_args})
qt_internal_extend_qt_entity_sbom(${target} ${sbom_args})
endif()
qt_add_list_file_finalizer(qt_finalize_plugin ${target} ${finalizer_extra_args})

View File

@ -29,7 +29,7 @@ macro(qt_collect_third_party_deps target)
endif()
unset(_target_is_static)
foreach(dep ${${depends_var}} ${optional_public_depends} ${extra_third_party_deps})
foreach(dep ${${depends_var}} ${extra_third_party_deps})
# Gather third party packages that should be found when using the Qt module.
# Also handle nolink target dependencies.
string(REGEX REPLACE "_nolink$" "" base_dep "${dep}")
@ -48,9 +48,6 @@ macro(qt_collect_third_party_deps target)
if(dep_seen EQUAL -1 AND package_name)
list(APPEND third_party_deps_seen ${dep})
get_target_property(package_is_optional ${dep} INTERFACE_QT_PACKAGE_IS_OPTIONAL)
if(NOT package_is_optional AND dep IN_LIST optional_public_depends)
set(package_is_optional TRUE)
endif()
get_target_property(package_version ${dep} INTERFACE_QT_PACKAGE_VERSION)
if(NOT package_version)
set(package_version "")
@ -143,6 +140,13 @@ function(qt_internal_remove_qt_dependency_duplicates out_deps deps)
endfunction()
function(qt_internal_create_module_depends_file target)
set(no_value_options "")
set(single_value_options "")
set(multi_value_options "")
cmake_parse_arguments(PARSE_ARGV 1 arg
"${no_value_options}" "${single_value_options}" "${multi_value_options}"
)
get_target_property(target_type "${target}" TYPE)
set(is_interface_lib FALSE)
if(target_type STREQUAL "INTERFACE_LIBRARY")
@ -156,11 +160,6 @@ function(qt_internal_create_module_depends_file target)
get_target_property(public_depends "${target}" INTERFACE_LINK_LIBRARIES)
unset(optional_public_depends)
if(TARGET "${target}Private")
get_target_property(optional_public_depends "${target}Private" INTERFACE_LINK_LIBRARIES)
endif()
# Used for collecting Qt module dependencies that should be find_package()'d in
# ModuleDependencies.cmake.
get_target_property(target_deps "${target}" _qt_target_deps)
@ -168,8 +167,11 @@ function(qt_internal_create_module_depends_file target)
set(qt_module_dependencies "")
if(NOT is_interface_lib)
# TODO: deprecated code path. QT_EXTRA_PACKAGE_DEPENDENCIES shouldn't be used for the Qt
# packages.
get_target_property(extra_depends "${target}" QT_EXTRA_PACKAGE_DEPENDENCIES)
endif()
if(NOT extra_depends MATCHES "-NOTFOUND$")
list(APPEND target_deps "${extra_depends}")
endif()
@ -337,7 +339,6 @@ function(qt_internal_create_plugin_depends_file target)
get_target_property(depends "${target}" LINK_LIBRARIES)
get_target_property(public_depends "${target}" INTERFACE_LINK_LIBRARIES)
get_target_property(target_deps "${target}" _qt_target_deps)
unset(optional_public_depends)
set(target_deps_seen "")
@ -398,7 +399,6 @@ function(qt_internal_create_qt6_dependencies_file)
set(actual_target Platform)
get_target_property(public_depends "${actual_target}" INTERFACE_LINK_LIBRARIES)
unset(depends)
unset(optional_public_depends)
set(third_party_deps "")
set(third_party_deps_seen "")
@ -432,7 +432,7 @@ endif()")
# to the target CMAKE_INSTALL_DIR, if at all possible to do so in a reliable way.
get_filename_component(qt_host_path_absolute "${QT_HOST_PATH}" ABSOLUTE)
get_filename_component(qt_host_path_cmake_dir_absolute
"${Qt${PROJECT_VERSION_MAJOR}HostInfo_DIR}/.." ABSOLUTE)
"${${INSTALL_CMAKE_NAMESPACE}HostInfo_DIR}/.." ABSOLUTE)
endif()
if(third_party_deps OR platform_requires_host_info_package)
@ -467,6 +467,9 @@ function(qt_internal_create_depends_files)
foreach (target ${repo_known_modules})
qt_internal_create_module_depends_file(${target})
if(TARGET "${target}Private")
qt_internal_create_module_depends_file(${target}Private)
endif()
endforeach()
foreach (target ${QT_KNOWN_PLUGINS})
@ -494,67 +497,8 @@ function(qt_internal_create_plugins_auto_inclusion_files)
if(QT_MODULE STREQUAL "Qml")
set(QT_MODULE_PLUGIN_INCLUDES "${QT_MODULE_PLUGIN_INCLUDES}
# Qml plugin targets might have dependencies on other qml plugin targets, but the Targets.cmake
# files are included in the order that file(GLOB) returns, which means certain targets that are
# referenced might not have been created yet, and \${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
# might be set to a message saying those targets don't exist.
#
# Postpone checking of which targets don't exist until all Qml PluginConfig.cmake files have been
# included, by including all the files one more time and checking for errors at each step.
#
# TODO: Find a better way to deal with this, perhaps by using find_package() instead of include
# for the Qml PluginConfig.cmake files.
# Distributions should probably change this default.
if(NOT DEFINED QT_SKIP_AUTO_QML_PLUGIN_INCLUSION)
set(QT_SKIP_AUTO_QML_PLUGIN_INCLUSION OFF)
endif()
set(__qt_qml_plugins_config_file_list \"\")
set(__qt_qml_plugins_glob_prefixes \"\${CMAKE_CURRENT_LIST_DIR}\")
# Allow passing additional prefixes where we will glob for PluginConfig.cmake files.
if(QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES)
foreach(__qt_qml_plugin_glob_prefix IN LISTS QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES)
if(__qt_qml_plugin_glob_prefix)
list(APPEND __qt_qml_plugins_glob_prefixes \"\${__qt_qml_plugin_glob_prefix}\")
endif()
endforeach()
endif()
list(REMOVE_DUPLICATES __qt_qml_plugins_glob_prefixes)
foreach(__qt_qml_plugin_glob_prefix IN LISTS __qt_qml_plugins_glob_prefixes)
file(GLOB __qt_qml_plugins_glob_config_file_list
\"\${__qt_qml_plugin_glob_prefix}/QmlPlugins/${INSTALL_CMAKE_NAMESPACE}*Config.cmake\")
if(__qt_qml_plugins_glob_config_file_list)
list(APPEND __qt_qml_plugins_config_file_list \${__qt_qml_plugins_glob_config_file_list})
endif()
endforeach()
if (__qt_qml_plugins_config_file_list AND NOT QT_SKIP_AUTO_QML_PLUGIN_INCLUSION)
# First round of inclusions ensure all qml plugin targets are brought into scope.
foreach(__qt_qml_plugin_config_file \${__qt_qml_plugins_config_file_list})
include(\${__qt_qml_plugin_config_file})
# Temporarily unset any failure markers and mark the Qml package as found.
unset(\${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE)
set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND TRUE)
endforeach()
# For the second round of inclusions, check and bail out early if there are errors.
foreach(__qt_qml_plugin_config_file \${__qt_qml_plugins_config_file_list})
include(\${__qt_qml_plugin_config_file})
if(\${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE)
string(APPEND \${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
\"\nThe message was set in \${__qt_qml_plugin_config_file} \")
set(\${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
return()
endif()
endforeach()
endif()")
__qt_internal_include_qml_plugin_packages()
")
endif()
get_target_property(module_plugin_types "${QT_MODULE}" MODULE_PLUGIN_TYPES)
@ -584,6 +528,11 @@ function(qt_generate_install_prefixes out_var)
INSTALL_PLUGINSDIR INSTALL_LIBEXECDIR INSTALL_QMLDIR INSTALL_DATADIR INSTALL_DOCDIR
INSTALL_TRANSLATIONSDIR INSTALL_SYSCONFDIR INSTALL_EXAMPLESDIR INSTALL_TESTSDIR
INSTALL_DESCRIPTIONSDIR INSTALL_SBOMDIR)
# INSTALL_PUBLICBINDIR is processed only if it is not empty
# See usage in qt_internal_generate_user_facing_tools_info
if(NOT "${INSTALL_PUBLICBINDIR}" STREQUAL "")
list(APPEND vars INSTALL_PUBLICBINDIR)
endif()
foreach(var ${vars})
get_property(docstring CACHE "${var}" PROPERTY HELPSTRING)
@ -617,7 +566,15 @@ function(qt_create_hostinfo_package)
INSTALL_DESTINATION "${install_destination}"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
qt_install(FILES "${config_file_path}" DESTINATION "${install_destination}")
set(version_file "${QT_CONFIG_BUILD_DIR}/${package}/${package}ConfigVersion.cmake")
write_basic_package_version_file(
"${version_file}"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
ARCH_INDEPENDENT
)
qt_install(FILES "${config_file_path}" "${version_file}" DESTINATION "${install_destination}")
endfunction()
function(qt_generate_build_internals_extra_cmake_code)
@ -921,6 +878,7 @@ function(qt_internal_generate_user_facing_tools_info)
if("${INSTALL_PUBLICBINDIR}" STREQUAL "")
return()
endif()
qt_path_join(tool_link_base_dir "${CMAKE_INSTALL_PREFIX}" "${INSTALL_PUBLICBINDIR}")
get_property(user_facing_tool_targets GLOBAL PROPERTY QT_USER_FACING_TOOL_TARGETS)
set(lines "")
foreach(target ${user_facing_tool_targets})
@ -937,6 +895,7 @@ function(qt_internal_generate_user_facing_tools_info)
endif()
qt_path_join(tool_target_path "${CMAKE_INSTALL_PREFIX}" "${INSTALL_BINDIR}" "${filename}")
qt_path_join(tool_link_path "${INSTALL_PUBLICBINDIR}" "${linkname}${PROJECT_VERSION_MAJOR}")
_qt_internal_relative_path(tool_target_path BASE_DIRECTORY ${tool_link_base_dir})
list(APPEND lines "${tool_target_path} ${tool_link_path}")
endforeach()
string(REPLACE ";" "\n" content "${lines}")

View File

@ -3,18 +3,55 @@
function(qt_update_precompiled_header target precompiled_header)
if (precompiled_header AND BUILD_WITH_PCH)
set_property(TARGET "${target}" APPEND PROPERTY "PRECOMPILE_HEADERS" "$<$<OR:$<COMPILE_LANGUAGE:CXX>,$<COMPILE_LANGUAGE:OBJCXX>>:${precompiled_header}>")
set_property(TARGET "${target}" APPEND PROPERTY "PRECOMPILE_HEADERS" "$<$<COMPILE_LANGUAGE:CXX,OBJCXX>:${precompiled_header}>")
endif()
endfunction()
function(qt_update_precompiled_header_with_library target library)
if (TARGET "${library}")
get_target_property(TARGET_TYPE "${library}" TYPE)
if (NOT TARGET_TYPE STREQUAL "INTERFACE_LIBRARY")
get_target_property(HEADER "${library}" MODULE_HEADER)
qt_update_precompiled_header("${target}" "${HEADER}")
if(NOT TARGET "${library}")
return()
endif()
get_target_property(target_type "${library}" TYPE)
if(target_type STREQUAL "INTERFACE_LIBRARY")
return()
endif()
get_target_property(header_file_path "${library}" MODULE_HEADER)
if(NOT header_file_path)
# The Qt module is imported from the Qt installation prefix.
# Calculate the module header location.
get_target_property(include_name "${library}" _qt_module_include_name)
if(NOT include_name)
message(DEBUG "Property _qt_module_include_name is not set on ${library}.")
return()
endif()
get_target_property(relative_include_dir "${library}" _qt_module_relative_include_dir)
if(NOT relative_include_dir)
message(DEBUG "Property _qt_module_relative_include_dir is not set on ${library}.")
return()
endif()
get_target_property(package_name ${library} _qt_package_name)
if(NOT package_name)
message(DEBUG "No package name found for ${library}.")
return()
endif()
set(package_location "${${package_name}_DIR}")
get_filename_component(absolute_include_dir
"${package_location}/${relative_include_dir}"
ABSOLUTE
)
set(header_file_path "${absolute_include_dir}/${include_name}")
if(NOT EXISTS "${header_file_path}")
message(DEBUG "Module header '${header_file_path}' does not exist.")
return()
endif()
endif()
qt_update_precompiled_header("${target}" "${header_file_path}")
endfunction()
function(qt_update_ignore_pch_source target sources)

View File

@ -738,9 +738,10 @@ function(qt_generate_global_config_pri_file)
endif()
if(CMAKE_CROSSCOMPILING)
qt_internal_get_host_info_var_prefix(host_info_var_prefix)
string(APPEND content "host_build {
QT_ARCH = ${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_ARCH}
QT_BUILDABI = ${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_BUILDABI}
QT_ARCH = ${${host_info_var_prefix}_ARCH}
QT_BUILDABI = ${${host_info_var_prefix}_BUILDABI}
QT_TARGET_ARCH = ${TEST_architecture_arch}
QT_TARGET_BUILDABI = ${TEST_buildAbi}
} else {
@ -965,8 +966,9 @@ function(qt_generate_global_module_pri_file)
set(arch "${TEST_architecture_arch}")
list(JOIN TEST_subarch_result " " subarchs)
if(CMAKE_CROSSCOMPILING)
set(host_arch "${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_ARCH}")
list(JOIN QT${PROJECT_VERSION_MAJOR}_HOST_INFO_SUBARCHS " " host_subarchs)
qt_internal_get_host_info_var_prefix(host_info_var_prefix)
set(host_arch "${${host_info_var_prefix}_ARCH}")
list(JOIN ${host_info_var_prefix}_SUBARCHS " " host_subarchs)
string(APPEND content "host_build {
QT_CPU_FEATURES.${host_arch} = ${host_subarchs}
} else {

View File

@ -65,9 +65,17 @@ function(qt_generate_prl_file target install_dir)
set(prefix_for_final_prl_name "$<TARGET_FILE_PREFIX:${target}>")
endif()
# For frameworks, the prl file should be placed under the Resources subdir.
# For macOS frameworks, the prl file should be placed under the Resources subdir.
# For iOS, visionOS, watchOS, tvOS, there is no Resources subdir, and the contents needs to
# be placed directly in the framework root, as described at
# https://developer.apple.com/documentation/bundleresources/placing-content-in-a-bundle?language=objc
get_target_property(is_framework ${target} FRAMEWORK)
if(is_framework)
if(APPLE AND (NOT CMAKE_SYSTEM_NAME OR CMAKE_SYSTEM_NAME STREQUAL "Darwin"))
set(is_macos TRUE)
else()
set(is_macos FALSE)
endif()
if(is_framework AND is_macos)
get_target_property(fw_version ${target} FRAMEWORK_VERSION)
string(APPEND prefix_for_final_prl_name "Versions/${fw_version}/Resources/")
endif()

View File

@ -230,6 +230,34 @@ function(qt_feature feature)
set_property(GLOBAL PROPERTY COMMANDLINE_FEATURE_SECTION_${feature} "${arg_SECTION}")
endfunction()
function(qt_feature_alias feature)
cmake_parse_arguments(arg "NEGATE" "PURPOSE;SECTION;MESSAGE;ALIAS_OF_FEATURE;ALIAS_OF_CACHE" ""
${ARGN})
set_property(GLOBAL APPEND PROPERTY COMMANDLINE_KNOWN_FEATURES "${feature}")
# Mark the feature as aliased
set(alias_note "alias of ")
if(arg_NEGATE)
string(APPEND alias_note "NOT ")
endif()
if(arg_ALIAS_OF_FEATURE)
string(APPEND alias_note "${arg_ALIAS_OF_FEATURE} Feature")
else()
string(APPEND alias_note "${arg_ALIAS_OF_CACHE} Cache")
endif()
set(arg_PURPOSE "(${alias_note}) ${arg_PURPOSE}")
set_property(GLOBAL PROPERTY COMMANDLINE_FEATURE_PURPOSE_${feature} "${arg_PURPOSE}")
set_property(GLOBAL PROPERTY COMMANDLINE_FEATURE_SECTION_${feature} "${arg_SECTION}")
endfunction()
function(qt_feature_deprecated feature)
cmake_parse_arguments(arg "" "PURPOSE;SECTION;MESSAGE" "" ${ARGN})
set_property(GLOBAL APPEND PROPERTY COMMANDLINE_KNOWN_FEATURES "${feature}")
# Mark the feature as deprecated
set(arg_PURPOSE "(DEPRECATED) ${arg_PURPOSE} ${arg_MESSAGE}")
set_property(GLOBAL PROPERTY COMMANDLINE_FEATURE_PURPOSE_${feature} "${arg_PURPOSE}")
set_property(GLOBAL PROPERTY COMMANDLINE_FEATURE_SECTION_${feature} "${arg_SECTION}")
endfunction()
function(find_package)
message(FATAL_ERROR "find_package must not be used directly in configure.cmake. "
"Use qt_find_package or guard the call with an if(NOT QT_CONFIGURE_RUNNING) block.")
@ -288,7 +316,7 @@ endmacro()
function(qt_commandline_option name)
set(options CONTROLS_FEATURE)
set(oneValueArgs TYPE NAME VALUE)
set(oneValueArgs TYPE NAME VALUE CMAKE_VARIABLE)
set(multiValueArgs VALUES MAPPING)
cmake_parse_arguments(arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
@ -299,6 +327,9 @@ function(qt_commandline_option name)
set(input_name ${arg_NAME})
set(commandline_option_${name}_variable "${arg_NAME}" PARENT_SCOPE)
endif()
if(DEFINED arg_CMAKE_VARIABLE)
set_property(GLOBAL PROPERTY INPUTCMAKEVAR_${input_name} "${arg_CMAKE_VARIABLE}")
endif()
set(mapping_type "${arg_TYPE}")
if(arg_CONTROLS_FEATURE)
set(mapping_type "boolean")
@ -317,11 +348,13 @@ endfunction()
# Add the common command line options for every qt repo.
macro(qt_add_common_commandline_options)
qt_commandline_option(headersclean TYPE boolean)
qt_commandline_option(sbom TYPE boolean)
qt_commandline_option(sbom-json TYPE boolean)
qt_commandline_option(sbom-json-required TYPE boolean)
qt_commandline_option(sbom-verify TYPE boolean)
qt_commandline_option(sbom-verify-required TYPE boolean)
qt_commandline_option(sbom TYPE boolean CMAKE_VARIABLE QT_GENERATE_SBOM)
qt_commandline_option(sbom-json TYPE boolean CMAKE_VARIABLE QT_SBOM_GENERATE_JSON)
qt_commandline_option(sbom-json-required TYPE boolean
CMAKE_VARIABLE QT_SBOM_REQUIRE_GENERATE_JSON
)
qt_commandline_option(sbom-verify TYPE boolean CMAKE_VARIABLE QT_SBOM_VERIFY)
qt_commandline_option(sbom-verify-required TYPE boolean CMAKE_VARIABLE QT_SBOM_REQUIRE_VERIFY)
endmacro()
function(qt_commandline_prefix arg var)
@ -505,6 +538,18 @@ function(qt_commandline_string arg val nextok)
endif()
endfunction()
# Handle command line arguments of type "path" exactly like strings.
# They are treated differently by translate_input, however.
function(qt_commandline_path arg val nextok)
qt_commandline_string("${arg}" "${val}" "${nextok}")
endfunction()
# Handle command line arguments of type "stringList" exactly like strings.
# They are treated differently by translate_input, however.
function(qt_commandline_stringList arg val nextok)
qt_commandline_string("${arg}" "${val}" "${nextok}")
endfunction()
function(qt_commandline_optionalString arg val nextok)
if("${val}" STREQUAL "")
if(nextok)
@ -798,9 +843,10 @@ get_property(config_inputs GLOBAL PROPERTY CONFIG_INPUTS)
list(REMOVE_DUPLICATES config_inputs)
foreach(var ${config_inputs})
get_property(INPUT_${var} GLOBAL PROPERTY INPUT_${var})
if("${commandline_input_type}" STREQUAL "")
if("${commandline_input_${var}_type}" STREQUAL "")
get_property(commandline_input_${var}_type GLOBAL PROPERTY INPUTTYPE_${var})
endif()
get_property(commandline_input_${var}_cmake_variable GLOBAL PROPERTY INPUTCMAKEVAR_${var})
endforeach()
macro(drop_input name)
@ -842,6 +888,24 @@ macro(translate_list_input name cmake_var)
endif()
endmacro()
macro(translate_input name cmake_var)
if("${commandline_input_${name}_type}" STREQUAL "boolean")
translate_boolean_input(${name} ${cmake_var})
elseif("${commandline_input_${name}_type}" STREQUAL "path")
translate_path_input(${name} ${cmake_var})
elseif("${commandline_input_${name}_type}" STREQUAL "string")
translate_string_input(${name} ${cmake_var})
elseif("${commandline_input_${name}_type}" STREQUAL "addString"
OR "${commandline_input_${name}_type}" STREQUAL "stringList")
translate_list_input(${name} ${cmake_var})
else()
message(FATAL_ERROR
"translate_input cannot handle input '${name}' "
"of type '${commandline_input_${name}_type}'."
)
endif()
endmacro()
# Check whether to guess the compiler for the given language.
#
# Sets ${out_var} to FALSE if one of the following holds:
@ -871,29 +935,27 @@ function(guess_compiler_from_mkspec)
check_whether_to_guess_compiler(guess_c_compiler CC CMAKE_C_COMPILER)
check_whether_to_guess_compiler(guess_cxx_compiler CXX CMAKE_CXX_COMPILER)
if(NOT guess_c_compiler AND NOT guess_cxx_compiler)
return()
endif()
string(REGEX MATCH "(^|;)-DQT_QMAKE_TARGET_MKSPEC=\([^;]+\)" m "${cmake_args}")
set(mkspec ${CMAKE_MATCH_2})
set(c_compiler "")
set(cxx_compiler "")
if(mkspec MATCHES "-clang-msvc$")
set(c_compiler "clang-cl")
set(cxx_compiler "clang-cl")
elseif(mkspec MATCHES "-clang(-|$)" AND NOT mkspec MATCHES "android")
set(c_compiler "clang")
set(cxx_compiler "clang++")
elseif(mkspec MATCHES "-msvc(-|$)")
set(c_compiler "cl")
set(cxx_compiler "cl")
endif()
if(guess_c_compiler AND NOT c_compiler STREQUAL "")
push("-DCMAKE_C_COMPILER=${c_compiler}")
endif()
if(guess_cxx_compiler AND NOT cxx_compiler STREQUAL "")
push("-DCMAKE_CXX_COMPILER=${cxx_compiler}")
if(guess_c_compiler OR guess_cxx_compiler)
set(c_compiler "")
set(cxx_compiler "")
if(mkspec MATCHES "-clang-msvc$")
set(c_compiler "clang-cl")
set(cxx_compiler "clang-cl")
elseif(mkspec MATCHES "-clang(-|$)" AND NOT mkspec MATCHES "android")
set(c_compiler "clang")
set(cxx_compiler "clang++")
elseif(mkspec MATCHES "-msvc(-|$)")
set(c_compiler "cl")
set(cxx_compiler "cl")
endif()
if(guess_c_compiler AND NOT c_compiler STREQUAL "")
push("-DCMAKE_C_COMPILER=${c_compiler}")
endif()
if(guess_cxx_compiler AND NOT cxx_compiler STREQUAL "")
push("-DCMAKE_CXX_COMPILER=${cxx_compiler}")
endif()
endif()
if(mkspec MATCHES "-libc\\+\\+$")
push("-DFEATURE_stdlib_libcpp=ON")
@ -925,47 +987,23 @@ function(check_qt_build_parts type)
set(cmake_args "${cmake_args}" PARENT_SCOPE)
endfunction()
# Translate command line arguments that have CMAKE_VARIABLE set.
foreach(input IN LISTS config_inputs)
if(NOT "${commandline_input_${input}_cmake_variable}" STREQUAL "")
translate_input("${input}" "${commandline_input_${input}_cmake_variable}")
endif()
endforeach()
drop_input(commercial)
drop_input(confirm-license)
translate_boolean_input(precompile_header BUILD_WITH_PCH)
translate_boolean_input(unity_build QT_UNITY_BUILD)
translate_string_input(unity_build_batch_size QT_UNITY_BUILD_BATCH_SIZE)
translate_boolean_input(ccache QT_USE_CCACHE)
translate_boolean_input(vcpkg QT_USE_VCPKG)
translate_boolean_input(sbom QT_GENERATE_SBOM)
translate_boolean_input(sbom-json QT_SBOM_GENERATE_JSON)
translate_boolean_input(sbom-json-required QT_SBOM_REQUIRE_GENERATE_JSON)
translate_boolean_input(sbom-verify QT_SBOM_VERIFY)
translate_boolean_input(sbom-verify-required QT_SBOM_REQUIRE_VERIFY)
translate_boolean_input(shared BUILD_SHARED_LIBS)
translate_boolean_input(warnings_are_errors WARNINGS_ARE_ERRORS)
translate_boolean_input(qtinlinenamespace QT_INLINE_NAMESPACE)
translate_string_input(qt_namespace QT_NAMESPACE)
translate_string_input(qt_libinfix QT_LIBINFIX)
translate_string_input(qreal QT_COORD_TYPE)
translate_path_input(prefix CMAKE_INSTALL_PREFIX)
translate_path_input(extprefix CMAKE_STAGING_PREFIX)
foreach(kind bin lib archdata libexec qml data doc sysconf examples tests)
string(TOUPPER ${kind} uc_kind)
translate_path_input(${kind}dir INSTALL_${uc_kind}DIR)
endforeach()
translate_path_input(headerdir INSTALL_INCLUDEDIR)
translate_path_input(plugindir INSTALL_PLUGINSDIR)
translate_path_input(translationdir INSTALL_TRANSLATIONSDIR)
translate_path_input(sbomdir INSTALL_SBOMDIR)
if(NOT "${INPUT_device}" STREQUAL "")
push("-DQT_QMAKE_TARGET_MKSPEC=devices/${INPUT_device}")
drop_input(device)
endif()
translate_string_input(platform QT_QMAKE_TARGET_MKSPEC)
translate_string_input(xplatform QT_QMAKE_TARGET_MKSPEC)
guess_compiler_from_mkspec()
translate_string_input(qpa_default_platform QT_QPA_DEFAULT_PLATFORM)
translate_list_input(qpa_platforms QT_QPA_PLATFORMS)
translate_path_input(android-sdk ANDROID_SDK_ROOT)
translate_path_input(android-ndk ANDROID_NDK_ROOT)
if(DEFINED INPUT_android-ndk-platform)
drop_input(android-ndk-platform)
push("-DANDROID_PLATFORM=${INPUT_android-ndk-platform}")
@ -977,14 +1015,9 @@ if(DEFINED INPUT_android-abis)
endif()
translate_string_input(android-abis ANDROID_ABI)
endif()
translate_string_input(android-javac-source QT_ANDROID_JAVAC_SOURCE)
translate_string_input(android-javac-target QT_ANDROID_JAVAC_TARGET)
translate_string_input(sdk QT_APPLE_SDK)
drop_input(make)
drop_input(nomake)
translate_boolean_input(install-examples-sources QT_INSTALL_EXAMPLES_SOURCES)
check_qt_build_parts(nomake)
check_qt_build_parts(make)
@ -1049,10 +1082,7 @@ if("${INPUT_ltcg}" STREQUAL "yes")
endforeach()
endif()
translate_path_input(ffmpeg-dir FFMPEG_DIR)
translate_boolean_input(ffmpeg-deploy QT_DEPLOY_FFMPEG)
translate_list_input(device-option QT_QMAKE_DEVICE_OPTIONS)
# Handle -D, -I and friends.
translate_list_input(defines QT_EXTRA_DEFINES)
translate_list_input(fpaths QT_EXTRA_FRAMEWORKPATHS)
translate_list_input(includes QT_EXTRA_INCLUDEPATHS)

View File

@ -10,7 +10,7 @@ function(_qt_internal_detect_latest_android_platform out_var)
# If list is not empty
if(android_platforms)
qt_internal_sort_android_platforms(android_platforms ${android_platforms})
_qt_internal_sort_android_platforms(android_platforms ${android_platforms})
list(REVERSE android_platforms)
list(GET android_platforms 0 android_platform_latest)
set(${out_var} "${android_platform_latest}" PARENT_SCOPE)
@ -18,3 +18,63 @@ function(_qt_internal_detect_latest_android_platform out_var)
set(${out_var} "${out_var}-NOTFOUND" PARENT_SCOPE)
endif()
endfunction()
function(_qt_internal_sort_android_platforms out_var)
if(CMAKE_VERSION GREATER_EQUAL 3.18)
set(platforms ${ARGN})
list(SORT platforms COMPARE NATURAL)
else()
# Simulate natural sorting:
# - prepend every platform with its version as three digits, zero-padded
# - regular sort
# - remove the padded version prefix
set(platforms)
foreach(platform IN LISTS ARGN)
set(version "000")
if(platform MATCHES ".*-([0-9]+)$")
set(version ${CMAKE_MATCH_1})
string(LENGTH "${version}" version_length)
math(EXPR padding_length "3 - ${version_length}")
string(REPEAT "0" ${padding_length} padding)
string(PREPEND version ${padding})
endif()
list(APPEND platforms "${version}~${platform}")
endforeach()
list(SORT platforms)
list(TRANSFORM platforms REPLACE "^.*~" "")
endif()
set("${out_var}" "${platforms}" PARENT_SCOPE)
endfunction()
function(_qt_internal_locate_android_jar)
# This variable specifies the API level used for building Java code, it can be the same as Qt
# for Android's maximum supported Android version or higher.
if(NOT QT_ANDROID_API_USED_FOR_JAVA)
set(QT_ANDROID_API_USED_FOR_JAVA "android-35")
endif()
set(jar_location "${ANDROID_SDK_ROOT}/platforms/${QT_ANDROID_API_USED_FOR_JAVA}/android.jar")
if(NOT EXISTS "${jar_location}")
_qt_internal_detect_latest_android_platform(android_platform_latest)
if(android_platform_latest)
message(NOTICE "The default platform SDK ${QT_ANDROID_API_USED_FOR_JAVA} not found, "
"using the latest installed ${android_platform_latest} instead.")
set(QT_ANDROID_API_USED_FOR_JAVA ${android_platform_latest})
endif()
endif()
set(QT_ANDROID_JAR "${ANDROID_SDK_ROOT}/platforms/${QT_ANDROID_API_USED_FOR_JAVA}/android.jar")
if(NOT EXISTS "${QT_ANDROID_JAR}")
message(FATAL_ERROR
"No suitable Android SDK platform found in '${ANDROID_SDK_ROOT}/platforms'."
" The minimum version required for building Java code is ${QT_ANDROID_API_USED_FOR_JAVA}"
)
endif()
message(STATUS "Using Android SDK API ${QT_ANDROID_API_USED_FOR_JAVA} from "
"${ANDROID_SDK_ROOT}/platforms")
set(QT_ANDROID_JAR "${QT_ANDROID_JAR}" PARENT_SCOPE)
set(QT_ANDROID_API_USED_FOR_JAVA "${QT_ANDROID_API_USED_FOR_JAVA}" PARENT_SCOPE)
endfunction()

View File

@ -97,9 +97,9 @@ function(_qt_internal_handle_ios_launch_screen target)
endif()
endfunction()
function(_qt_internal_find_ios_development_team_id out_var)
function(_qt_internal_find_apple_development_team_id out_var)
get_property(team_id GLOBAL PROPERTY _qt_internal_ios_development_team_id)
get_property(team_id_computed GLOBAL PROPERTY _qt_internal_ios_development_team_id_computed)
get_property(team_id_computed GLOBAL PROPERTY _qt_internal_apple_development_team_id_computed)
if(team_id_computed)
# Just in case if the value is non-empty but still booly FALSE.
if(NOT team_id)
@ -109,17 +109,31 @@ function(_qt_internal_find_ios_development_team_id out_var)
return()
endif()
set_property(GLOBAL PROPERTY _qt_internal_ios_development_team_id_computed "TRUE")
set_property(GLOBAL PROPERTY _qt_internal_apple_development_team_id_computed "TRUE")
set(home_dir "$ENV{HOME}")
set(xcode_preferences_path "${home_dir}/Library/Preferences/com.apple.dt.Xcode.plist")
# Extract the first account name (email) from the user's Xcode preferences
message(DEBUG "Trying to extract an Xcode development team id from '${xcode_preferences_path}'")
execute_process(COMMAND "/usr/libexec/PlistBuddy"
-x -c "print IDEProvisioningTeams" "${xcode_preferences_path}"
OUTPUT_VARIABLE teams_xml
ERROR_VARIABLE plist_error)
# Try Xcode 16.2 format first
_qt_internal_plist_buddy("${xcode_preferences_path}"
COMMANDS "print IDEProvisioningTeamByIdentifier"
EXTRA_ARGS -x
OUTPUT_VARIABLE teams_xml
ERROR_VARIABLE plist_error
)
# Then fall back to older format
if(plist_error OR NOT teams_xml)
_qt_internal_plist_buddy("${xcode_preferences_path}"
COMMANDS "print IDEProvisioningTeams"
EXTRA_ARGS -x
OUTPUT_VARIABLE teams_xml
ERROR_VARIABLE plist_error
)
endif()
# Parsing state.
set(is_free "")
@ -152,6 +166,16 @@ function(_qt_internal_find_ios_development_team_id out_var)
# ...
# </dict>
# </array>
# <key>AAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE</key>
# <array>
# <dict>
# <key>isFreeProvisioningTeam</key>
# <false/>
# <key>teamID</key>
# <string>CCC</string>
# ...
# </dict>
# </array>
#</dict>
#</plist>
if(teams_xml AND NOT plist_error)
@ -270,7 +294,7 @@ function(_qt_internal_get_default_apple_bundle_identifier target out_var)
# For a better out-of-the-box experience, try to create a unique prefix by appending
# the sha1 of the team id, if one is found.
_qt_internal_find_ios_development_team_id(team_id)
_qt_internal_find_apple_development_team_id(team_id)
if(team_id)
string(SHA1 hash "${team_id}")
string(SUBSTRING "${hash}" 0 8 infix)
@ -378,7 +402,7 @@ function(_qt_internal_set_xcode_development_team_id target)
if(NOT CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM AND NOT QT_NO_SET_XCODE_DEVELOPMENT_TEAM_ID)
get_target_property(existing_team_id "${target}" XCODE_ATTRIBUTE_DEVELOPMENT_TEAM)
if(NOT existing_team_id)
_qt_internal_find_ios_development_team_id(team_id)
_qt_internal_find_apple_development_team_id(team_id)
set_target_properties("${target}"
PROPERTIES XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "${team_id}")
endif()
@ -635,10 +659,10 @@ endfunction()
function(_qt_internal_plist_buddy plist_file)
cmake_parse_arguments(PARSE_ARGV 1 arg
"" "OUTPUT_VARIABLE;ERROR_VARIABLE" "COMMANDS")
"" "OUTPUT_VARIABLE;ERROR_VARIABLE;EXTRA_ARGS" "COMMANDS")
foreach(command ${arg_COMMANDS})
execute_process(COMMAND "/usr/libexec/PlistBuddy"
-c "${command}" "${plist_file}"
${arg_EXTRA_ARGS} -c "${command}" "${plist_file}"
OUTPUT_VARIABLE plist_buddy_output
ERROR_VARIABLE plist_buddy_error)
string(STRIP "${plist_buddy_output}" plist_buddy_output)
@ -730,6 +754,25 @@ function(_qt_internal_set_ios_simulator_arch target)
"x86_64")
endfunction()
function(_qt_internal_set_xcode_entrypoint_attribute target entrypoint)
if(CMAKE_XCODE_ATTRIBUTE_LD_ENTRY_POINT
OR QT_NO_SET_XCODE_LD_ENTRY_POINT)
return()
endif()
get_target_property(existing_entrypoint
"${target}" XCODE_ATTRIBUTE_LD_ENTRY_POINT)
if(NOT existing_entrypoint MATCHES "-NOTFOUND")
return()
endif()
set_target_properties("${target}"
PROPERTIES
"XCODE_ATTRIBUTE_LD_ENTRY_POINT"
"${entrypoint}")
endfunction()
# Export Apple platform sdk and xcode version requirements to Qt6ConfigExtras.cmake.
# Always exported, even on non-Apple platforms, so that we can use them when building
# documentation.
@ -768,38 +811,141 @@ endif()")
set(${out_var} "${assignments}" PARENT_SCOPE)
endfunction()
function(_qt_internal_get_apple_sdk_version out_var)
if(APPLE)
if(CMAKE_SYSTEM_NAME STREQUAL iOS)
set(sdk_name "iphoneos")
elseif(CMAKE_SYSTEM_NAME STREQUAL visionOS)
set(sdk_name "xros")
# Returns the active apple sdk name that was either explicitly set by the user via QT_APPLE_SDK or
# or CMAKE_OSX_SYSROOT, or return the default approximated value, based on what CMake does
# internally.
#
# TODO: Handle case when CMAKE_OSX_SYSROOT is set to an sdk path, from which we need to retrieve the
# sdk name.
function(_qt_internal_get_apple_sdk_name out_var)
if(NOT APPLE)
set(${out_var} "" PARENT_SCOPE)
return()
endif()
# If CMake or the user has set an explicit sdk name, consider it.
if(QT_APPLE_SDK)
set(explicit_sdk_name "${QT_APPLE_SDK}")
elseif(CMAKE_OSX_SYSROOT)
set(explicit_sdk_name "${CMAKE_OSX_SYSROOT}")
else()
set(explicit_sdk_name "")
endif()
set(output_sdk_name "")
# Detect (or check if already set) that the sdk name is one that Qt knows about.
if(CMAKE_SYSTEM_NAME STREQUAL iOS)
if(explicit_sdk_name STREQUAL "iphoneos" OR explicit_sdk_name STREQUAL "iphonesimulator")
set(output_sdk_name "${explicit_sdk_name}")
else()
# Default to macOS
set(sdk_name "macosx")
# Default case.
set(output_sdk_name "iphoneos")
endif()
set(xcrun_version_arg "--show-sdk-version")
execute_process(COMMAND /usr/bin/xcrun --sdk ${sdk_name} ${xcrun_version_arg}
OUTPUT_VARIABLE sdk_version
ERROR_VARIABLE xcrun_error)
elseif(CMAKE_SYSTEM_NAME STREQUAL visionOS)
if(explicit_sdk_name STREQUAL "xros" OR explicit_sdk_name STREQUAL "xrsimulator")
set(output_sdk_name "${explicit_sdk_name}")
else()
# Default case.
set(output_sdk_name "xros")
endif()
else()
# Default case.
set(output_sdk_name "macosx")
endif()
set(${out_var} "${output_sdk_name}" PARENT_SCOPE)
endfunction()
function(_qt_internal_execute_xcrun out_var)
set(opt_args "")
set(single_args "")
set(multi_args
XCRUN_ARGS
OUT_ERROR_VAR
)
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
set(output "")
set(xcrun_error "")
if(NOT APPLE)
message(FATAL_ERROR
"Executing xcrun should only happen happen when targeting Apple plaforms")
endif()
find_program(QT_XCRUN xcrun)
if(NOT QT_XCRUN)
message(FATAL_ERROR "Can't find xcrun in PATH")
endif()
execute_process(COMMAND "${QT_XCRUN}" ${arg_XCRUN_ARGS}
OUTPUT_VARIABLE output
ERROR_VARIABLE xcrun_error)
if(arg_OUT_ERROR_VAR)
set(${arg_OUT_ERROR_VAR} "${xcrun_error}" PARENT_SCOPE)
endif()
set(${out_var} "${output}" PARENT_SCOPE)
endfunction()
function(_qt_internal_get_apple_sdk_path out_var)
set(sdk_path "")
if(APPLE)
_qt_internal_get_apple_sdk_name(sdk_name)
_qt_internal_execute_xcrun(sdk_path
XCRUN_ARGS --sdk ${sdk_name} --show-sdk-path
OUT_ERROR_VAR xcrun_error
)
if(NOT sdk_path)
message(FATAL_ERROR
"Can't determine darwin ${sdk_name} SDK path. Error: ${xcrun_error}")
endif()
string(STRIP "${sdk_path}" sdk_path)
endif()
set(${out_var} "${sdk_path}" PARENT_SCOPE)
endfunction()
function(_qt_internal_get_apple_sdk_version out_var)
set(sdk_version "")
if(APPLE)
_qt_internal_get_apple_sdk_name(sdk_name)
_qt_internal_execute_xcrun(sdk_version
XCRUN_ARGS --sdk ${sdk_name} --show-sdk-version
OUT_ERROR_VAR xcrun_error
)
if(NOT sdk_version)
message(FATAL_ERROR
"Can't determine darwin ${sdk_name} SDK version. Error: ${xcrun_error}")
endif()
string(STRIP "${sdk_version}" sdk_version)
set(${out_var} "${sdk_version}" PARENT_SCOPE)
endif()
set(${out_var} "${sdk_version}" PARENT_SCOPE)
endfunction()
function(_qt_internal_get_xcode_version_raw out_var)
set(xcode_version "")
if(APPLE)
execute_process(COMMAND /usr/bin/xcrun xcodebuild -version
OUTPUT_VARIABLE xcode_version
ERROR_VARIABLE xcrun_error)
_qt_internal_execute_xcrun(xcode_version
XCRUN_ARGS xcodebuild -version
OUT_ERROR_VAR xcrun_error
)
string(REPLACE "\n" " " xcode_version "${xcode_version}")
string(STRIP "${xcode_version}" xcode_version)
set(${out_var} "${xcode_version}" PARENT_SCOPE)
if(NOT xcode_version)
message(FATAL_ERROR
"Can't determine Xcode version. Is Xcode installed?"
" Error details:\n${xcrun_error}")
endif()
endif()
set(${out_var} "${xcode_version}" PARENT_SCOPE)
endfunction()
function(_qt_internal_get_xcode_version out_var)
@ -844,9 +990,9 @@ function(_qt_internal_get_cached_xcode_version out_var)
set(${out_var} "${xcode_version}" PARENT_SCOPE)
endfunction()
# Warn when the platform SDK or Xcode version are not supported.
# Warn or error out when the platform SDK or Xcode version are not supported.
#
# The warnings are currently only shown when building Qt, not when building user projects
# The messages are currently only shown when building Qt, not when building user projects
# with CMake.
# The warnings ARE shown for qmake user projects.
#
@ -891,11 +1037,14 @@ function(_qt_internal_check_apple_sdk_and_xcode_versions)
endif()
# The default differs in different branches.
set(failed_check_should_error FALSE)
set(failed_check_should_error TRUE)
if(failed_check_should_error)
# Allow downgrading the error into a warning.
if(QT_FORCE_WARN_APPLE_SDK_AND_XCODE_CHECK)
#
# Our cmake build tests might be executed on older not officially supported Xcode or SDK
# versions in the CI. Downgrade the error in this case as well.
if(QT_FORCE_WARN_APPLE_SDK_AND_XCODE_CHECK OR QT_INTERNAL_IS_CMAKE_BUILD_TEST)
set(message_type WARNING)
set(extra_message " Due to QT_FORCE_WARN_APPLE_SDK_AND_XCODE_CHECK being ON "
"the build will continue, but it will likely fail. Use at your own risk.")
@ -995,6 +1144,8 @@ function(_qt_internal_finalize_ios_app target)
_qt_internal_set_xcode_targeted_device_family("${target}")
_qt_internal_set_xcode_bitcode_enablement("${target}")
_qt_internal_set_ios_simulator_arch("${target}")
_qt_internal_set_xcode_entrypoint_attribute("${target}" "_qt_main_wrapper")
endfunction()
function(_qt_internal_finalize_macos_app target)

View File

@ -0,0 +1,24 @@
# Copyright (C) 2025 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Save the current value of the CMP0156 policy in a propert of the current directory scope.
function(__qt_internal_save_directory_scope_policy_cmp0156)
if(NOT POLICY CMP0156)
return()
endif()
# Exit early if we already saved the policy value for this directory scope.
get_property(policy_value_set DIRECTORY PROPERTY _qt_internal_policy_cmp0156_value_set)
if(policy_value_set)
return()
endif()
cmake_policy(GET CMP0156 policy_value)
set_property(DIRECTORY PROPERTY _qt_internal_policy_cmp0156_value "${policy_value}")
set_property(DIRECTORY PROPERTY _qt_internal_policy_cmp0156_value_set "TRUE")
endfunction()
function(__qt_internal_get_directory_scope_policy_cmp0156 out_var)
get_property(policy_value DIRECTORY PROPERTY _qt_internal_policy_cmp0156_value)
set(${out_var} "${policy_value}" PARENT_SCOPE)
endfunction()

View File

@ -153,7 +153,7 @@ function(__qt_internal_collect_additional_module_paths)
if(is_path_to_cmake)
list(APPEND CMAKE_MODULE_PATH "${prefix_path}/${QT_CMAKE_EXPORT_NAMESPACE}")
else()
__qt_internal_get_possible_cmake_dirs(additional_cmake_dirs "${additional_path}")
__qt_internal_get_possible_cmake_dirs(additional_cmake_dirs "${prefix_path}")
list(TRANSFORM additional_cmake_dirs APPEND "/${QT_CMAKE_EXPORT_NAMESPACE}")
list(APPEND CMAKE_MODULE_PATH ${additional_cmake_dirs})
endif()
@ -174,6 +174,21 @@ function(__qt_internal_prefix_paths_to_roots out_var prefix_paths)
set("${out_var}" "${result}" PARENT_SCOPE)
endfunction()
function(_qt_internal_get_check_cxx_source_compiles_out_var out_output_var out_func_args)
# This just resets the output var in the parent scope to an empty string.
set(${out_output_var} "" PARENT_SCOPE)
# OUTPUT_VARIABLE is an internal undocumented variable of check_cxx_source_compiles
# since 3.23. Allow an opt out in case this breaks in the future.
set(extra_func_args "")
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.23"
AND NOT QT_INTERNAL_NO_TRY_COMPILE_OUTPUT_VARIABLE)
set(extra_func_args OUTPUT_VARIABLE ${out_output_var})
endif()
set(${out_func_args} "${extra_func_args}" PARENT_SCOPE)
endfunction()
# This function gets all targets below this directory
#
# Multi-value Arguments:
@ -536,8 +551,14 @@ endfunction()
# Takes a list of path components and joins them into one path separated by forward slashes "/",
# and saves the path in out_var.
# Filters out any path parts that are bare "."s.
function(_qt_internal_path_join out_var)
string(JOIN "/" path ${ARGN})
set(args ${ARGN})
# Remove any bare ".", to avoid any CMP0177 warnings for paths passed to install().
list(REMOVE_ITEM args ".")
string(JOIN "/" path ${args})
set(${out_var} ${path} PARENT_SCOPE)
endfunction()
@ -597,6 +618,45 @@ function(_qt_internal_remove_args out_var)
set(${out_var} "${result}" PARENT_SCOPE)
endfunction()
function(__qt_internal_handle_find_all_qt_module_packages out_var)
set(opt_args "")
set(single_args "")
set(multi_args
COMPONENTS
)
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_COMPONENTS)
return()
endif()
set(components ${arg_COMPONENTS})
if("ALL_QT_MODULES" IN_LIST components)
list(FIND components "ALL_QT_MODULES" all_qt_modules_index)
list(REMOVE_AT components ${all_qt_modules_index})
# Find the path to dir with module.json files. # We consider each file name to be a
# Qt package (component) name that contains a target with the same name.
set(json_modules_path "${QT6_INSTALL_PREFIX}/${QT6_INSTALL_DESCRIPTIONSDIR}")
file(GLOB json_modules "${json_modules_path}/*.json")
set(all_qt_modules "")
foreach(json_module IN LISTS json_modules)
get_filename_component(module_name "${json_module}" NAME_WE)
list(APPEND all_qt_modules ${module_name})
endforeach()
if(all_qt_modules)
list(INSERT components "${all_qt_modules_index}" ${all_qt_modules})
endif()
endif()
set(${out_var} "${components}" PARENT_SCOPE)
endfunction()
# Append ${ARGN} to ${target}'s ${property_name} property, removing duplicates.
function(_qt_internal_append_to_target_property_without_duplicates target property_name)
get_target_property(property "${target}" "${property_name}")
@ -690,6 +750,7 @@ function(_qt_internal_add_transitive_property target type property)
message(FATAL_ERROR "Attempt to assign unknown TRANSITIVE_${type}_PROPERTIES property")
endif()
_qt_internal_dealias_target(target)
get_target_property(transitive_properties ${target}
TRANSITIVE_${type}_PROPERTIES)
if(NOT "${property}" IN_LIST transitive_properties)
@ -697,3 +758,225 @@ function(_qt_internal_add_transitive_property target type property)
APPEND PROPERTY TRANSITIVE_${type}_PROPERTIES ${property})
endif()
endfunction()
# Compatibility of `cmake_path(RELATIVE_PATH)`
#
# In order to be compatible with `file(RELATIVE_PATH)`, path normalization of the result is
# always performed, with the trailing slash stripped.
#
# Synopsis
#
# _qt_internal_relative_path(<path-var>
# [BASE_DIRECTORY <input>]
# [OUTPUT_VARIABLE <out-var>]
# )
#
# Arguments
#
# `path-var`
# Equivalent to `cmake_path(RELATIVE_PATH <path-var>)`.
#
# `BASE_DIRECTORY`
# Equivalent to `cmake_path(RELATIVE_PATH BASE_DIRECTORY)`.
#
# `OUTPUT_VARIABLE`
# Equivalent to `cmake_path(RELATIVE_PATH OUTPUT_VARIABLE)`.
function(_qt_internal_relative_path path_var)
set(option_args "")
set(single_args
BASE_DIRECTORY
OUTPUT_VARIABLE
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 1 arg "${option_args}" "${single_args}" "${multi_args}")
if(NOT arg_BASE_DIRECTORY)
set(arg_BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()
if(NOT arg_OUTPUT_VARIABLE)
set(arg_OUTPUT_VARIABLE ${path_var})
endif()
if(CMAKE_VERSION VERSION_LESS 3.20)
file(RELATIVE_PATH ${arg_OUTPUT_VARIABLE}
"${arg_BASE_DIRECTORY}"
"${${path_var}}")
else()
cmake_path(RELATIVE_PATH ${path_var}
BASE_DIRECTORY "${arg_BASE_DIRECTORY}"
OUTPUT_VARIABLE ${arg_OUTPUT_VARIABLE}
)
cmake_path(NORMAL_PATH ${arg_OUTPUT_VARIABLE})
string(REGEX REPLACE "/$" "" ${arg_OUTPUT_VARIABLE}
"${${arg_OUTPUT_VARIABLE}}")
endif()
set(${arg_OUTPUT_VARIABLE} "${${arg_OUTPUT_VARIABLE}}" PARENT_SCOPE)
endfunction()
# Compatibility of `cmake_path(IS_PREFIX)`
#
# NORMALIZE keyword is not supported
#
# Synopsis
#
# _qt_internal_path_is_prefix(<path-var> <input> <out-var>)
#
# Arguments
#
# `path-var`
# Equivalent to `cmake_path(IS_PREFIX <path-var>)`.
#
# `input`
# Equivalent to `cmake_path(IS_PREFIX <input>)`.
#
# `out-var`
# Equivalent to `cmake_path(IS_PREFIX <out-var>)`.
function(_qt_internal_path_is_prefix path_var input out_var)
# Make sure the path ends with `/`
if(NOT ${path_var} MATCHES "/$")
set(${path_var} "${${path_var}}/")
endif()
# For the case input == path_var, we need to also include a trailing `/` to match the
# previous change. We discard the actual path for input so we can add it unconditionally
set(input "${input}/")
if(CMAKE_VERSION VERSION_LESS 3.20)
string(FIND "${input}" "${${path_var}}" find_pos)
if(find_pos EQUAL 0)
# input starts_with path_var
set(${out_var} ON)
else()
set(${out_var} OFF)
endif()
else()
cmake_path(IS_PREFIX ${path_var} ${input} ${out_var})
endif()
set(${out_var} "${${out_var}}" PARENT_SCOPE)
endfunction()
function(qt_set01 result)
if (${ARGN})
set("${result}" 1 PARENT_SCOPE)
else()
set("${result}" 0 PARENT_SCOPE)
endif()
endfunction()
# Configures the file using either the input template or the CONTENT.
# Behaves as either file(CONFIGURE or configure_file( command, but do not depend
# on CMake version.
#
# Synopsis
# _qt_internal_configure_file(<CONFIGURE|GENERATE>
# OUTPUT <path>
# <INPUT path|CONTENT data>
# )
#
# Arguments
# `CONFIGURE` Run in pure CONFIGURE mode.
#
# `GENERATE` Configure CONTENT and generate file with the generator expression
# support.
#
# `OUTPUT` The output file name to generate.
#
# `INPUT` The input template file name.
#
# `CONTENT` The template content. If both INPUT and CONTENT are specified, INPUT
# argument is ignored.
function(_qt_internal_configure_file mode)
cmake_parse_arguments(PARSE_ARGV 1 arg "" "OUTPUT;INPUT;CONTENT" "")
if(NOT arg_OUTPUT)
message(FATAL_ERROR "No OUTPUT file provided to _qt_internal_configure_file.")
endif()
# Substitute the '@' wrapped variables and generate the file with the
# the generator expressions evaluation inside the resulting CONTENT.
if(mode STREQUAL "GENERATE")
if(arg_INPUT)
configure_file("${arg_INPUT}" "${arg_OUTPUT}.tmp" @ONLY)
file(GENERATE OUTPUT "${arg_OUTPUT}" INPUT "${arg_OUTPUT}.tmp")
else()
string(CONFIGURE "${arg_CONTENT}" arg_CONTENT @ONLY)
file(GENERATE OUTPUT "${arg_OUTPUT}" CONTENT "${arg_CONTENT}")
endif()
return()
endif()
# We use this check for the cases when the specified CONTENT is empty. The value of arg_CONTENT
# is undefined, but we still want to create a file with empty content.
if("CONTENT" IN_LIST ARGV)
if(arg_INPUT)
message(WARNING "Both CONTENT and INPUT are specified. CONTENT will be used to generate"
" output")
endif()
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.18)
file(CONFIGURE OUTPUT "${arg_OUTPUT}" CONTENT "${arg_CONTENT}" @ONLY)
return()
endif()
set(template_name "QtFileConfigure.txt.in")
# When building qtbase, use the source template file.
# Otherwise use the installed file (basically wherever Qt6 package is found).
# This should work for non-prefix and superbuilds as well.
if(QtBase_SOURCE_DIR)
set(input_file "${QtBase_SOURCE_DIR}/cmake/${template_name}")
else()
set(input_file "${_qt_6_config_cmake_dir}/${template_name}")
endif()
set(__qt_file_configure_content "${arg_CONTENT}")
elseif(arg_INPUT)
set(input_file "${arg_INPUT}")
else()
message(FATAL_ERROR "No input value provided to _qt_internal_configure_file.")
endif()
configure_file("${input_file}" "${arg_OUTPUT}" @ONLY)
endfunction()
# The function checks if `value` is a valid C indentifier.
#
# Synopsis
#
# _qt_internal_is_c_identifier(<out_var> <value>)
#
# Arguments
#
# `out_var`
# Variable name for the evaluation result.
#
# `value`
# The string for the evaluation.
function(_qt_internal_is_c_identifier out_var value)
string(MAKE_C_IDENTIFIER "${value}" value_valid)
if(value AND "${value}" STREQUAL "${value_valid}")
set(${out_var} "TRUE" PARENT_SCOPE)
else()
set(${out_var} "FALSE" PARENT_SCOPE)
endif()
endfunction()
# Makes appending of the CMake configure time dependencies unique.
function(_qt_internal_append_cmake_configure_depends)
get_property(configure_depends DIRECTORY PROPERTY CMAKE_CONFIGURE_DEPENDS)
foreach(path IN LISTS ARGN)
get_filename_component(abs_path "${path}" REALPATH)
if(NOT "${abs_path}" IN_LIST configure_depends)
list(APPEND configure_depends "${abs_path}")
endif()
endforeach()
set_property(DIRECTORY PROPERTY CMAKE_CONFIGURE_DEPENDS "${configure_depends}")
endfunction()
function(_qt_internal_get_moc_compiler_flavor_flags out_var)
set(flags "")
if(WIN32)
list(APPEND flags -DWIN32)
endif()
if(MSVC)
list(APPEND flags --compiler-flavor=msvc)
endif()
set(${out_var} "${flags}" PARENT_SCOPE)
endfunction()

View File

@ -55,9 +55,8 @@ function(__qt_internal_force_allow_unsuitable_cmake_version_for_using_qt out_var
# Temporarily allow any version when using Qt in Qt's CI, so we can decouple the provisioning
# of the minimum CMake version from the bump of the minimum CMake version.
# The COIN_UNIQUE_JOB_ID env var is set in Qt's CI for both build and test work items.
# Current state is that this check is enabled.
# TODO: Disable it once provisioning is merged.
set(allow_any_version_in_ci TRUE)
# Current state is that this check is disabled.
set(allow_any_version_in_ci FALSE)
if(allow_any_version_in_ci AND DEFINED ENV{COIN_UNIQUE_JOB_ID})
set(allow_any_version TRUE)
@ -105,21 +104,88 @@ function(__qt_internal_require_suitable_cmake_version_for_using_qt)
endif()
endfunction()
# Handle force-assignment of CMP0156 policy when using CMake 3.29+.
#
# For Apple-platforms we set it to NEW, to avoid duplicate linker issues when using -ObjC flag.
#
# For non-Apple platforms we set it to OLD, because we haven't done the necessary testing to
# see which platforms / linkers can handle the new deduplication behavior, without breaking the
# various linking techniques that Qt uses for object library propagation.
function(__qt_internal_set_cmp0156)
if(POLICY CMP0156)
if(QT_FORCE_CMP0156_TO_NEW)
cmake_policy(SET CMP0156 "NEW")
else()
cmake_policy(GET CMP0156 policy_value)
if(NOT "${policy_value}" STREQUAL "OLD")
if("${policy_value}" STREQUAL "NEW" AND NOT QT_BUILDING_QT)
message(WARNING "CMP0156 is set to '${policy_value}'. Qt forces the 'OLD'"
" behavior of this policy by default. Set QT_FORCE_CMP0156_TO_NEW=ON to"
" force the 'NEW' behavior for the Qt commands that create either"
" library or executable targets.")
endif()
cmake_policy(SET CMP0156 "OLD")
endif()
# Exit early if not using CMake 3.29+
if(NOT POLICY CMP0156)
return()
endif()
# Honor this variable if it's set and TRUE. It was previously introduced to allow working around
# the forced OLD value.
if(QT_FORCE_CMP0156_TO_NEW)
get_cmake_property(debug_message_shown _qt_internal_cmp0156_debug_message_shown)
if(NOT debug_message_shown)
message(DEBUG "Force setting the CMP0156 policy to user provided value: NEW")
set_property(GLOBAL PROPERTY _qt_internal_cmp0156_debug_message_shown TRUE)
endif()
cmake_policy(SET CMP0156 "NEW")
return()
endif()
# Allow forcing to OLD / NEW or empty behavior due the default being NEW for Apple platforms.
if(QT_FORCE_CMP0156_TO_VALUE)
cmake_policy(SET CMP0156 "${QT_FORCE_CMP0156_TO_VALUE}")
message(DEBUG "Force setting the CMP0156 policy to user provided value: "
"${QT_FORCE_CMP0156_TO_VALUE}")
return()
endif()
# Get the current value of the policy, as saved by the Qt6 package as soon as it is found.
# We can't just do cmake_policy(GET CMP0156 policy_value) here, because our Qt6Config.cmake and
# Qt6FooConfig.cmake files use cmake_minimum_required, which reset the policy value that
# might have been set by the project developer or the user.
# And a function uses the policy values that were set when the function was defined, not when
# it is called.
__qt_internal_get_directory_scope_policy_cmp0156(policy_value)
# Apple linkers (legacy Apple ld64, as well as the new ld-prime) don't care about the
# link line order when linking static libraries, compared to Linux GNU ld.
# But they care about duplicate static frameworks (not libraries) when used in conjunction with
# the -ObjC flag, which force loads all static libraries / frameworks that contain Objective-C
# categories or classes. This can cause duplicate symbol errors.
# To avoid the issue, we want to enable the policy, so we de-duplicate the libraries.
if(APPLE)
set(default_policy_value NEW)
set(unsupported_policy_value OLD)
set(platform_string "Apple")
else()
# For non-Apple linkers, we keep the previous behavior of not deduplicating libraries,
# because we haven't done the necessary testing to identify on which platforms
# it is safe to deduplicate.
set(default_policy_value OLD)
set(unsupported_policy_value NEW)
set(platform_string "non-Apple")
endif()
# Force set the default policy value for the given platform, even if the policy value is
# the same or empty. That's because in the calling function scope, the value can be empty
# due to the cmake_minimum_required call in Qt6Config.cmake resetting the policy value.
get_cmake_property(debug_message_shown _qt_internal_cmp0156_debug_message_shown)
if(NOT debug_message_shown)
message(DEBUG "Force setting the CMP0156 policy to '${default_policy_value}' "
"for ${platform_string} platforms.")
set_property(GLOBAL PROPERTY _qt_internal_cmp0156_debug_message_shown TRUE)
endif()
cmake_policy(SET CMP0156 "${default_policy_value}")
# If the policy is explicitly set to a value other than the default, issue a warning.
# Don't show the warning if the policy is unset, which would be the default for most
# projects, because it's too much noise. Also don't show it for Qt builds.
if("${policy_value}" STREQUAL "${unsupported_policy_value}" AND NOT QT_BUILDING_QT)
message(WARNING
"CMP0156 is set to '${policy_value}'. Qt forces the '${default_policy_value}'"
" behavior of this policy for ${platform_string} platforms by default."
" Set QT_FORCE_CMP0156_TO_VALUE=${unsupported_policy_value} to force"
" the '${unsupported_policy_value}' behavior for Qt commands that create"
" library or executable targets.")
endif()
endfunction()

View File

@ -34,6 +34,9 @@ macro(_qt_internal_find_third_party_dependencies target target_dep_list)
find_package(${__qt_${target}_find_package_args})
else()
find_dependency(${__qt_${target}_find_package_args})
if(NOT ${__qt_${target}_pkg}_FOUND)
list(APPEND __qt_${target}_missing_deps "${__qt_${target}_pkg}")
endif()
endif()
_qt_internal_get_package_components_id(
@ -83,15 +86,15 @@ macro(_qt_internal_find_tool_dependencies target target_dep_list)
"${_qt_additional_host_packages_root_paths}")
endif()
unset(__qt_${target}_find_package_args)
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
list(APPEND __qt_${target}_find_package_args QUIET)
endif()
foreach(__qt_${target}_target_dep IN LISTS ${target_dep_list})
list(GET __qt_${target}_target_dep 0 __qt_${target}_pkg)
list(GET __qt_${target}_target_dep 1 __qt_${target}_version)
unset(__qt_${target}_find_package_args)
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
list(APPEND __qt_${target}_find_package_args QUIET)
endif()
_qt_internal_save_find_package_context_for_debugging(${target})
find_package(${__qt_${target}_pkg}
@ -124,42 +127,34 @@ endmacro()
# contain preformed dependencies. See foreach block for reference.
# The same applies for find_dependency_path_list.
macro(_qt_internal_find_qt_dependencies target target_dep_list find_dependency_path_list)
list(APPEND __qt_${target}_find_qt_dependencies_save_QT_NO_PRIVATE_MODULE_WARNING
${QT_NO_PRIVATE_MODULE_WARNING}
)
set(QT_NO_PRIVATE_MODULE_WARNING ON)
foreach(__qt_${target}_target_dep IN LISTS ${target_dep_list})
list(GET __qt_${target}_target_dep 0 __qt_${target}_pkg)
list(GET __qt_${target}_target_dep 1 __qt_${target}_version)
if (NOT ${__qt_${target}_pkg}_FOUND)
# TODO: Remove Private handling once sufficient time has passed, aka all developers
# updated their builds not to contain stale FooDependencies.cmake files without the
# _qt_package_name property.
set(__qt_${target}_pkg_names ${__qt_${target}_pkg})
if(__qt_${target}_pkg MATCHES "(.*)Private$")
set(__qt_${target}_pkg_names "${CMAKE_MATCH_1};${__qt_${target}_pkg}")
endif()
_qt_internal_save_find_package_context_for_debugging(${target})
find_dependency(${__qt_${target}_pkg} ${__qt_${target}_version}
NAMES
${__qt_${target}_pkg_names}
PATHS
${QT_BUILD_CMAKE_PREFIX_PATH}
${${find_dependency_path_list}}
${_qt_additional_packages_prefix_paths}
${__qt_use_no_default_path_for_qt_packages}
)
if(NOT ${__qt_${target}_pkg}_FOUND)
list(APPEND __qt_${target}_missing_deps "${__qt_${target}_pkg}")
endif()
endif()
endforeach()
endmacro()
# TODO: Remove once a dependency update completes and most developers have the Dependencies.cmake
# files updated in their builds.
# The name is too generic, it doesn't look for any kind of dependencies but only Qt package
# dependencies.
macro(_qt_internal_find_dependencies target_dep_list find_dependency_path_list)
_qt_internal_find_qt_dependencies("none" "${target_dep_list}" "${find_dependency_path_list}")
list(POP_BACK __qt_${target}_find_qt_dependencies_save_QT_NO_PRIVATE_MODULE_WARNING
QT_NO_PRIVATE_MODULE_WARNING
)
endmacro()
# If a dependency package was not found, provide some hints in the error message on how to debug
@ -243,9 +238,9 @@ function(_qt_internal_determine_if_host_info_package_needed out_var)
set(${out_var} "${needed}" PARENT_SCOPE)
endfunction()
macro(_qt_internal_find_host_info_package platform_requires_host_info)
macro(_qt_internal_find_host_info_package platform_requires_host_info install_namespace)
if(${platform_requires_host_info})
find_package(Qt6HostInfo
find_package(${install_namespace}HostInfo
CONFIG
REQUIRED
PATHS "${QT_HOST_PATH}"
@ -326,3 +321,23 @@ macro(_qt_internal_setup_qt_host_path
endif()
endif()
endmacro()
function(_qt_internal_show_private_module_warning module)
if(DEFINED QT_REPO_MODULE_VERSION OR QT_NO_PRIVATE_MODULE_WARNING OR QT_FIND_PRIVATE_MODULES)
return()
endif()
get_cmake_property(warning_shown __qt_private_module_${module}_warning_shown)
if(warning_shown)
return()
endif()
message(WARNING
"This project is using headers of the ${module} module and will therefore be tied "
"to this specific Qt module build version. "
"Running this project against other versions of the Qt modules may crash at any arbitrary "
"point. This is not a bug, but a result of using Qt internals. You have been warned! "
"\nYou can disable this warning by setting QT_NO_PRIVATE_MODULE_WARNING to ON."
)
set_property(GLOBAL PROPERTY __qt_private_module_${module}_warning_shown TRUE)
endfunction()

View File

@ -49,6 +49,16 @@ function(_qt_internal_query_git_version)
set(git_version "${version_git_head}+${version_git_branch}")
endif()
if(QT_SBOM_FAKE_GIT_VERSION)
set(version_git_head "fakegithead")
set(version_git_hash "fakegithash")
set(version_git_branch "fakegitbranch")
set(version_git_tag "fakegittag")
set(git_version "${version_git_head}+${version_git_branch}")
_qt_internal_set_git_query_variables()
return()
endif()
if(NOT Git_FOUND)
message(STATUS "Git not found, skipping querying git version.")
_qt_internal_set_git_query_variables()

View File

@ -248,10 +248,7 @@ function(__qt_internal_add_static_plugin_init_object_library
CONTENT "${import_content}"
)
# CMake versions earlier than 3.18.0 can't find the generated file for some reason,
# failing at generation phase.
# Explicitly marking the file as GENERATED fixes the issue.
set_source_files_properties("${generated_qt_plugin_file_name}" PROPERTIES GENERATED TRUE)
_qt_internal_set_source_file_generated(SOURCES "${generated_qt_plugin_file_name}")
__qt_internal_get_static_plugin_init_target_name("${plugin_target}" plugin_init_target)
@ -416,46 +413,6 @@ function(__qt_internal_collect_plugin_targets_from_dependencies_of_plugins targe
set("${out_var}" "${plugin_targets}" PARENT_SCOPE)
endfunction()
# Generate plugin information files for deployment
#
# Arguments:
# OUT_PLUGIN_TARGETS - Variable name to store the plugin targets that were collected with
# __qt_internal_collect_plugin_targets_from_dependencies.
function(__qt_internal_generate_plugin_deployment_info target)
set(no_value_options "")
set(single_value_options "OUT_PLUGIN_TARGETS")
set(multi_value_options "")
cmake_parse_arguments(PARSE_ARGV 0 arg
"${no_value_options}" "${single_value_options}" "${multi_value_options}"
)
__qt_internal_collect_plugin_targets_from_dependencies("${target}" plugin_targets)
if(NOT "${arg_OUT_PLUGIN_TARGETS}" STREQUAL "")
set("${arg_OUT_PLUGIN_TARGETS}" "${plugin_targets}" PARENT_SCOPE)
endif()
get_target_property(marked_for_deployment ${target} _qt_marked_for_deployment)
if(NOT marked_for_deployment)
return()
endif()
__qt_internal_collect_plugin_library_files(${target} "${plugin_targets}" plugins_files)
set(plugins_files "$<FILTER:${plugins_files},EXCLUDE,^$>")
_qt_internal_get_deploy_impl_dir(deploy_impl_dir)
set(file_path "${deploy_impl_dir}/${target}-plugins")
get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG)
if(is_multi_config)
string(APPEND file_path "-$<CONFIG>")
endif()
string(APPEND file_path ".cmake")
file(GENERATE
OUTPUT ${file_path}
CONTENT "set(__QT_DEPLOY_PLUGINS ${plugins_files})"
)
endfunction()
# Main logic of finalizer mode.
function(__qt_internal_apply_plugin_imports_finalizer_mode target)
# Process a target only once.
@ -464,9 +421,6 @@ function(__qt_internal_apply_plugin_imports_finalizer_mode target)
return()
endif()
__qt_internal_generate_plugin_deployment_info(${target}
OUT_PLUGIN_TARGETS plugin_targets)
# By default if the project hasn't explicitly opted in or out, use finalizer mode.
# The precondition for this is that qt_finalize_target was called (either explicitly by the user
# or auto-deferred by CMake 3.19+).
@ -480,6 +434,7 @@ function(__qt_internal_apply_plugin_imports_finalizer_mode target)
return()
endif()
__qt_internal_collect_plugin_targets_from_dependencies("${target}" plugin_targets)
__qt_internal_collect_plugin_init_libraries("${plugin_targets}" init_libraries)
__qt_internal_collect_plugin_libraries("${plugin_targets}" plugin_libraries)
@ -518,6 +473,20 @@ function(__qt_internal_add_interface_plugin_target plugin_module_target plugin_t
APPEND PROPERTY INTERFACE_QT_PLUGIN_TARGETS ${plugin_target_name_wrapped})
endfunction()
# TODO: Figure out how to do this more reliably, instead of parsing the file name to get
# the target name.
function(__qt_internal_get_target_name_from_plugin_config_file_name
config_file_path
package_prefix_regex
out_var)
string(REGEX REPLACE
"^.*/${QT_CMAKE_EXPORT_NAMESPACE}(${package_prefix_regex})Config.cmake$"
"\\1"
target "${config_file_path}")
set(${out_var} "${target}" PARENT_SCOPE)
endfunction()
# Include CMake plugin packages that belong to the Qt module ${target} and initialize automatic
# linkage of the plugins in static builds.
# The variables inside the macro have to be named unique to the module because an included Plugin
@ -529,10 +498,7 @@ macro(__qt_internal_include_plugin_packages target)
# Properties can't be set on aliased targets, so make sure to unalias the target. This is needed
# when Qt examples are built as part of the Qt build itself.
get_target_property(_aliased_target ${__qt_${target}_plugin_module_target} ALIASED_TARGET)
if(_aliased_target)
set(__qt_${target}_plugin_module_target ${_aliased_target})
endif()
_qt_internal_dealias_target(__qt_${target}_plugin_module_target)
# Ensure that QT_PLUGIN_TARGETS is a known transitive compile property. Works with CMake
# versions >= 3.30.
@ -546,11 +512,14 @@ macro(__qt_internal_include_plugin_packages target)
file(GLOB __qt_${target}_plugin_config_files
"${CMAKE_CURRENT_LIST_DIR}/${QT_CMAKE_EXPORT_NAMESPACE}*PluginConfig.cmake")
foreach(__qt_${target}_plugin_config_file ${__qt_${target}_plugin_config_files})
string(REGEX REPLACE
"^.*/${QT_CMAKE_EXPORT_NAMESPACE}(.*Plugin)Config.cmake$"
"\\1"
__qt_${target}_qt_plugin "${__qt_${target}_plugin_config_file}")
include("${__qt_${target}_plugin_config_file}")
__qt_internal_get_target_name_from_plugin_config_file_name(
"${__qt_${target}_plugin_config_file}"
"(.*Plugin)"
__qt_${target}_qt_plugin
)
if(TARGET "${QT_CMAKE_EXPORT_NAMESPACE}::${__qt_${target}_qt_plugin}")
list(APPEND __qt_${target}_plugins ${__qt_${target}_qt_plugin})
__qt_internal_add_interface_plugin_target(${__qt_${target}_plugin_module_target}
@ -581,10 +550,34 @@ macro(__qt_internal_include_plugin_packages target)
continue()
endif()
list(APPEND "QT_ALL_PLUGINS_FOUND_BY_FIND_PACKAGE_${__plugin_type}" "${plugin_target}")
set(plugin_target_versioned "${QT_CMAKE_EXPORT_NAMESPACE}::${plugin_target}")
if(NOT "${plugin_target}"
IN_LIST QT_ALL_PLUGINS_FOUND_VIA_FIND_PACKAGE)
# Old compatibility name.
# TODO: Remove once all usages are ported.
list(APPEND QT_ALL_PLUGINS_FOUND_BY_FIND_PACKAGE "${plugin_target}")
# New name consistent with other such variables.
list(APPEND QT_ALL_PLUGINS_FOUND_VIA_FIND_PACKAGE "${plugin_target}")
list(APPEND QT_ALL_PLUGINS_VERSIONED_FOUND_VIA_FIND_PACKAGE
"${plugin_target_versioned}")
endif()
if(NOT "${plugin_target}" IN_LIST QT_ALL_PLUGINS_FOUND_VIA_FIND_PACKAGE_${__plugin_type})
# Old compatibility name.
# TODO: Remove once all usages are ported.
list(APPEND QT_ALL_PLUGINS_FOUND_BY_FIND_PACKAGE_${__plugin_type} "${plugin_target}")
# New name consistent with other such variables.
list(APPEND QT_ALL_PLUGINS_FOUND_VIA_FIND_PACKAGE_${__plugin_type} "${plugin_target}")
list(APPEND
QT_ALL_PLUGINS_VERSIONED_FOUND_VIA_FIND_PACKAGE_${__plugin_type}
"${plugin_target_versioned}")
endif()
# Auto-linkage should be set up only for static plugins.
set(plugin_target_versioned "${QT_CMAKE_EXPORT_NAMESPACE}::${plugin_target}")
get_target_property(type "${plugin_target_versioned}" TYPE)
if(type STREQUAL STATIC_LIBRARY)
__qt_internal_add_static_plugin_linkage(
@ -597,3 +590,87 @@ macro(__qt_internal_include_plugin_packages target)
set_target_properties(
${__qt_${target}_plugin_module_target} PROPERTIES __qt_internal_plugins_added TRUE)
endmacro()
# Include Qt Qml plugin CMake packages that are present under the Qml package directory.
# TODO: Consider moving this to qtdeclarative somehow.
macro(__qt_internal_include_qml_plugin_packages)
# Qml plugin targets might have dependencies on other qml plugin targets, but the Targets.cmake
# files are included in the order that file(GLOB) returns, which means certain targets that are
# referenced might not have been created yet, and ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
# might be set to a message saying those targets don't exist.
#
# Postpone checking of which targets don't exist until all Qml PluginConfig.cmake files have
# been included, by including all the files one more time and checking for errors at each step.
#
# TODO: Find a better way to deal with this, perhaps by using find_package() instead of include
# for the Qml PluginConfig.cmake files.
# Distributions should probably change this default.
if(NOT DEFINED QT_SKIP_AUTO_QML_PLUGIN_INCLUSION)
set(QT_SKIP_AUTO_QML_PLUGIN_INCLUSION OFF)
endif()
set(__qt_qml_plugins_config_file_list "")
set(__qt_qml_plugins_glob_prefixes "${CMAKE_CURRENT_LIST_DIR}")
# Allow passing additional prefixes where we will glob for PluginConfig.cmake files.
if(QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES)
foreach(__qt_qml_plugin_glob_prefix IN LISTS QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES)
if(__qt_qml_plugin_glob_prefix)
list(APPEND __qt_qml_plugins_glob_prefixes "${__qt_qml_plugin_glob_prefix}")
endif()
endforeach()
endif()
list(REMOVE_DUPLICATES __qt_qml_plugins_glob_prefixes)
foreach(__qt_qml_plugin_glob_prefix IN LISTS __qt_qml_plugins_glob_prefixes)
file(GLOB __qt_qml_plugins_glob_config_file_list
"${__qt_qml_plugin_glob_prefix}/QmlPlugins/${INSTALL_CMAKE_NAMESPACE}*Config.cmake")
if(__qt_qml_plugins_glob_config_file_list)
list(APPEND __qt_qml_plugins_config_file_list ${__qt_qml_plugins_glob_config_file_list})
endif()
endforeach()
if (__qt_qml_plugins_config_file_list AND NOT QT_SKIP_AUTO_QML_PLUGIN_INCLUSION)
# First round of inclusions ensure all qml plugin targets are brought into scope.
foreach(__qt_qml_plugin_config_file ${__qt_qml_plugins_config_file_list})
include(${__qt_qml_plugin_config_file})
# Temporarily unset any failure markers and mark the Qml package as found.
unset(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE)
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND TRUE)
endforeach()
# For the second round of inclusions, check and bail out early if there are errors.
foreach(__qt_qml_plugin_config_file ${__qt_qml_plugins_config_file_list})
include(${__qt_qml_plugin_config_file})
__qt_internal_get_target_name_from_plugin_config_file_name(
"${__qt_qml_plugin_config_file}"
"(.*)"
__qt_qml_plugin_target
)
set(__qt_qml_plugin_target_versioned
"${QT_CMAKE_EXPORT_NAMESPACE}::${__qt_qml_plugin_target}")
if(TARGET "${__qt_qml_plugin_target_versioned}"
AND NOT "${__qt_qml_plugin_target}"
IN_LIST QT_ALL_QML_PLUGINS_FOUND_VIA_FIND_PACKAGE)
list(APPEND QT_ALL_QML_PLUGINS_FOUND_VIA_FIND_PACKAGE "${__qt_qml_plugin_target}")
list(APPEND QT_ALL_QML_PLUGINS_VERSIONED_FOUND_VIA_FIND_PACKAGE
"${__qt_qml_plugin_target_versioned}")
endif()
unset(__qt_qml_plugin_target)
unset(__qt_qml_plugin_target_versioned)
if(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE)
string(APPEND ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
"\nThe message was set in ${__qt_qml_plugin_config_file} ")
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
return()
endif()
endforeach()
endif()
endmacro()

View File

@ -0,0 +1,599 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Handles attribution information for a target.
#
# If CREATE_SBOM_FOR_EACH_ATTRIBUTION is set, a separate sbom target is created for each parsed
# attribution entry, and the new targets are added as dependencies to the parent target.
#
# If CREATE_SBOM_FOR_EACH_ATTRIBUTION is not set, the information read from the first attribution
# entry is added directly to the parent target, aka the the values are propagated to the outer
# function scope to be read.. The rest of the attribution entries are created as separate targets
# and added as dependencies, as if the option was passed.
#
# Handles multiple attribution files and entries within a file.
# Attribution files can be specified either via directories and direct file paths.
# If ATTRIBUTION_ENTRY_INDEX is set, only that specific attribution entry will be processed
# from the given attribution file.
function(_qt_internal_sbom_handle_qt_attribution_files out_prefix_outer)
if(NOT QT_GENERATE_SBOM)
return()
endif()
if(CMAKE_VERSION LESS_EQUAL "3.19")
message(DEBUG "CMake version is too low, can't parse attribution.json file.")
return()
endif()
set(opt_args "")
set(single_args "")
set(multi_args "")
_qt_internal_get_sbom_specific_options(sbom_opt_args sbom_single_args sbom_multi_args)
list(APPEND opt_args ${sbom_opt_args})
list(APPEND single_args ${sbom_single_args})
list(APPEND multi_args ${sbom_multi_args})
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
set(attribution_files "")
set(attribution_file_count 0)
foreach(attribution_file_path IN LISTS arg_ATTRIBUTION_FILE_PATHS)
get_filename_component(real_path "${attribution_file_path}" REALPATH)
list(APPEND attribution_files "${real_path}")
math(EXPR attribution_file_count "${attribution_file_count} + 1")
endforeach()
foreach(attribution_file_dir_path IN LISTS arg_ATTRIBUTION_FILE_DIR_PATHS)
get_filename_component(real_path
"${attribution_file_dir_path}/qt_attribution.json" REALPATH)
list(APPEND attribution_files "${real_path}")
math(EXPR attribution_file_count "${attribution_file_count} + 1")
endforeach()
# If CREATE_SBOM_FOR_EACH_ATTRIBUTION is set, that means the parent target is likely not a
# 3rd party library, so each attribution entry should create a separate attribution target.
# In which case we don't want to proagate options like CPE to the child attribution targets,
# because the CPE is meant for the parent target.
set(propagate_sbom_options_to_new_attribution_targets TRUE)
if(arg___QT_INTERNAL_HANDLE_QT_ENTITY_ATTRIBUTION_FILES)
_qt_internal_sbom_is_qt_entity_type("${arg_TYPE}" is_qt_entity_type)
if(is_qt_entity_type)
set(arg_CREATE_SBOM_FOR_EACH_ATTRIBUTION TRUE)
endif()
endif()
if(arg_CREATE_SBOM_FOR_EACH_ATTRIBUTION)
set(propagate_sbom_options_to_new_attribution_targets FALSE)
if(NOT arg_ATTRIBUTION_PARENT_TARGET)
message(FATAL_ERROR "ATTRIBUTION_PARENT_TARGET must be set")
endif()
endif()
if(arg_ATTRIBUTION_ENTRY_INDEX AND attribution_file_count GREATER 1)
message(FATAL_ERROR
"ATTRIBUTION_ENTRY_INDEX should only be set if a single attribution "
"file is specified."
)
endif()
set(ids_to_add "")
set(ids_found "")
if(arg_ATTRIBUTION_IDS)
set(ids_to_add ${arg_ATTRIBUTION_IDS})
endif()
set(file_index 0)
set(first_attribution_processed FALSE)
foreach(attribution_file_path IN LISTS attribution_files)
# Collect all processed attribution files to later create a configure-time dependency on
# them so that the SBOM is regenerated (and CMake is re-ran) if they are modified.
set_property(GLOBAL APPEND PROPERTY _qt_internal_project_attribution_files
"${attribution_file_path}")
# Set a unique out_prefix that will not overlap when multiple entries are processed.
set(out_prefix_file "${out_prefix_outer}_${file_index}")
# Get the number of entries in the attribution file.
_qt_internal_sbom_read_qt_attribution(${out_prefix_file}
GET_ATTRIBUTION_ENTRY_COUNT
OUT_VAR_VALUE attribution_entry_count
FILE_PATH "${attribution_file_path}"
)
# If a specific entry was specified, we will only process it from the file.
if(NOT "${arg_ATTRIBUTION_ENTRY_INDEX}" STREQUAL "")
set(entry_index ${arg_ATTRIBUTION_ENTRY_INDEX})
else()
set(entry_index 0)
endif()
# Go through each entry in the attribution file.
while("${entry_index}" LESS "${${out_prefix_file}_attribution_entry_count}")
# If this is the first entry to be processed, or if CREATE_SBOM_FOR_EACH_ATTRIBUTION
# is not set, we read the attribution file entry directly, and propagate the values
# to the parent scope.
if(NOT first_attribution_processed AND NOT arg_CREATE_SBOM_FOR_EACH_ATTRIBUTION)
# Set a prefix without indices, so that the parent scope add_sbom call can
# refer to the values directly with the outer prefix, without any index infix.
set(out_prefix "${out_prefix_outer}")
_qt_internal_sbom_read_qt_attribution(${out_prefix}
GET_DEFAULT_KEYS
ENTRY_INDEX "${entry_index}"
OUT_VAR_ASSIGNED_VARIABLE_NAMES variable_names
FILE_PATH "${attribution_file_path}"
)
# Check if we need to filter for specific ids.
if(ids_to_add AND ${out_prefix}_attribution_id)
if("${${out_prefix}_attribution_id}" IN_LIST ids_to_add)
list(APPEND ids_found "${${out_prefix}_attribution_id}")
else()
# Skip to next entry.
math(EXPR entry_index "${entry_index} + 1")
continue()
endif()
endif()
# Propagate the values to the outer scope.
foreach(variable_name IN LISTS variable_names)
set(${out_prefix}_${variable_name} "${${out_prefix}_${variable_name}}"
PARENT_SCOPE)
endforeach()
get_filename_component(relative_attribution_file_path
"${attribution_file_path}" REALPATH)
set(${out_prefix}_chosen_attribution_file_path "${relative_attribution_file_path}"
PARENT_SCOPE)
set(${out_prefix}_chosen_attribution_entry_index "${entry_index}"
PARENT_SCOPE)
set(first_attribution_processed TRUE)
if(NOT "${arg_ATTRIBUTION_ENTRY_INDEX}" STREQUAL "")
# We had a specific index to process, so break right after processing it.
break()
endif()
else()
# We are processing the second or later entry, or CREATE_SBOM_FOR_EACH_ATTRIBUTION
# was set. Instead of directly reading all the keys from the attribution file,
# we get the Id, and create a new sbom target for the entry.
# That will recursively call this function with a specific attribution file path
# and index, to process the specific entry.
set(out_prefix "${out_prefix_outer}_${file_index}_${entry_index}")
# Get the attribution id.
_qt_internal_sbom_read_qt_attribution(${out_prefix}
GET_KEY
KEY Id
OUT_VAR_VALUE attribution_id
ENTRY_INDEX "${entry_index}"
FILE_PATH "${attribution_file_path}"
)
# Check if we need to filter for specific ids
if(ids_to_add AND ${out_prefix}_attribution_id)
if("${${out_prefix}_attribution_id}" IN_LIST ids_to_add)
list(APPEND ids_found "${${out_prefix}_attribution_id}")
else()
# Skip to next entry.
math(EXPR entry_index "${entry_index} + 1")
continue()
endif()
endif()
# If no Id was retrieved, just add a numeric one, to make the sbom target
# unique.
set(attribution_target "${arg_ATTRIBUTION_PARENT_TARGET}_Attribution_")
if(NOT ${out_prefix}_attribution_id)
string(APPEND attribution_target "${file_index}_${entry_index}")
else()
string(APPEND attribution_target "${${out_prefix}_attribution_id}")
endif()
# Sanitize the target name, to avoid issues with slashes and other unsupported chars
# in target names.
string(REGEX REPLACE "[^a-zA-Z0-9_-]" "_"
attribution_target "${attribution_target}")
set(sbom_args "")
# Always propagate the package supplier, because we assume the supplier for 3rd
# party libs is the same as the current project supplier.
# Also propagate the internal qt entity type values like CPE, supplier, PURL
# handling options, attribution file values, if set.
_qt_internal_forward_function_args(
FORWARD_APPEND
FORWARD_PREFIX arg
FORWARD_OUT_VAR sbom_args
FORWARD_OPTIONS
USE_ATTRIBUTION_FILES
__QT_INTERNAL_HANDLE_QT_ENTITY_TYPE_CPE
__QT_INTERNAL_HANDLE_QT_ENTITY_TYPE_SUPPLIER
__QT_INTERNAL_HANDLE_QT_ENTITY_TYPE_PURL
__QT_INTERNAL_HANDLE_QT_ENTITY_ATTRIBUTION_FILES
FORWARD_SINGLE
SUPPLIER
)
if(propagate_sbom_options_to_new_attribution_targets)
# Filter out the attributtion options, they will be passed mnaually
# depending on which file and index is currently being processed.
_qt_internal_get_sbom_specific_options(
sbom_opt_args sbom_single_args sbom_multi_args)
list(REMOVE_ITEM sbom_opt_args
NO_CURRENT_DIR_ATTRIBUTION
CREATE_SBOM_FOR_EACH_ATTRIBUTION
)
list(REMOVE_ITEM sbom_single_args ATTRIBUTION_ENTRY_INDEX)
list(REMOVE_ITEM sbom_multi_args
ATTRIBUTION_IDS
ATTRIBUTION_FILE_PATHS
ATTRIBUTION_FILE_DIR_PATHS
)
# Also filter out the FRIENDLY_PACKAGE_NAME option, otherwise we'd try to
# file(GENERATE) multiple times with the same file name, but different content.
list(REMOVE_ITEM sbom_single_args FRIENDLY_PACKAGE_NAME)
_qt_internal_forward_function_args(
FORWARD_APPEND
FORWARD_PREFIX arg
FORWARD_OUT_VAR sbom_args
FORWARD_OPTIONS
${sbom_opt_args}
FORWARD_SINGLE
${sbom_single_args}
FORWARD_MULTI
${sbom_multi_args}
)
endif()
# Create another sbom target with the id as a hint for the target name,
# the attribution file passed, and make the new target a dependency of the
# parent one.
if(arg___QT_INTERNAL_HANDLE_QT_ENTITY_ATTRIBUTION_FILES)
set(attribution_entity_type QT_THIRD_PARTY_SOURCES)
else()
set(attribution_entity_type THIRD_PARTY_SOURCES)
endif()
_qt_internal_add_sbom("${attribution_target}"
IMMEDIATE_FINALIZATION
TYPE "${attribution_entity_type}"
ATTRIBUTION_FILE_PATHS "${attribution_file_path}"
ATTRIBUTION_ENTRY_INDEX "${entry_index}"
NO_CURRENT_DIR_ATTRIBUTION
${sbom_args}
)
_qt_internal_extend_sbom_dependencies(${arg_ATTRIBUTION_PARENT_TARGET}
SBOM_DEPENDENCIES ${attribution_target}
)
endif()
math(EXPR entry_index "${entry_index} + 1")
endwhile()
math(EXPR file_index "${file_index} + 1")
endforeach()
# Show an error if an id is unaccounted for, it might be it has moved to a different file, that
# is not referenced.
if(ids_to_add)
set(attribution_ids_diff ${ids_to_add})
list(REMOVE_ITEM attribution_ids_diff ${ids_found})
if(attribution_ids_diff)
set(error_message
"The following required attribution ids were not found in the attribution files")
if(arg_ATTRIBUTION_PARENT_TARGET)
string(APPEND error_message " for target: ${arg_ATTRIBUTION_PARENT_TARGET}")
endif()
string(APPEND error_message " ids: ${attribution_ids_diff}")
message(FATAL_ERROR "${error_message}")
endif()
endif()
endfunction()
# Helper to parse a qt_attribution.json file and do various operations:
# - GET_DEFAULT_KEYS extracts the license id, copyrights, version, etc.
# - GET_KEY extracts a single given json key's value, as specified with KEY and saved into
# OUT_VAR_VALUE
# - GET_ATTRIBUTION_ENTRY_COUNT returns the number of entries in the json file, set in
# OUT_VAR_VALUE
#
# ENTRY_INDEX can be used to specify the array index to select a specific entry in the json file.
#
# Any retrieved value is set in the outer scope.
# The variables are prefixed with ${out_prefix}.
# OUT_VAR_ASSIGNED_VARIABLE_NAMES contains the list of variables set in the parent scope, the
# variables names in this list are not prefixed with ${out_prefix}.
#
# Requires cmake 3.19 for json parsing.
function(_qt_internal_sbom_read_qt_attribution out_prefix)
if(NOT QT_GENERATE_SBOM)
return()
endif()
if(CMAKE_VERSION LESS_EQUAL "3.19")
message(DEBUG "CMake version is too low, can't parse attribution.json file.")
return()
endif()
set(opt_args
GET_DEFAULT_KEYS
GET_KEY
GET_ATTRIBUTION_ENTRY_COUNT
)
set(single_args
FILE_PATH
KEY
ENTRY_INDEX
OUT_VAR_VALUE
OUT_VAR_ASSIGNED_VARIABLE_NAMES
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
set(file_path "${arg_FILE_PATH}")
if(NOT file_path)
message(FATAL_ERROR "qt attribution file path not given")
endif()
file(READ "${file_path}" contents)
if(NOT contents)
message(FATAL_ERROR "qt attribution file is empty: ${file_path}")
endif()
if(NOT arg_GET_DEFAULT_KEYS AND NOT arg_GET_KEY AND NOT arg_GET_ATTRIBUTION_ENTRY_COUNT)
message(FATAL_ERROR
"No valid operation specified to _qt_internal_sbom_read_qt_attribution call.")
endif()
if(arg_GET_KEY)
if(NOT arg_KEY)
message(FATAL_ERROR "KEY must be set")
endif()
if(NOT arg_OUT_VAR_VALUE)
message(FATAL_ERROR "OUT_VAR_VALUE must be set")
endif()
endif()
get_filename_component(attribution_file_dir "${file_path}" DIRECTORY)
# Parse the json file.
# The first element might be an array, or an object. We need to detect which one.
# Do that by trying to query index 0 of the potential root array.
# If the index is found, that means the root is an array, and elem_error is set to NOTFOUND,
# because there was no error.
# Otherwise elem_error will be something like 'member '0' not found', and we can assume the
# root is an object.
string(JSON first_elem_type ERROR_VARIABLE elem_error TYPE "${contents}" 0)
if(elem_error STREQUAL "NOTFOUND")
# Root is an array. The attribution file might contain multiple entries.
# Pick the first one if no specific index was specified, otherwise use the given index.
if(NOT "${arg_ENTRY_INDEX}" STREQUAL "")
set(indices "${arg_ENTRY_INDEX}")
else()
set(indices "0")
endif()
set(is_array TRUE)
else()
# Root is an object, not an array, which means the file has a single entry.
set(indices "")
set(is_array FALSE)
endif()
set(variable_names "")
if(arg_GET_KEY)
_qt_internal_sbom_get_attribution_key(${arg_KEY} ${arg_OUT_VAR_VALUE} ${out_prefix})
endif()
if(arg_GET_ATTRIBUTION_ENTRY_COUNT)
if(NOT arg_OUT_VAR_VALUE)
message(FATAL_ERROR "OUT_VAR_VALUE must be set")
endif()
if(is_array)
string(JSON attribution_entry_count ERROR_VARIABLE elem_error LENGTH "${contents}")
# There was an error getting the length of the array, so we assume it's empty.
if(NOT elem_error STREQUAL "NOTFOUND")
set(attribution_entry_count 0)
endif()
else()
set(attribution_entry_count 1)
endif()
set(${out_prefix}_${arg_OUT_VAR_VALUE} "${attribution_entry_count}" PARENT_SCOPE)
endif()
if(arg_GET_DEFAULT_KEYS)
_qt_internal_sbom_get_attribution_key(Id attribution_id "${out_prefix}")
_qt_internal_sbom_get_attribution_key(LicenseId license_id "${out_prefix}")
_qt_internal_sbom_get_attribution_key(License license "${out_prefix}")
_qt_internal_sbom_get_attribution_key(LicenseFile license_file "${out_prefix}")
_qt_internal_sbom_get_attribution_key(Version version "${out_prefix}")
_qt_internal_sbom_get_attribution_key(Homepage homepage "${out_prefix}")
_qt_internal_sbom_get_attribution_key(Name attribution_name "${out_prefix}")
_qt_internal_sbom_get_attribution_key(Description description "${out_prefix}")
_qt_internal_sbom_get_attribution_key(QtUsage qt_usage "${out_prefix}")
_qt_internal_sbom_get_attribution_key(DownloadLocation download_location "${out_prefix}")
_qt_internal_sbom_get_attribution_key(Copyright copyrights "${out_prefix}" IS_MULTI_VALUE)
_qt_internal_sbom_get_attribution_key(CopyrightFile copyright_file "${out_prefix}")
_qt_internal_sbom_get_attribution_key(PURL purls "${out_prefix}" IS_MULTI_VALUE)
_qt_internal_sbom_get_attribution_key(CPE cpes "${out_prefix}" IS_MULTI_VALUE)
# Some attribution files contain a copyright file that contains the actual list of
# copyrights. Read it and use it.
set(copyright_file_path "${attribution_file_dir}/${copyright_file}")
get_filename_component(copyright_file_path "${copyright_file_path}" REALPATH)
if(NOT copyrights AND copyright_file AND EXISTS "${copyright_file_path}")
file(READ "${copyright_file_path}" copyright_contents)
if(copyright_contents)
set(copyright_contents "${copyright_contents}")
set(copyrights "${copyright_contents}")
set(${out_prefix}_copyrights "${copyright_contents}" PARENT_SCOPE)
list(APPEND variable_names "copyrights")
endif()
endif()
endif()
if(arg_OUT_VAR_ASSIGNED_VARIABLE_NAMES)
set(${arg_OUT_VAR_ASSIGNED_VARIABLE_NAMES} "${variable_names}" PARENT_SCOPE)
endif()
endfunction()
# Extracts a string or an array of strings from a json index path, depending on the extracted value
# type.
#
# Given the 'contents' of the whole json document and the EXTRACTED_VALUE of a json key specified
# by the INDICES path, it tries to determine whether the value is an array, in which case the array
# is converted to a cmake list and assigned to ${out_var} in the parent scope.
# Otherwise the function assumes the EXTRACTED_VALUE was not an array, and just assigns the value
# of EXTRACTED_VALUE to ${out_var}
function(_qt_internal_sbom_handle_attribution_json_array contents)
set(opt_args "")
set(single_args
EXTRACTED_VALUE
OUT_VAR
)
set(multi_args
INDICES
)
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
# Write the original value to the parent scope, in case it was not an array.
set(${arg_OUT_VAR} "${arg_EXTRACTED_VALUE}" PARENT_SCOPE)
if(NOT arg_EXTRACTED_VALUE)
return()
endif()
string(JSON element_type TYPE "${contents}" ${arg_INDICES})
if(NOT element_type STREQUAL "ARRAY")
return()
endif()
set(json_array "${arg_EXTRACTED_VALUE}")
string(JSON array_len LENGTH "${json_array}")
set(value_list "")
math(EXPR array_len "${array_len} - 1")
foreach(index RANGE 0 "${array_len}")
string(JSON value GET "${json_array}" ${index})
if(value)
list(APPEND value_list "${value}")
endif()
endforeach()
if(value_list)
set(${arg_OUT_VAR} "${value_list}" PARENT_SCOPE)
endif()
endfunction()
# Escapes various characters in json content, so that the generate cmake code to append the content
# to the spdx document is syntactically valid.
function(_qt_internal_sbom_escape_json_content content out_var)
# Escape backslashes
string(REPLACE "\\" "\\\\" escaped_content "${content}")
# Escape quotes
string(REPLACE "\"" "\\\"" escaped_content "${escaped_content}")
set(${out_var} "${escaped_content}" PARENT_SCOPE)
endfunction()
# This macro reads a json key from a qt_attribution.json file, and assigns the escaped value to
# out_var.
# Also appends the name of the out_var to the parent scope 'variable_names' var.
#
# Expects 'contents' and 'indices' to already be set in the calling scope.
#
# If IS_MULTI_VALUE is set, handles the key as if it contained an array of
# values, by converting the array of json values to a cmake list.
macro(_qt_internal_sbom_get_attribution_key json_key out_var out_prefix)
cmake_parse_arguments(arg "IS_MULTI_VALUE" "" "" ${ARGN})
# Reset any leftover value that might have been set in a previous iteration.
set(${out_prefix}_${out_var} "" PARENT_SCOPE)
string(JSON "${out_var}" ERROR_VARIABLE get_error GET "${contents}" ${indices} "${json_key}")
if(NOT "${${out_var}}" STREQUAL "" AND NOT get_error)
set(extracted_value "${${out_var}}")
if(arg_IS_MULTI_VALUE)
_qt_internal_sbom_handle_attribution_json_array("${contents}"
EXTRACTED_VALUE "${extracted_value}"
INDICES ${indices} ${json_key}
OUT_VAR value_list
)
if(value_list)
set(extracted_value "${value_list}")
endif()
endif()
_qt_internal_sbom_escape_json_content("${extracted_value}" escaped_content)
set(${out_prefix}_${out_var} "${escaped_content}" PARENT_SCOPE)
list(APPEND variable_names "${out_var}")
unset(extracted_value)
unset(escaped_content)
unset(value_list)
endif()
endmacro()
# Replaces placeholders in CPE and PURL strings read from qt_attribution.json files.
#
# VALUES - list of CPE or PURL strings
# OUT_VAR - variable to store the replaced values
# VERSION - version to replace in the placeholders
# Known placeholders:
# $<VERSION> - Replaces occurrences of the placeholder with the value passed to the VERSION option.
# $<VERSION_DASHED> - Replaces occurrences of the placeholder with the value passed to the VERSION
# option, but with dots replaced by dashes.
function(_qt_internal_sbom_replace_qa_placeholders)
set(opt_args "")
set(single_args
OUT_VAR
VERSION
)
set(multi_args
VALUES
)
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_OUT_VAR)
message(FATAL_ERROR "OUT_VAR must be set")
endif()
set(result "")
if(arg_VERSION)
string(REPLACE "." "-" dashed_version "${arg_VERSION}")
endif()
foreach(value IN LISTS arg_VALUES)
if(arg_VERSION)
string(REPLACE "$<VERSION>" "${arg_VERSION}" value "${value}")
string(REPLACE "$<VERSION_DASHED>" "${dashed_version}" value "${value}")
endif()
list(APPEND result "${value}")
endforeach()
set(${arg_OUT_VAR} "${result}" PARENT_SCOPE)
endfunction()

View File

@ -0,0 +1,90 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Computes a security CPE for a given set of attributes.
#
# When a part is not specified, a wildcard is added.
#
# References:
# https://spdx.github.io/spdx-spec/v2.3/external-repository-identifiers/#f22-cpe23type
# https://nvlpubs.nist.gov/nistpubs/Legacy/IR/nistir7695.pdf
# https://nvd.nist.gov/products/cpe
#
# Each attribute means:
# 1. part
# 2. vendor
# 3. product
# 4. version
# 5. update
# 6. edition
# 7. language
# 8. sw_edition
# 9. target_sw
# 10. target_hw
# 11. other
function(_qt_internal_sbom_compute_security_cpe out_cpe)
set(opt_args "")
set(single_args
PART
VENDOR
PRODUCT
VERSION
UPDATE
EDITION
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
set(cpe_template "cpe:2.3:PART:VENDOR:PRODUCT:VERSION:UPDATE:EDITION:*:*:*:*:*")
set(cpe "${cpe_template}")
foreach(attribute_name IN LISTS single_args)
if(arg_${attribute_name})
set(${attribute_name}_value "${arg_${attribute_name}}")
else()
if(attribute_name STREQUAL "PART")
set(${attribute_name}_value "a")
else()
set(${attribute_name}_value "*")
endif()
endif()
string(REPLACE "${attribute_name}" "${${attribute_name}_value}" cpe "${cpe}")
endforeach()
set(${out_cpe} "${cpe}" PARENT_SCOPE)
endfunction()
# Computes the default security CPE for the Qt framework.
function(_qt_internal_sbom_get_cpe_qt out_var)
_qt_internal_sbom_get_root_project_name_lower_case(repo_project_name_lowercase)
_qt_internal_sbom_compute_security_cpe(repo_cpe
VENDOR "qt"
PRODUCT "${repo_project_name_lowercase}"
VERSION "${QT_REPO_MODULE_VERSION}"
)
set(${out_var} "${repo_cpe}" PARENT_SCOPE)
endfunction()
# Computes the default security CPE for a given qt repository.
function(_qt_internal_sbom_get_cpe_qt_repo out_var)
_qt_internal_sbom_compute_security_cpe(qt_cpe
VENDOR "qt"
PRODUCT "qt"
VERSION "${QT_REPO_MODULE_VERSION}"
)
set(${out_var} "${qt_cpe}" PARENT_SCOPE)
endfunction()
# Computes the list of security CPEs for Qt, including both the repo-specific one and generic one.
function(_qt_internal_sbom_compute_security_cpe_for_qt out_cpe_list)
set(cpe_list "")
_qt_internal_sbom_get_cpe_qt(repo_cpe)
list(APPEND cpe_list "${repo_cpe}")
_qt_internal_sbom_get_cpe_qt_repo(qt_cpe)
list(APPEND cpe_list "${qt_cpe}")
set(${out_cpe_list} "${cpe_list}" PARENT_SCOPE)
endfunction()

View File

@ -0,0 +1,265 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Walks a target's direct dependencies and assembles a list of relationships between the packages
# of the target dependencies.
# Currently handles various Qt targets and system libraries.
function(_qt_internal_sbom_handle_target_dependencies target)
set(opt_args "")
set(single_args
SPDX_ID
OUT_RELATIONSHIPS
)
set(multi_args
LIBRARIES
PUBLIC_LIBRARIES
)
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_SPDX_ID)
message(FATAL_ERROR "SPDX_ID must be set")
endif()
set(package_spdx_id "${arg_SPDX_ID}")
set(libraries "")
if(arg_LIBRARIES)
list(APPEND libraries "${arg_LIBRARIES}")
endif()
get_target_property(extend_libraries "${target}" _qt_extend_target_libraries)
if(extend_libraries)
list(APPEND libraries ${extend_libraries})
endif()
get_target_property(target_type ${target} TYPE)
set(valid_target_types
EXECUTABLE
SHARED_LIBRARY
MODULE_LIBRARY
STATIC_LIBRARY
OBJECT_LIBRARY
)
if(target_type IN_LIST valid_target_types)
get_target_property(link_libraries "${target}" LINK_LIBRARIES)
if(link_libraries)
list(APPEND libraries ${link_libraries})
endif()
endif()
set(public_libraries "")
if(arg_PUBLIC_LIBRARIES)
list(APPEND public_libraries "${arg_PUBLIC_LIBRARIES}")
endif()
get_target_property(extend_public_libraries "${target}" _qt_extend_target_public_libraries)
if(extend_public_libraries)
list(APPEND public_libraries ${extend_public_libraries})
endif()
set(sbom_dependencies "")
if(arg_SBOM_DEPENDENCIES)
list(APPEND sbom_dependencies "${arg_SBOM_DEPENDENCIES}")
endif()
get_target_property(extend_sbom_dependencies "${target}" _qt_extend_target_sbom_dependencies)
if(extend_sbom_dependencies)
list(APPEND sbom_dependencies ${extend_sbom_dependencies})
endif()
list(REMOVE_DUPLICATES libraries)
list(REMOVE_DUPLICATES public_libraries)
list(REMOVE_DUPLICATES sbom_dependencies)
set(all_direct_libraries ${libraries} ${public_libraries} ${sbom_dependencies})
list(REMOVE_DUPLICATES all_direct_libraries)
set(spdx_dependencies "")
set(external_spdx_dependencies "")
# Go through each direct linked lib.
foreach(direct_lib IN LISTS all_direct_libraries)
if(NOT TARGET "${direct_lib}")
continue()
endif()
# Check for Qt-specific system library targets. These are marked via qt_find_package calls.
get_target_property(is_system_library "${direct_lib}" _qt_internal_sbom_is_system_library)
if(is_system_library)
# We need to check if the dependency is a FindWrap dependency that points either to a
# system library or a vendored / bundled library. We need to depend on whichever one
# the FindWrap script points to.
__qt_internal_walk_libs(
"${direct_lib}"
lib_walked_targets
_discarded_out_var
"sbom_targets"
"collect_targets")
# Detect if we are dealing with a vendored / bundled lib.
set(bundled_targets_found FALSE)
if(lib_walked_targets)
foreach(lib_walked_target IN LISTS lib_walked_targets)
get_target_property(is_3rdparty_bundled_lib
"${lib_walked_target}" _qt_module_is_3rdparty_library)
_qt_internal_sbom_get_spdx_id_for_target("${lib_walked_target}" lib_spdx_id)
# Add a dependency on the vendored lib instead of the Wrap target.
if(is_3rdparty_bundled_lib AND lib_spdx_id)
list(APPEND spdx_dependencies "${lib_spdx_id}")
set(bundled_targets_found TRUE)
endif()
endforeach()
if(bundled_targets_found)
# If we handled a bundled target, we can move on to process the next direct_lib.
continue()
endif()
endif()
if(NOT bundled_targets_found)
# If we haven't found a bundled target, then it's a regular system library
# dependency. Make sure to mark the system library as consumed, so that we later
# generate an sbom for it.
# Also fall through to the code that actually adds the dependency on the target.
_qt_internal_append_to_cmake_property_without_duplicates(
_qt_internal_sbom_consumed_system_library_targets
"${direct_lib}"
)
endif()
endif()
# Get the spdx id of the dependency.
_qt_internal_sbom_get_spdx_id_for_target("${direct_lib}" lib_spdx_id)
if(NOT lib_spdx_id)
message(DEBUG "Could not add target dependency on target ${direct_lib} "
"because no spdx id for it could be found.")
continue()
endif()
# Check if the target sbom is defined in an external document.
_qt_internal_sbom_is_external_target_dependency("${direct_lib}"
OUT_VAR is_dependency_in_external_document
)
if(NOT is_dependency_in_external_document)
# If the target is not in the external document, it must be one built as part of the
# current project.
list(APPEND spdx_dependencies "${lib_spdx_id}")
else()
# Refer to the package in the external document. This can be the case
# in a top-level build, where a system library is reused across repos, or for any
# regular dependency that was built as part of a different project.
_qt_internal_sbom_add_external_target_dependency("${direct_lib}"
extra_spdx_dependencies
)
if(extra_spdx_dependencies)
list(APPEND external_spdx_dependencies ${extra_spdx_dependencies})
endif()
endif()
endforeach()
set(relationships "")
# Keep the external dependencies first, so they are neatly ordered.
foreach(dep_spdx_id IN LISTS external_spdx_dependencies spdx_dependencies)
set(relationship
"${package_spdx_id} DEPENDS_ON ${dep_spdx_id}"
)
list(APPEND relationships "${relationship}")
endforeach()
set(${arg_OUT_RELATIONSHIPS} "${relationships}" PARENT_SCOPE)
endfunction()
# Checks whether the current target will have its sbom generated into the current repo sbom
# document, or whether it is present in an external sbom document.
function(_qt_internal_sbom_is_external_target_dependency target)
set(opt_args
SYSTEM_LIBRARY
)
set(single_args
OUT_VAR
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
get_target_property(is_imported "${target}" IMPORTED)
get_target_property(is_custom_sbom_target "${target}" _qt_sbom_is_custom_sbom_target)
_qt_internal_sbom_get_root_project_name_lower_case(current_repo_project_name)
get_property(target_repo_project_name TARGET ${target}
PROPERTY _qt_sbom_spdx_repo_project_name_lowercase)
if(NOT "${target_repo_project_name}" STREQUAL ""
AND NOT "${target_repo_project_name}" STREQUAL "${current_repo_project_name}")
set(part_of_other_repo TRUE)
else()
set(part_of_other_repo FALSE)
endif()
set(${arg_OUT_VAR} "${part_of_other_repo}" PARENT_SCOPE)
endfunction()
# Handles generating an external document reference SDPX element for each target package that is
# located in a different spdx document.
function(_qt_internal_sbom_add_external_target_dependency target out_spdx_dependencies)
_qt_internal_sbom_get_spdx_id_for_target("${target}" dep_spdx_id)
if(NOT dep_spdx_id)
message(DEBUG "Could not add external target dependency on ${target} "
"because no spdx id could be found")
set(${out_spdx_dependencies} "" PARENT_SCOPE)
return()
endif()
set(spdx_dependencies "")
# Get the external document path and the repo it belongs to for the given target.
get_property(relative_installed_repo_document_path TARGET ${target}
PROPERTY _qt_sbom_spdx_relative_installed_repo_document_path)
get_property(project_name_lowercase TARGET ${target}
PROPERTY _qt_sbom_spdx_repo_project_name_lowercase)
if(relative_installed_repo_document_path AND project_name_lowercase)
_qt_internal_sbom_get_external_document_ref_spdx_id(
"${project_name_lowercase}" external_document_ref)
get_cmake_property(known_external_document
_qt_known_external_documents_${external_document_ref})
set(dependency "${external_document_ref}:${dep_spdx_id}")
list(APPEND spdx_dependencies "${dependency}")
# Only add a reference to the external document package, if we haven't done so already.
if(NOT known_external_document)
set(install_prefixes "")
get_cmake_property(install_prefix _qt_internal_sbom_install_prefix)
list(APPEND install_prefixes "${install_prefix}")
set(external_document "${relative_installed_repo_document_path}")
_qt_internal_sbom_generate_add_external_reference(
EXTERNAL_DOCUMENT_FILE_PATH "${external_document}"
EXTERNAL_DOCUMENT_INSTALL_PREFIXES ${install_prefixes}
EXTERNAL_DOCUMENT_SPDX_ID "${external_document_ref}"
)
set_property(GLOBAL PROPERTY
_qt_known_external_documents_${external_document_ref} TRUE)
set_property(GLOBAL APPEND PROPERTY
_qt_known_external_documents "${external_document_ref}")
endif()
else()
message(AUTHOR_WARNING
"Missing spdx document path for external target dependency: ${target}")
endif()
set(${out_spdx_dependencies} "${spdx_dependencies}" PARENT_SCOPE)
endfunction()

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,108 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Adds a license id and its text to the sbom.
function(_qt_internal_sbom_add_license)
if(NOT QT_GENERATE_SBOM)
return()
endif()
set(opt_args
NO_LICENSE_REF_PREFIX
)
set(single_args
LICENSE_ID
LICENSE_PATH
EXTRACTED_TEXT
)
set(multi_args
)
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_LICENSE_ID)
message(FATAL_ERROR "LICENSE_ID must be set")
endif()
if(NOT arg_TEXT AND NOT arg_LICENSE_PATH)
message(FATAL_ERROR "Either TEXT or LICENSE_PATH must be set")
endif()
# Sanitize the content a bit.
if(arg_TEXT)
set(text "${arg_TEXT}")
string(REPLACE ";" "$<SEMICOLON>" text "${text}")
string(REPLACE "\"" "\\\"" text "${text}")
else()
file(READ "${arg_LICENSE_PATH}" text)
string(REPLACE ";" "$<SEMICOLON>" text "${text}")
string(REPLACE "\"" "\\\"" text "${text}")
endif()
set(license_id "${arg_LICENSE_ID}")
if(NOT arg_NO_LICENSE_REF_PREFIX)
set(license_id "LicenseRef-${license_id}")
endif()
_qt_internal_sbom_generate_add_license(
LICENSE_ID "${license_id}"
EXTRACTED_TEXT "<text>${text}</text>"
)
endfunction()
# Get a qt spdx license expression given the id.
function(_qt_internal_sbom_get_spdx_license_expression id out_var)
set(license "")
# The default for modules / plugins
if(id STREQUAL "QT_DEFAULT" OR id STREQUAL "QT_COMMERCIAL_OR_LGPL3")
set(license "LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only")
# For commercial only entities
elseif(id STREQUAL "QT_COMMERCIAL")
set(license "LicenseRef-Qt-Commercial")
# For GPL3 only modules
elseif(id STREQUAL "QT_COMMERCIAL_OR_GPL3")
set(license "LicenseRef-Qt-Commercial OR GPL-3.0-only")
# For tools and apps
elseif(id STREQUAL "QT_COMMERCIAL_OR_GPL3_WITH_EXCEPTION")
set(license "LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0")
# For things like the qtmain library
elseif(id STREQUAL "QT_COMMERCIAL_OR_BSD3")
set(license "LicenseRef-Qt-Commercial OR BSD-3-Clause")
# For documentation
elseif(id STREQUAL "QT_COMMERCIAL_OR_GFDL1_3")
set(license "LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only")
# For examples and the like
elseif(id STREQUAL "BSD3")
set(license "BSD-3-Clause")
endif()
if(NOT license)
message(FATAL_ERROR "No SPDX license expression found for id: ${id}")
endif()
set(${out_var} "${license}" PARENT_SCOPE)
endfunction()
# Joins two license IDs with the given ${op}, avoiding parenthesis when possible.
function(_qt_internal_sbom_join_two_license_ids_with_op left_id op right_id out_var)
if(NOT left_id)
set(${out_var} "${right_id}" PARENT_SCOPE)
return()
endif()
if(NOT right_id)
set(${out_var} "${left_id}" PARENT_SCOPE)
return()
endif()
set(value "(${left_id}) ${op} (${right_id})")
set(${out_var} "${value}" PARENT_SCOPE)
endfunction()

View File

@ -0,0 +1,861 @@
# Copyright (C) 2024 The Qt Company Ltd.
# Copyright (C) 2023-2024 Jochem Rutgers
# SPDX-License-Identifier: MIT AND BSD-3-Clause
# Handles the look up of Python, Python spdx dependencies and other various post-installation steps
# like NTIA validation, auditing, json generation, etc.
function(_qt_internal_sbom_setup_project_ops_generation)
set(opt_args
GENERATE_JSON
GENERATE_JSON_REQUIRED
GENERATE_SOURCE_SBOM
VERIFY_SBOM
VERIFY_SBOM_REQUIRED
VERIFY_NTIA_COMPLIANT
LINT_SOURCE_SBOM
LINT_SOURCE_SBOM_NO_ERROR
SHOW_TABLE
AUDIT
AUDIT_NO_ERROR
)
set(single_args "")
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(arg_GENERATE_JSON AND NOT QT_INTERNAL_NO_SBOM_PYTHON_OPS)
set(op_args
OP_KEY "GENERATE_JSON"
OUT_VAR_DEPS_FOUND deps_found
)
if(arg_GENERATE_JSON_REQUIRED)
list(APPEND op_args REQUIRED)
endif()
_qt_internal_sbom_find_and_handle_sbom_op_dependencies(${op_args})
if(deps_found)
_qt_internal_sbom_generate_json()
endif()
endif()
if(arg_VERIFY_SBOM AND NOT QT_INTERNAL_NO_SBOM_PYTHON_OPS)
set(op_args
OP_KEY "VERIFY_SBOM"
OUT_VAR_DEPS_FOUND deps_found
)
if(arg_VERIFY_SBOM_REQUIRED)
list(APPEND op_args REQUIRED)
endif()
_qt_internal_sbom_find_and_handle_sbom_op_dependencies(${op_args})
if(deps_found)
_qt_internal_sbom_verify_valid()
endif()
endif()
if(arg_VERIFY_NTIA_COMPLIANT AND NOT QT_INTERNAL_NO_SBOM_PYTHON_OPS)
_qt_internal_sbom_find_and_handle_sbom_op_dependencies(REQUIRED OP_KEY "RUN_NTIA")
_qt_internal_sbom_verify_ntia_compliant()
endif()
if(arg_SHOW_TABLE AND NOT QT_INTERNAL_NO_SBOM_PYTHON_OPS)
_qt_internal_sbom_find_python_dependency_program(NAME sbom2doc REQUIRED)
_qt_internal_sbom_show_table()
endif()
if(arg_AUDIT AND NOT QT_INTERNAL_NO_SBOM_PYTHON_OPS)
set(audit_no_error_option "")
if(arg_AUDIT_NO_ERROR)
set(audit_no_error_option NO_ERROR)
endif()
_qt_internal_sbom_find_python_dependency_program(NAME sbomaudit REQUIRED)
_qt_internal_sbom_audit(${audit_no_error_option})
endif()
if(arg_GENERATE_SOURCE_SBOM AND NOT QT_INTERNAL_NO_SBOM_PYTHON_OPS)
_qt_internal_sbom_find_python_dependency_program(NAME reuse REQUIRED)
_qt_internal_sbom_generate_reuse_source_sbom()
endif()
if(arg_LINT_SOURCE_SBOM AND NOT QT_INTERNAL_NO_SBOM_PYTHON_OPS)
set(lint_no_error_option "")
if(arg_LINT_SOURCE_SBOM_NO_ERROR)
set(lint_no_error_option NO_ERROR)
endif()
_qt_internal_sbom_find_python_dependency_program(NAME reuse REQUIRED)
_qt_internal_sbom_run_reuse_lint(
${lint_no_error_option}
BUILD_TIME_SCRIPT_PATH_OUT_VAR reuse_lint_script
)
endif()
endfunction()
# Helper to find a python interpreter and a specific python dependency, e.g. to be able to generate
# a SPDX JSON SBOM, or run post-installation steps like NTIA verification.
# The exact dependency should be specified as the OP_KEY.
#
# Caches the found python executable in a separate cache var QT_INTERNAL_SBOM_PYTHON_EXECUTABLE, to
# avoid conflicts with any other found python interpreter.
function(_qt_internal_sbom_find_and_handle_sbom_op_dependencies)
set(opt_args
REQUIRED
)
set(single_args
OP_KEY
OUT_VAR_DEPS_FOUND
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_OP_KEY)
message(FATAL_ERROR "OP_KEY is required")
endif()
set(supported_ops "GENERATE_JSON" "VERIFY_SBOM" "RUN_NTIA")
if(arg_OP_KEY STREQUAL "GENERATE_JSON" OR arg_OP_KEY STREQUAL "VERIFY_SBOM")
set(import_statement "import spdx_tools.spdx.clitools.pyspdxtools")
elseif(arg_OP_KEY STREQUAL "RUN_NTIA")
set(import_statement "import ntia_conformance_checker.main")
else()
message(FATAL_ERROR "OP_KEY must be one of ${supported_ops}")
endif()
# Return early if we found the dependencies.
if(QT_INTERNAL_SBOM_DEPS_FOUND_FOR_${arg_OP_KEY})
if(arg_OUT_VAR_DEPS_FOUND)
set(${arg_OUT_VAR_DEPS_FOUND} TRUE PARENT_SCOPE)
endif()
return()
endif()
# NTIA-compliance checker requires Python 3.9 or later, so we use it as the minimum for all
# SBOM OPs.
set(required_version "3.9")
set(python_common_args
VERSION "${required_version}"
)
set(everything_found FALSE)
# On macOS FindPython prefers looking in the system framework location, but that usually would
# not have the required dependencies. So we first look in it, and then fallback to any other
# non-framework python found.
if(CMAKE_HOST_APPLE)
set(extra_python_args SEARCH_IN_FRAMEWORKS QUIET)
_qt_internal_sbom_find_python_and_dependency_helper_lambda()
endif()
if(NOT everything_found)
set(extra_python_args QUIET)
_qt_internal_sbom_find_python_and_dependency_helper_lambda()
endif()
# Always save the python interpreter path if it is found, even if the dependencies are not
# found. This improves the error message workflow.
if(python_found AND NOT QT_INTERNAL_SBOM_PYTHON_EXECUTABLE)
set(QT_INTERNAL_SBOM_PYTHON_EXECUTABLE "${python_path}" CACHE INTERNAL
"Python interpeter used for SBOM generation.")
endif()
if(NOT everything_found)
if(arg_REQUIRED)
set(message_type "FATAL_ERROR")
else()
set(message_type "DEBUG")
endif()
if(NOT python_found)
# Look for python one more time, this time without QUIET, to show an error why it
# wasn't found.
if(arg_REQUIRED)
_qt_internal_sbom_find_python_helper(${python_common_args}
OUT_VAR_PYTHON_PATH unused_python
OUT_VAR_PYTHON_FOUND unused_found
)
endif()
message(${message_type} "Python ${required_version} for running SBOM ops not found.")
elseif(NOT dep_found)
message(${message_type} "Python dependency for running SBOM op ${arg_OP_KEY} "
"not found:\n Python: ${python_path} \n Output: \n${dep_find_output}")
endif()
else()
message(DEBUG "Using Python ${python_path} for running SBOM ops.")
set(QT_INTERNAL_SBOM_DEPS_FOUND_FOR_${arg_OP_KEY} "TRUE" CACHE INTERNAL
"All dependencies found to run SBOM OP ${arg_OP_KEY}")
endif()
if(arg_OUT_VAR_DEPS_FOUND)
set(${arg_OUT_VAR_DEPS_FOUND} "${QT_INTERNAL_SBOM_DEPS_FOUND_FOR_${arg_OP_KEY}}"
PARENT_SCOPE)
endif()
endfunction()
# Helper that checks a variable for truthiness, and sets the OUT_VAR_DEPS_FOUND and
# OUT_VAR_REASON_FAILURE_MESSAGE variables based on what was passed in.
function(_qt_internal_sbom_handle_sbom_op_missing_dependency)
set(opt_args "")
set(single_args
VAR_TO_CHECK
OUT_VAR_DEPS_FOUND
OUT_VAR_REASON_FAILURE_MESSAGE
)
set(multi_args
FAILURE_MESSAGE
)
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_VAR_TO_CHECK)
message(FATAL_ERROR "VAR_TO_CHECK is required")
endif()
set(reason "")
set(value "${${arg_VAR_TO_CHECK}}")
if(NOT value)
if(arg_FAILURE_MESSAGE)
list(JOIN arg_FAILURE_MESSAGE " " reason)
endif()
set(deps_found FALSE)
else()
set(deps_found TRUE)
endif()
if(arg_OUT_VAR_DEPS_FOUND)
set(${arg_OUT_VAR_DEPS_FOUND} "${deps_found}" PARENT_SCOPE)
endif()
if(arg_OUT_VAR_REASON_FAILURE_MESSAGE)
set(${arg_OUT_VAR_REASON_FAILURE_MESSAGE} "${reason}" PARENT_SCOPE)
endif()
endfunction()
# Helper to query whether the sbom python interpreter is available, and also the error message if it
# is not available.
function(_qt_internal_sbom_check_python_interpreter_available)
set(opt_args "")
set(single_args
OUT_VAR_DEPS_FOUND
OUT_VAR_REASON_FAILURE_MESSAGE
)
set(multi_args
FAILURE_MESSAGE_PREFIX
)
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
set(failure_message
"QT_INTERNAL_SBOM_PYTHON_EXECUTABLE is missing a valid path to a python interpreter")
if(arg_FAILURE_MESSAGE_PREFIX)
list(PREPEND failure_message ${arg_FAILURE_MESSAGE_PREFIX})
endif()
_qt_internal_sbom_handle_sbom_op_missing_dependency(
VAR_TO_CHECK QT_INTERNAL_SBOM_PYTHON_EXECUTABLE
FAILURE_MESSAGE ${failure_message}
OUT_VAR_DEPS_FOUND deps_found
OUT_VAR_REASON_FAILURE_MESSAGE reason
)
if(arg_OUT_VAR_DEPS_FOUND)
set(${arg_OUT_VAR_DEPS_FOUND} "${deps_found}" PARENT_SCOPE)
endif()
if(arg_OUT_VAR_REASON_FAILURE_MESSAGE)
set(${arg_OUT_VAR_REASON_FAILURE_MESSAGE} "${reason}" PARENT_SCOPE)
endif()
endfunction()
# Helper to assert that the python interpreter is available.
function(_qt_internal_sbom_assert_python_interpreter_available error_message_prefix)
_qt_internal_sbom_check_python_interpreter_available(
FAILURE_MESSAGE_PREFIX ${error_message_prefix}
OUT_VAR_DEPS_FOUND deps_found
OUT_VAR_REASON_FAILURE_MESSAGE reason
)
if(NOT deps_found)
message(FATAL_ERROR ${reason})
endif()
endfunction()
# Helper to query whether an sbom python dependency is available, and also the error message if it
# is not available.
function(_qt_internal_sbom_check_python_dependency_available)
set(opt_args "")
set(single_args
OUT_VAR_DEPS_FOUND
OUT_VAR_REASON_FAILURE_MESSAGE
VAR_TO_CHECK
)
set(multi_args
FAILURE_MESSAGE_PREFIX
FAILURE_MESSAGE_SUFFIX
)
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
set(failure_message
"Required Python dependencies not found: ")
if(arg_FAILURE_MESSAGE_PREFIX)
list(PREPEND failure_message ${arg_FAILURE_MESSAGE_PREFIX})
endif()
if(arg_FAILURE_MESSAGE_SUFFIX)
list(APPEND failure_message ${arg_FAILURE_MESSAGE_SUFFIX})
endif()
_qt_internal_sbom_handle_sbom_op_missing_dependency(
VAR_TO_CHECK ${arg_VAR_TO_CHECK}
FAILURE_MESSAGE ${failure_message}
OUT_VAR_DEPS_FOUND deps_found
OUT_VAR_REASON_FAILURE_MESSAGE reason
)
if(arg_OUT_VAR_DEPS_FOUND)
set(${arg_OUT_VAR_DEPS_FOUND} "${deps_found}" PARENT_SCOPE)
endif()
if(arg_OUT_VAR_REASON_FAILURE_MESSAGE)
set(${arg_OUT_VAR_REASON_FAILURE_MESSAGE} "${reason}" PARENT_SCOPE)
endif()
endfunction()
# Helper to assert that an sbom python dependency is available.
function(_qt_internal_sbom_assert_python_dependency_available key dep error_message_prefix)
_qt_internal_sbom_check_python_dependency_available(
VAR_TO_CHECK QT_INTERNAL_SBOM_DEPS_FOUND_FOR_${key}
FAILURE_MESSAGE_PREFIX ${error_message_prefix}
FAILURE_MESSAGE_SUFFIX ${dep}
OUT_VAR_DEPS_FOUND deps_found
OUT_VAR_REASON_FAILURE_MESSAGE reason
)
if(NOT deps_found)
message(FATAL_ERROR ${reason})
endif()
endfunction()
# Helper to query whether the json sbom generation dependency is available, and also the error
# message if it is not available.
function(_qt_internal_sbom_check_generate_json_dependency_available)
set(opt_args "")
set(single_args
OUT_VAR_DEPS_FOUND
OUT_VAR_REASON_FAILURE_MESSAGE
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
_qt_internal_sbom_check_python_dependency_available(
VAR_TO_CHECK QT_INTERNAL_SBOM_DEPS_FOUND_FOR_GENERATE_JSON
FAILURE_MESSAGE_SUFFIX "spdx_tools.spdx.clitools.pyspdxtools"
OUT_VAR_DEPS_FOUND deps_found
OUT_VAR_REASON_FAILURE_MESSAGE reason
)
if(arg_OUT_VAR_DEPS_FOUND)
set(${arg_OUT_VAR_DEPS_FOUND} "${deps_found}" PARENT_SCOPE)
endif()
if(arg_OUT_VAR_REASON_FAILURE_MESSAGE)
set(${arg_OUT_VAR_REASON_FAILURE_MESSAGE} "${reason}" PARENT_SCOPE)
endif()
endfunction()
# Helper to generate a SPDX JSON file from a tag/value format file.
# This also implies some additional validity checks, useful to ensure a proper sbom file.
function(_qt_internal_sbom_generate_json)
set(error_message_prefix "Failed to generate an SBOM json file.")
_qt_internal_sbom_assert_python_interpreter_available("${error_message_prefix}")
_qt_internal_sbom_assert_python_dependency_available(GENERATE_JSON
"spdx_tools.spdx.clitools.pyspdxtools" ${error_message_prefix})
set(content "
message(STATUS \"Generating JSON: \${QT_SBOM_OUTPUT_PATH}.json\")
execute_process(
COMMAND ${QT_INTERNAL_SBOM_PYTHON_EXECUTABLE} -m spdx_tools.spdx.clitools.pyspdxtools
-i \"\${QT_SBOM_OUTPUT_PATH}\" -o \"\${QT_SBOM_OUTPUT_PATH}.json\"
RESULT_VARIABLE res
)
if(NOT res EQUAL 0)
message(FATAL_ERROR \"SBOM conversion to JSON failed: \${res}\")
endif()
")
_qt_internal_get_current_project_sbom_dir(sbom_dir)
set(verify_sbom "${sbom_dir}/convert_to_json.cmake")
file(GENERATE OUTPUT "${verify_sbom}" CONTENT "${content}")
set_property(GLOBAL APPEND PROPERTY _qt_sbom_cmake_verify_include_files "${verify_sbom}")
endfunction()
# Helper to query whether the all required dependencies are available to generate a tag / value
# document from a json one.
function(_qt_internal_sbom_verify_deps_for_generate_tag_value_spdx_document)
set(opt_args "")
set(single_args
OUT_VAR_DEPS_FOUND
OUT_VAR_REASON_FAILURE_MESSAGE
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
# First try to find dependencies, because they might not have been found yet.
_qt_internal_sbom_find_and_handle_sbom_op_dependencies(
OP_KEY "GENERATE_JSON"
)
_qt_internal_sbom_check_python_interpreter_available(
OUT_VAR_DEPS_FOUND python_found
OUT_VAR_REASON_FAILURE_MESSAGE python_error
)
_qt_internal_sbom_check_generate_json_dependency_available(
OUT_VAR_DEPS_FOUND dep_found
OUT_VAR_REASON_FAILURE_MESSAGE dep_error
)
set(reasons "")
if(python_error)
string(APPEND reasons "${python_error}\n")
endif()
if(dep_error)
string(APPEND reasons "${dep_error}\n")
endif()
if(python_found AND dep_found)
set(deps_found "TRUE")
else()
set(deps_found "FALSE")
endif()
set(${arg_OUT_VAR_DEPS_FOUND} "${deps_found}" PARENT_SCOPE)
set(${arg_OUT_VAR_REASON_FAILURE_MESSAGE} "${reasons}" PARENT_SCOPE)
endfunction()
# Helper to generate a tag/value SPDX file from a SPDX JSON format file.
#
# Will be used by WebEngine to convert the Chromium JSON file to a tag/value SPDX file.
#
# This conversion needs to happen before the document is referenced in the SBOM generation process,
# so that the file already exists when it is parsed for its unique id and namespace.
# It also needs to happen before verification codes are computed for the current document
# that will depend on the target one, to ensure the the file exists and its checksum can be
# computed.
#
# OPERATION_ID - a unique id for the operation, used to generate a unique cmake file name for
# the SBOM generation process.
#
# INPUT_JSON_PATH - the absolute path to the input JSON file.
#
# OUTPUT_FILE_PATH - the absolute path where to create the output tag/value SPDX file.
# Note that if the output file path is set, it is up to the caller to also copy / install the file
# into the build and install directories where the build system expects to find all external
# document references.
#
# OUTPUT_FILE_NAME - when OUTPUT_FILE_PATH is not specified, the output directory is automatically
# set to the SBOM output directory. In this case OUTPUT_FILE_NAME can be used to override the
# outout file name. If not specified, it will be derived from the input file name.
#
# OUT_VAR_OUTPUT_FILE_NAME - output variable where to store the output file.
#
# OUT_VAR_OUTPUT_ABSOLUTE_FILE_PATH - output variable where to store the output file path.
# Note that the path will contain an unresolved '${QT_SBOM_OUTPUT_DIR}' which only has a value at
# install time. So the path can't be used sensibly during configure time.
#
# OPTIONAL - whether the operation should return early, if the required python dependencies are
# not found. OUT_VAR_DEPS_FOUND is still set in that case.
#
# OUT_VAR_DEPS_FOUND - output variable where to store whether the python dependencies for the
# operation were found, and thus the conversion will be attempted.
function(_qt_internal_sbom_generate_tag_value_spdx_document)
if(NOT QT_GENERATE_SBOM)
return()
endif()
set(opt_args
OPTIONAL
)
set(single_args
OPERATION_ID
INPUT_JSON_FILE_PATH
OUTPUT_FILE_PATH
OUTPUT_FILE_NAME
OUT_VAR_OUTPUT_FILE_NAME
OUT_VAR_OUTPUT_ABSOLUTE_FILE_PATH
OUT_VAR_DEPS_FOUND
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
# First try to find dependencies, because they might not have been found yet.
_qt_internal_sbom_find_and_handle_sbom_op_dependencies(
OP_KEY "GENERATE_JSON"
OUT_VAR_DEPS_FOUND deps_found
)
if(arg_OPTIONAL)
set(deps_are_required FALSE)
else()
set(deps_are_required TRUE)
endif()
# If the operation has to succeed, then the deps are required. Assert they are available.
if(deps_are_required)
set(error_message_prefix "Failed to generate a tag/value SBOM file from a json SBOM file.")
_qt_internal_sbom_assert_python_interpreter_available("${error_message_prefix}")
_qt_internal_sbom_assert_python_dependency_available(GENERATE_JSON
"spdx_tools.spdx.clitools.pyspdxtools" ${error_message_prefix})
# If the operation is optional, don't error out if the deps are not found, but silently return
# and mention that the deps are not found.
elseif(NOT deps_found)
set(${arg_OUT_VAR_DEPS_FOUND} "${deps_found}" PARENT_SCOPE)
return()
endif()
set(${arg_OUT_VAR_DEPS_FOUND} "${deps_found}" PARENT_SCOPE)
if(NOT arg_OPERATION_ID)
message(FATAL_ERROR "OPERATION_ID is required")
endif()
if(NOT arg_INPUT_JSON_FILE_PATH)
message(FATAL_ERROR "INPUT_JSON_FILE_PATH is required")
endif()
if(arg_OUTPUT_FILE_PATH)
set(output_path "${arg_OUTPUT_FILE_PATH}")
else()
if(arg_OUTPUT_FILE_NAME)
set(output_name "${arg_OUTPUT_FILE_NAME}")
else()
# Use the input file name without the last extension (without .json) as the output name.
get_filename_component(output_name "${arg_INPUT_JSON_FILE_PATH}" NAME_WLE)
endif()
set(output_path "\${QT_SBOM_OUTPUT_DIR}/${output_name}")
endif()
if(arg_OUT_VAR_OUTPUT_FILE_NAME)
get_filename_component(output_name_resolved "${output_path}" NAME)
set(${arg_OUT_VAR_OUTPUT_FILE_NAME} "${output_name_resolved}" PARENT_SCOPE)
endif()
if(arg_OUT_VAR_OUTPUT_ABSOLUTE_FILE_PATH)
set(${arg_OUT_VAR_OUTPUT_ABSOLUTE_FILE_PATH} "${output_path}" PARENT_SCOPE)
endif()
set(content "
message(STATUS
\"Generating tag/value SPDX document: ${output_path} from \"
\"${arg_INPUT_JSON_FILE_PATH}\")
execute_process(
COMMAND ${QT_INTERNAL_SBOM_PYTHON_EXECUTABLE} -m spdx_tools.spdx.clitools.pyspdxtools
-i \"${arg_INPUT_JSON_FILE_PATH}\" -o \"${output_path}\"
RESULT_VARIABLE res
)
if(NOT res EQUAL 0)
message(FATAL_ERROR \"SBOM conversion to tag/value failed: \${res}\")
endif()
")
_qt_internal_get_current_project_sbom_dir(sbom_dir)
set(convert_sbom "${sbom_dir}/convert_to_tag_value_${arg_OPERATION_ID}.cmake")
file(GENERATE OUTPUT "${convert_sbom}" CONTENT "${content}")
set_property(GLOBAL APPEND PROPERTY _qt_sbom_cmake_include_files
"${convert_sbom}")
endfunction()
# Helper to verify the generated sbom is valid.
function(_qt_internal_sbom_verify_valid)
set(error_message_prefix "Failed to verify SBOM file syntax.")
_qt_internal_sbom_assert_python_interpreter_available("${error_message_prefix}")
_qt_internal_sbom_assert_python_dependency_available(VERIFY_SBOM
"spdx_tools.spdx.clitools.pyspdxtools" ${error_message_prefix})
set(content "
message(STATUS \"Verifying: \${QT_SBOM_OUTPUT_PATH}\")
execute_process(
COMMAND ${QT_INTERNAL_SBOM_PYTHON_EXECUTABLE} -m spdx_tools.spdx.clitools.pyspdxtools
-i \"\${QT_SBOM_OUTPUT_PATH}\"
RESULT_VARIABLE res
)
if(NOT res EQUAL 0)
message(FATAL_ERROR \"SBOM verification failed: \${res}\")
endif()
")
_qt_internal_get_current_project_sbom_dir(sbom_dir)
set(verify_sbom "${sbom_dir}/verify_valid.cmake")
file(GENERATE OUTPUT "${verify_sbom}" CONTENT "${content}")
set_property(GLOBAL APPEND PROPERTY _qt_sbom_cmake_verify_include_files "${verify_sbom}")
endfunction()
# Helper to verify the generated sbom is NTIA compliant.
function(_qt_internal_sbom_verify_ntia_compliant)
set(error_message_prefix "Failed to run NTIA checker on SBOM file.")
_qt_internal_sbom_assert_python_interpreter_available("${error_message_prefix}")
_qt_internal_sbom_assert_python_dependency_available(RUN_NTIA
"ntia_conformance_checker.main" ${error_message_prefix})
set(content "
message(STATUS \"Checking for NTIA compliance: \${QT_SBOM_OUTPUT_PATH}\")
execute_process(
COMMAND ${QT_INTERNAL_SBOM_PYTHON_EXECUTABLE} -m ntia_conformance_checker.main
--file \"\${QT_SBOM_OUTPUT_PATH}\"
RESULT_VARIABLE res
)
if(NOT res EQUAL 0)
message(FATAL_ERROR \"SBOM NTIA verification failed: \${res}\")
endif()
")
_qt_internal_get_current_project_sbom_dir(sbom_dir)
set(verify_sbom "${sbom_dir}/verify_ntia.cmake")
file(GENERATE OUTPUT "${verify_sbom}" CONTENT "${content}")
set_property(GLOBAL APPEND PROPERTY _qt_sbom_cmake_verify_include_files "${verify_sbom}")
endfunction()
# Helper to show the main sbom document info in the form of a CLI table.
function(_qt_internal_sbom_show_table)
set(extra_code_begin "")
if(DEFINED ENV{COIN_UNIQUE_JOB_ID})
# The output of the process dynamically adjusts the width of the shown table based on the
# console width. In the CI, the width is very short for some reason, and thus the output
# is truncated in the CI log. Explicitly set a bigger width to avoid this.
set(extra_code_begin "
set(backup_env_columns \$ENV{COLUMNS})
set(ENV{COLUMNS} 150)
")
set(extra_code_end "
set(ENV{COLUMNS} \${backup_env_columns})
")
endif()
set(content "
message(STATUS \"Showing main SBOM document info: \${QT_SBOM_OUTPUT_PATH}\")
${extra_code_begin}
execute_process(
COMMAND ${QT_SBOM_PROGRAM_SBOM2DOC} -i \"\${QT_SBOM_OUTPUT_PATH}\"
RESULT_VARIABLE res
)
${extra_code_end}
if(NOT res EQUAL 0)
message(FATAL_ERROR \"Showing SBOM document failed: \${res}\")
endif()
")
_qt_internal_get_current_project_sbom_dir(sbom_dir)
set(verify_sbom "${sbom_dir}/show_table.cmake")
file(GENERATE OUTPUT "${verify_sbom}" CONTENT "${content}")
set_property(GLOBAL APPEND PROPERTY _qt_sbom_cmake_verify_include_files "${verify_sbom}")
endfunction()
# Helper to audit the generated sbom.
function(_qt_internal_sbom_audit)
set(opt_args NO_ERROR)
set(single_args "")
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
set(handle_error "")
if(NOT arg_NO_ERROR)
set(handle_error "
if(NOT res EQUAL 0)
message(FATAL_ERROR \"SBOM Audit failed: \${res}\")
endif()
")
endif()
set(content "
message(STATUS \"Auditing SBOM: \${QT_SBOM_OUTPUT_PATH}\")
execute_process(
COMMAND ${QT_SBOM_PROGRAM_SBOMAUDIT} -i \"\${QT_SBOM_OUTPUT_PATH}\"
--disable-license-check --cpecheck --offline
RESULT_VARIABLE res
)
${handle_error}
")
_qt_internal_get_current_project_sbom_dir(sbom_dir)
set(verify_sbom "${sbom_dir}/audit.cmake")
file(GENERATE OUTPUT "${verify_sbom}" CONTENT "${content}")
set_property(GLOBAL APPEND PROPERTY _qt_sbom_cmake_verify_include_files "${verify_sbom}")
endfunction()
# Returns path to project's potential root source reuse.toml file.
function(_qt_internal_sbom_get_project_reuse_toml_path out_var)
set(reuse_toml_path "${PROJECT_SOURCE_DIR}/REUSE.toml")
set(${out_var} "${reuse_toml_path}" PARENT_SCOPE)
endfunction()
# Helper to generate and install a source SBOM using reuse.
function(_qt_internal_sbom_generate_reuse_source_sbom)
set(opt_args NO_ERROR)
set(single_args "")
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
_qt_internal_get_current_project_sbom_dir(sbom_dir)
set(file_op "${sbom_dir}/generate_reuse_source_sbom.cmake")
_qt_internal_sbom_get_project_reuse_toml_path(reuse_toml_path)
if(NOT EXISTS "${reuse_toml_path}" AND NOT QT_FORCE_SOURCE_SBOM_GENERATION)
set(skip_message
"Skipping source SBOM generation: No reuse.toml file found at '${reuse_toml_path}'.")
message(STATUS "${skip_message}")
set(content "
message(STATUS \"${skip_message}\")
")
file(GENERATE OUTPUT "${file_op}" CONTENT "${content}")
set_property(GLOBAL APPEND PROPERTY _qt_sbom_cmake_post_generation_include_files
"${file_op}")
return()
endif()
set(handle_error "")
if(NOT arg_NO_ERROR)
set(handle_error "
if(NOT res EQUAL 0)
message(FATAL_ERROR \"Source SBOM generation using reuse tool failed: \${res}\")
endif()
")
endif()
set(source_sbom_path "\${QT_SBOM_OUTPUT_PATH_WITHOUT_EXT}.source.spdx")
file(TO_CMAKE_PATH "$ENV{QT_QA_LICENSE_TEST_DIR}/$ENV{QT_SOURCE_SBOM_TEST_SCRIPT}"
full_path_to_license_test)
set(verify_source_sbom "
if(res EQUAL 0)
message(STATUS \"Verifying source SBOM ${source_sbom_path} using qtqa tst_licenses.pl ${full_path_to_license_test}\")
if(NOT EXISTS \"${full_path_to_license_test}\")
message(FATAL_ERROR \"Source SBOM check has failed: The tst_licenses.pl script could not be found at ${full_path_to_license_test}\")
endif()
execute_process(
COMMAND perl \"\$ENV{QT_SOURCE_SBOM_TEST_SCRIPT}\" -sbomonly -sbom \"${source_sbom_path}\"
WORKING_DIRECTORY \"\$ENV{QT_QA_LICENSE_TEST_DIR}\"
RESULT_VARIABLE res
COMMAND_ECHO STDOUT
)
if(NOT res EQUAL 0)
message(FATAL_ERROR \"Source SBOM check has failed: \${res}\")
endif()
endif()
")
set(extra_reuse_args "")
get_property(project_supplier GLOBAL PROPERTY _qt_sbom_project_supplier)
if(project_supplier)
get_property(project_supplier_url GLOBAL PROPERTY _qt_sbom_project_supplier_url)
# Add the supplier url if available. Add it in parenthesis to stop reuse from adding its
# own empty parenthesis.
if(project_supplier_url)
set(project_supplier "${project_supplier} (${project_supplier_url})")
endif()
# Unfortunately there's no way to silence the addition of the 'Creator: Person' field,
# even though 'Creator: Organization' is supplied.
list(APPEND extra_reuse_args --creator-organization "${project_supplier}")
endif()
set(content "
message(STATUS \"Generating source SBOM using reuse tool: ${source_sbom_path}\")
set(extra_reuse_args \"${extra_reuse_args}\")
execute_process(
COMMAND
${QT_SBOM_PROGRAM_REUSE}
--root \"${PROJECT_SOURCE_DIR}\"
spdx
-o ${source_sbom_path}
\${extra_reuse_args}
RESULT_VARIABLE res
)
${handle_error}
if(\"\$ENV{VERIFY_SOURCE_SBOM}\")
${verify_source_sbom}
endif()
")
file(GENERATE OUTPUT "${file_op}" CONTENT "${content}")
set_property(GLOBAL APPEND PROPERTY _qt_sbom_cmake_post_generation_include_files "${file_op}")
endfunction()
# Helper to run 'reuse lint' on the project source dir.
function(_qt_internal_sbom_run_reuse_lint)
set(opt_args
NO_ERROR
)
set(single_args
BUILD_TIME_SCRIPT_PATH_OUT_VAR
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
# If no reuse.toml file exists, it means the repo is likely not reuse compliant yet,
# so we shouldn't error out during installation when running the lint.
_qt_internal_sbom_get_project_reuse_toml_path(reuse_toml_path)
if(NOT EXISTS "${reuse_toml_path}" AND NOT QT_FORCE_REUSE_LINT_ERROR)
set(arg_NO_ERROR TRUE)
endif()
set(handle_error "")
if(NOT arg_NO_ERROR)
set(handle_error "
if(NOT res EQUAL 0)
message(FATAL_ERROR \"Running 'reuse lint' failed: \${res}\")
endif()
")
endif()
set(content "
message(STATUS \"Running 'reuse lint' in '${PROJECT_SOURCE_DIR}'.\")
execute_process(
COMMAND ${QT_SBOM_PROGRAM_REUSE} --root \"${PROJECT_SOURCE_DIR}\" lint
RESULT_VARIABLE res
)
${handle_error}
")
_qt_internal_get_current_project_sbom_dir(sbom_dir)
set(file_op_build "${sbom_dir}/run_reuse_lint_build.cmake")
file(GENERATE OUTPUT "${file_op_build}" CONTENT "${content}")
# Allow skipping running 'reuse lint' during installation. But still allow running it during
# build time. This is a fail safe opt-out in case some repo needs it.
if(QT_FORCE_SKIP_REUSE_LINT_ON_INSTALL)
set(skip_message "Skipping running 'reuse lint' in '${PROJECT_SOURCE_DIR}'.")
set(content "
message(STATUS \"${skip_message}\")
")
set(file_op_install "${sbom_dir}/run_reuse_lint_install.cmake")
file(GENERATE OUTPUT "${file_op_install}" CONTENT "${content}")
else()
# Just reuse the already generated script for installation as well.
set(file_op_install "${file_op_build}")
endif()
set_property(GLOBAL APPEND PROPERTY _qt_sbom_cmake_verify_include_files "${file_op_install}")
if(arg_BUILD_TIME_SCRIPT_PATH_OUT_VAR)
set(${arg_BUILD_TIME_SCRIPT_PATH_OUT_VAR} "${file_op_build}" PARENT_SCOPE)
endif()
endfunction()

View File

@ -0,0 +1,305 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Parse purl arguments for a specific purl entry.
# arguments_var_name is the variable name that contains the args.
# prefix is the prefix passed to cmake_parse_arguments.
macro(_qt_internal_sbom_parse_purl_entry_options prefix arguments_var_name)
_qt_internal_get_sbom_purl_parsing_options(purl_opt_args purl_single_args purl_multi_args)
cmake_parse_arguments(${prefix} "${purl_opt_args}" "${purl_single_args}" "${purl_multi_args}"
${${arguments_var_name}})
_qt_internal_validate_all_args_are_parsed(${prefix})
endmacro()
# Helper macro to prepare forwarding all set purl options to some other function.
# Expects the options names to be set in the parent scope by calling
# _qt_internal_get_sbom_add_target_options(opt_args single_args multi_args)
macro(_qt_internal_sbom_forward_purl_handling_options args_var_name)
if(NOT opt_args)
message(FATAL_ERROR
"Expected opt_args to be set by _qt_internal_get_sbom_purl_handling_options")
endif()
if(NOT single_args)
message(FATAL_ERROR
"Expected single_args to be set by _qt_internal_get_sbom_purl_handling_options")
endif()
if(NOT multi_args)
message(FATAL_ERROR
"Expected multi_args to be set by _qt_internal_get_sbom_purl_handling_options")
endif()
_qt_internal_forward_function_args(
FORWARD_PREFIX arg
FORWARD_OUT_VAR ${args_var_name}
FORWARD_OPTIONS
${opt_args}
FORWARD_SINGLE
${single_args}
FORWARD_MULTI
${multi_args}
)
endmacro()
# Handles purl arguments specified to functions like qt_internal_add_sbom.
#
# Synopsis
#
# qt_internal_add_sbom(<target>
# PURLS
# [[PURL_ENTRY
# PURL_ID <id>
# PURL_TYPE <type>
# PURL_NAMESPACE <namespace>
# PURL_NAME <name>
# PURL_VERSION <version>]...]
# PURL_VALUES
# [purl-string...]
# )
#
# Example
#
# qt_internal_add_sbom(<target>
# PURLS
# PURL_ENTRY
# PURL_ID "UPSTREAM"
# PURL_TYPE "github"
# PURL_NAMESPACE "harfbuzz"
# PURL_NAME "harfbuzz"
# PURL_VERSION "v8.5.0"
# PURL_ENTRY
# PURL_ID "MIRROR"
# PURL_TYPE "git"
# PURL_NAMESPACE "harfbuzz"
# PURL_NAME "harfbuzz"
# PURL_QUALIFIERS "vcs_url=https://code.qt.io/qt/qtbase"
# ....
# PURL_VALUES
# pkg:git/harfbuzz/harfbuzz@v8.5.0
# pkg:github/harfbuzz/harfbuzz@v8.5.0
# ....
#
#
# PURLS accepts multiple purl entries, each starting with the PURL_ENTRY keyword.
# PURL_VALUES takes a list of pre-built purl strings.
#
# If no arguments are specified, for qt entity types (e.g. libraries built as part of Qt repos),
# default purls will be generated.
#
# There is no limit to the number of purls that can be added to a target.
function(_qt_internal_sbom_handle_purl_values target)
_qt_internal_get_sbom_purl_handling_options(opt_args single_args multi_args)
list(APPEND single_args OUT_VAR)
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_OUT_VAR)
message(FATAL_ERROR "OUT_VAR must be set")
endif()
_qt_internal_get_sbom_purl_parsing_options(purl_opt_args purl_single_args purl_multi_args)
set(project_package_options "")
# Collect each PURL_ENTRY args into a separate variable.
set(purl_idx -1)
set(purl_entry_indices "")
foreach(purl_arg IN LISTS arg_PURLS)
if(purl_arg STREQUAL "PURL_ENTRY")
math(EXPR purl_idx "${purl_idx}+1")
list(APPEND purl_entry_indices "${purl_idx}")
elseif(purl_idx GREATER_EQUAL 0)
list(APPEND purl_${purl_idx}_args "${purl_arg}")
else()
message(FATAL_ERROR "Missing PURL_ENTRY keyword.")
endif()
endforeach()
# Validate the args for each collected entry.
foreach(purl_idx IN LISTS purl_entry_indices)
list(LENGTH purl_${purl_idx}_args num_args)
if(num_args LESS 1)
message(FATAL_ERROR "Empty PURL_ENTRY encountered.")
endif()
_qt_internal_sbom_parse_purl_entry_options(arg purl_${purl_idx}_args)
endforeach()
# Append qt specific placeholder entries when handling Qt entities.
if(arg___QT_INTERNAL_HANDLE_QT_ENTITY_TYPE_PURL)
_qt_internal_sbom_forward_purl_handling_options(purl_handling_args)
_qt_internal_sbom_handle_qt_entity_purl_entries(${purl_handling_args}
OUT_VAR_IDS qt_purl_ids
)
if(qt_purl_ids)
# Create purl placeholder indices for each qt purl id.
foreach(qt_purl_id IN LISTS qt_purl_ids)
math(EXPR purl_idx "${purl_idx}+1")
list(APPEND purl_entry_indices "${purl_idx}")
list(APPEND purl_${purl_idx}_args PURL_ID "${qt_purl_id}")
endforeach()
endif()
endif()
foreach(purl_idx IN LISTS purl_entry_indices)
# Clear previous values.
foreach(option_name IN LISTS purl_opt_args purl_single_args purl_multi_args)
unset(arg_${option_name})
endforeach()
_qt_internal_sbom_parse_purl_entry_options(arg purl_${purl_idx}_args)
set(purl_args "")
# Override the purl version with the package version.
if(arg_PURL_USE_PACKAGE_VERSION AND arg_PACKAGE_VERSION)
set(arg_PURL_VERSION "${arg_PACKAGE_VERSION}")
endif()
# Append a vcs_url to the qualifiers if specified.
if(arg_PURL_VCS_URL)
list(APPEND arg_PURL_QUALIFIERS "vcs_url=${arg_PURL_VCS_URL}")
endif()
_qt_internal_forward_function_args(
FORWARD_APPEND
FORWARD_PREFIX arg
FORWARD_OUT_VAR purl_args
FORWARD_OPTIONS
${purl_opt_args}
FORWARD_SINGLE
${purl_single_args}
FORWARD_MULTI
${purl_multi_args}
)
# Qt entity types get special treatment to gather the required args.
if(arg___QT_INTERNAL_HANDLE_QT_ENTITY_TYPE_PURL
AND arg_PURL_ID
AND arg_PURL_ID IN_LIST qt_purl_ids)
_qt_internal_sbom_handle_qt_entity_purl("${target}"
${purl_handling_args}
PURL_ID "${arg_PURL_ID}"
OUT_PURL_ARGS qt_purl_args
)
if(qt_purl_args)
list(APPEND purl_args "${qt_purl_args}")
endif()
endif()
_qt_internal_sbom_assemble_purl(${target}
${purl_args}
OUT_VAR package_manager_external_ref
)
list(APPEND project_package_options ${package_manager_external_ref})
endforeach()
foreach(purl_value IN LISTS arg_PURL_VALUES)
_qt_internal_sbom_get_purl_value_extref(
VALUE "${purl_value}" OUT_VAR package_manager_external_ref)
# The order in which the purls are generated, matters for tools that consume the SBOM.
# Some tools can only handle one PURL per package, so the first one should be the
# important one.
# For now, I deem that the directly specified ones (probably via a qt_attribution.json
# file) are the more important ones. So we prepend them.
list(PREPEND project_package_options ${package_manager_external_ref})
endforeach()
set(${arg_OUT_VAR} "${project_package_options}" PARENT_SCOPE)
endfunction()
# Assembles an external reference purl identifier.
# PURL_TYPE and PURL_NAME are required.
# Stores the result in the OUT_VAR.
# Accepted options:
# PURL_TYPE
# PURL_NAME
# PURL_NAMESPACE
# PURL_VERSION
# PURL_SUBPATH
# PURL_QUALIFIERS
function(_qt_internal_sbom_assemble_purl target)
set(opt_args "")
set(single_args
OUT_VAR
)
set(multi_args "")
_qt_internal_get_sbom_purl_parsing_options(purl_opt_args purl_single_args purl_multi_args)
list(APPEND opt_args ${purl_opt_args})
list(APPEND single_args ${purl_single_args})
list(APPEND multi_args ${purl_multi_args})
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
set(purl_scheme "pkg")
if(NOT arg_PURL_TYPE)
message(FATAL_ERROR "PURL_TYPE must be set")
endif()
if(NOT arg_PURL_NAME)
message(FATAL_ERROR "PURL_NAME must be set")
endif()
if(NOT arg_OUT_VAR)
message(FATAL_ERROR "OUT_VAR must be set")
endif()
# https://github.com/package-url/purl-spec
# Spec is 'scheme:type/namespace/name@version?qualifiers#subpath'
set(purl "${purl_scheme}:${arg_PURL_TYPE}")
if(arg_PURL_NAMESPACE)
string(APPEND purl "/${arg_PURL_NAMESPACE}")
endif()
string(APPEND purl "/${arg_PURL_NAME}")
if(arg_PURL_VERSION)
string(APPEND purl "@${arg_PURL_VERSION}")
endif()
if(arg_PURL_QUALIFIERS)
# TODO: Note that the qualifiers are expected to be URL encoded, which this implementation
# is not doing at the moment.
list(JOIN arg_PURL_QUALIFIERS "&" qualifiers)
string(APPEND purl "?${qualifiers}")
endif()
if(arg_PURL_SUBPATH)
string(APPEND purl "#${arg_PURL_SUBPATH}")
endif()
_qt_internal_sbom_get_purl_value_extref(VALUE "${purl}" OUT_VAR result)
set(${arg_OUT_VAR} "${result}" PARENT_SCOPE)
endfunction()
# Takes a PURL VALUE and returns an SBOM purl external reference in OUT_VAR.
function(_qt_internal_sbom_get_purl_value_extref)
set(opt_args "")
set(single_args
OUT_VAR
VALUE
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_OUT_VAR)
message(FATAL_ERROR "OUT_VAR must be set")
endif()
if(NOT arg_VALUE)
message(FATAL_ERROR "VALUE must be set")
endif()
# SPDX SBOM External reference type.
set(ext_ref_prefix "PACKAGE-MANAGER purl")
set(external_ref "${ext_ref_prefix} ${arg_VALUE}")
set(result "EXTREF" "${external_ref}")
set(${arg_OUT_VAR} "${result}" PARENT_SCOPE)
endfunction()

View File

@ -0,0 +1,250 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Helper macro to find python and a given dependency. Expects the caller to set all of the vars.
# Meant to reduce the line noise due to the repeated calls.
macro(_qt_internal_sbom_find_python_and_dependency_helper_lambda)
_qt_internal_sbom_find_python_and_dependency_helper(
PYTHON_ARGS
${extra_python_args}
${python_common_args}
DEPENDENCY_ARGS
DEPENDENCY_IMPORT_STATEMENT "${import_statement}"
OUT_VAR_PYTHON_PATH python_path
OUT_VAR_PYTHON_FOUND python_found
OUT_VAR_DEP_FOUND dep_found
OUT_VAR_PYTHON_AND_DEP_FOUND everything_found
OUT_VAR_DEP_FIND_OUTPUT dep_find_output
)
endmacro()
# Tries to find python and a given dependency based on the args passed to PYTHON_ARGS and
# DEPENDENCY_ARGS which are forwarded to the respective finding functions.
# Returns the path to the python interpreter, whether it was found, whether the dependency was
# found, whether both were found, and the reason why the dependency might not be found.
function(_qt_internal_sbom_find_python_and_dependency_helper)
set(opt_args)
set(single_args
OUT_VAR_PYTHON_PATH
OUT_VAR_PYTHON_FOUND
OUT_VAR_DEP_FOUND
OUT_VAR_PYTHON_AND_DEP_FOUND
OUT_VAR_DEP_FIND_OUTPUT
)
set(multi_args
PYTHON_ARGS
DEPENDENCY_ARGS
)
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
set(everything_found_inner FALSE)
set(deps_find_output_inner "")
if(NOT arg_OUT_VAR_PYTHON_PATH)
message(FATAL_ERROR "OUT_VAR_PYTHON_PATH var is required")
endif()
if(NOT arg_OUT_VAR_PYTHON_FOUND)
message(FATAL_ERROR "OUT_VAR_PYTHON_FOUND var is required")
endif()
if(NOT arg_OUT_VAR_DEP_FOUND)
message(FATAL_ERROR "OUT_VAR_DEP_FOUND var is required")
endif()
if(NOT arg_OUT_VAR_PYTHON_AND_DEP_FOUND)
message(FATAL_ERROR "OUT_VAR_PYTHON_AND_DEP_FOUND var is required")
endif()
if(NOT arg_OUT_VAR_DEP_FIND_OUTPUT)
message(FATAL_ERROR "OUT_VAR_DEP_FIND_OUTPUT var is required")
endif()
_qt_internal_sbom_find_python_helper(
${arg_PYTHON_ARGS}
OUT_VAR_PYTHON_PATH python_path_inner
OUT_VAR_PYTHON_FOUND python_found_inner
)
if(python_found_inner AND python_path_inner)
_qt_internal_sbom_find_python_dependency_helper(
${arg_DEPENDENCY_ARGS}
PYTHON_PATH "${python_path_inner}"
OUT_VAR_FOUND dep_found_inner
OUT_VAR_OUTPUT dep_find_output_inner
)
if(dep_found_inner)
set(everything_found_inner TRUE)
endif()
endif()
set(${arg_OUT_VAR_PYTHON_PATH} "${python_path_inner}" PARENT_SCOPE)
set(${arg_OUT_VAR_PYTHON_FOUND} "${python_found_inner}" PARENT_SCOPE)
set(${arg_OUT_VAR_DEP_FOUND} "${dep_found_inner}" PARENT_SCOPE)
set(${arg_OUT_VAR_PYTHON_AND_DEP_FOUND} "${everything_found_inner}" PARENT_SCOPE)
set(${arg_OUT_VAR_DEP_FIND_OUTPUT} "${dep_find_output_inner}" PARENT_SCOPE)
endfunction()
# Tries to find the python intrepreter, given the QT_SBOM_PYTHON_INTERP path hint, as well as
# other options.
# Ignores any previously found python.
# Returns the python interpreter path and whether it was successfully found.
#
# This is intentionally a function, and not a macro, to prevent overriding the Python3_EXECUTABLE
# non-cache variable in a global scope in case if a different python is found and used for a
# different purpose (e.g. qtwebengine or qtinterfaceframework).
# The reason to use a different python is that an already found python might not be the version we
# need, or might lack the dependencies we need.
# https://gitlab.kitware.com/cmake/cmake/-/issues/21797#note_901621 claims that finding multiple
# python versions in separate directory scopes is possible, and I claim a function scope is as
# good as a directory scope.
function(_qt_internal_sbom_find_python_helper)
set(opt_args
SEARCH_IN_FRAMEWORKS
QUIET
)
set(single_args
VERSION
OUT_VAR_PYTHON_PATH
OUT_VAR_PYTHON_FOUND
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_OUT_VAR_PYTHON_PATH)
message(FATAL_ERROR "OUT_VAR_PYTHON_PATH var is required")
endif()
if(NOT arg_OUT_VAR_PYTHON_FOUND)
message(FATAL_ERROR "OUT_VAR_PYTHON_FOUND var is required")
endif()
# Allow disabling looking for a python interpreter shipped as part of a macOS system framework.
if(NOT arg_SEARCH_IN_FRAMEWORKS)
set(Python3_FIND_FRAMEWORK NEVER)
endif()
set(required_version "")
if(arg_VERSION)
set(required_version "${arg_VERSION}")
endif()
set(find_quiet "")
if(arg_QUIET)
set(find_quiet "QUIET")
endif()
# Locally reset any executable that was possibly already found.
# We do this to ensure we always re-do the lookup/
# This needs to be set to an empty string, to override any cache variable
set(Python3_EXECUTABLE "")
# This needs to be unset, because the Python module checks whether the variable is defined, not
# whether it is empty.
unset(_Python3_EXECUTABLE)
if(QT_SBOM_PYTHON_INTERP)
set(Python3_ROOT_DIR ${QT_SBOM_PYTHON_INTERP})
endif()
find_package(Python3 ${required_version} ${find_quiet} COMPONENTS Interpreter)
set(${arg_OUT_VAR_PYTHON_PATH} "${Python3_EXECUTABLE}" PARENT_SCOPE)
set(${arg_OUT_VAR_PYTHON_FOUND} "${Python3_Interpreter_FOUND}" PARENT_SCOPE)
endfunction()
# Helper that takes an python import statement to run using the given python interpreter path,
# to confirm that the given python dependency can be found.
# Returns whether the dependency was found and the output of running the import, for error handling.
function(_qt_internal_sbom_find_python_dependency_helper)
set(opt_args "")
set(single_args
DEPENDENCY_IMPORT_STATEMENT
PYTHON_PATH
OUT_VAR_FOUND
OUT_VAR_OUTPUT
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_PYTHON_PATH)
message(FATAL_ERROR "Python interpreter path not given.")
endif()
if(NOT arg_DEPENDENCY_IMPORT_STATEMENT)
message(FATAL_ERROR "Python depdendency import statement not given.")
endif()
if(NOT arg_OUT_VAR_FOUND)
message(FATAL_ERROR "Out var found variable not given.")
endif()
set(python_path "${arg_PYTHON_PATH}")
execute_process(
COMMAND
${python_path} -c "${arg_DEPENDENCY_IMPORT_STATEMENT}"
RESULT_VARIABLE res
OUTPUT_VARIABLE output
ERROR_VARIABLE output
)
if("${res}" STREQUAL "0")
set(found TRUE)
set(output "${output}")
else()
set(found FALSE)
string(CONCAT output "SBOM Python dependency ${arg_DEPENDENCY_IMPORT_STATEMENT} not found. "
"Error:\n${output}")
endif()
set(${arg_OUT_VAR_FOUND} "${found}" PARENT_SCOPE)
if(arg_OUT_VAR_OUTPUT)
set(${arg_OUT_VAR_OUTPUT} "${output}" PARENT_SCOPE)
endif()
endfunction()
# Helper to find a python installed CLI utility.
# Expected to be in PATH.
function(_qt_internal_sbom_find_python_dependency_program)
set(opt_args
REQUIRED
)
set(single_args
NAME
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
set(program_name "${arg_NAME}")
string(TOUPPER "${program_name}" upper_name)
set(cache_var "QT_SBOM_PROGRAM_${upper_name}")
set(hints "")
# The path to python installed apps is different on Windows compared to UNIX, so we use
# a different path than where the python interpreter might be located.
if(QT_SBOM_PYTHON_APPS_PATH)
list(APPEND hints ${QT_SBOM_PYTHON_APPS_PATH})
endif()
find_program(${cache_var}
NAMES ${program_name}
HINTS ${hints}
)
if(NOT ${cache_var})
if(arg_REQUIRED)
set(message_type "FATAL_ERROR")
set(prefix "Required ")
else()
set(message_type "STATUS")
set(prefix "Optional ")
endif()
message(${message_type} "${prefix}SBOM python program '${program_name}' not found.")
endif()
endfunction()

View File

@ -0,0 +1,492 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Helper macro to prepare forwarding all set sbom options to some other function.
# Expects the options names to be set in the parent scope by calling
# _qt_internal_get_sbom_add_target_options(opt_args single_args multi_args)
macro(_qt_internal_sbom_forward_sbom_add_target_options args_var_name)
if(NOT opt_args)
message(FATAL_ERROR
"Expected opt_args to be set by _qt_internal_get_sbom_add_target_options")
endif()
if(NOT single_args)
message(FATAL_ERROR
"Expected single_args to be set by _qt_internal_get_sbom_add_target_options")
endif()
if(NOT multi_args)
message(FATAL_ERROR
"Expected multi_args to be set by _qt_internal_get_sbom_add_target_options")
endif()
_qt_internal_forward_function_args(
FORWARD_PREFIX arg
FORWARD_OUT_VAR ${args_var_name}
FORWARD_OPTIONS
${opt_args}
FORWARD_SINGLE
${single_args}
FORWARD_MULTI
${multi_args}
)
endmacro()
# Helper function to add a default supplier for a qt entity type.
function(_qt_internal_sbom_handle_qt_entity_supplier target)
_qt_internal_get_sbom_add_target_options(opt_args single_args multi_args)
list(APPEND single_args OUT_VAR)
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
_qt_internal_sbom_is_qt_entity_type("${arg_TYPE}" is_qt_entity_type)
_qt_internal_sbom_is_qt_3rd_party_entity_type("${arg_TYPE}" is_qt_3rd_party_entity_type)
set(supplier "")
if(NOT arg_SUPPLIER
AND (is_qt_entity_type OR is_qt_3rd_party_entity_type)
AND NOT arg_NO_DEFAULT_QT_SUPPLIER)
_qt_internal_sbom_get_default_supplier(supplier)
endif()
if(supplier)
set(${arg_OUT_VAR} "${supplier}" PARENT_SCOPE)
endif()
endfunction()
# Helper function to add a default package for a qt entity type.
function(_qt_internal_sbom_handle_qt_entity_package_version target)
_qt_internal_get_sbom_add_target_options(opt_args single_args multi_args)
list(APPEND single_args OUT_VAR)
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
_qt_internal_sbom_is_qt_entity_type("${arg_TYPE}" is_qt_entity_type)
set(package_version "")
if(NOT arg_PACKAGE_VERSION
AND is_qt_entity_type
AND NOT arg_NO_DEFAULT_QT_PACKAGE_VERSION)
_qt_internal_sbom_get_default_qt_package_version(package_version)
endif()
if(package_version)
set(${arg_OUT_VAR} "${package_version}" PARENT_SCOPE)
endif()
endfunction()
# Helper function to add a default repo download location for a qt entity type.
function(_qt_internal_sbom_handle_qt_entity_download_location target)
_qt_internal_get_sbom_add_target_options(opt_args single_args multi_args)
list(APPEND single_args OUT_VAR)
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
_qt_internal_sbom_is_qt_entity_type("${arg_TYPE}" is_qt_entity_type)
set(download_location "")
if(NOT arg_DOWNLOAD_LOCATION AND is_qt_entity_type)
_qt_internal_sbom_get_qt_repo_source_download_location(download_location)
endif()
if(download_location)
set(${arg_OUT_VAR} "${download_location}" PARENT_SCOPE)
endif()
endfunction()
# Helper function to add a default license expression for a qt entity type.
function(_qt_internal_sbom_handle_qt_entity_license_expression target)
_qt_internal_get_sbom_add_target_options(opt_args single_args multi_args)
list(APPEND single_args OUT_VAR)
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
_qt_internal_sbom_is_qt_entity_type("${arg_TYPE}" is_qt_entity_type)
set(license_expression "")
# For Qt entities, we have some special handling.
if(is_qt_entity_type AND NOT arg_NO_DEFAULT_QT_LICENSE AND NOT arg_QT_LICENSE_ID)
if(arg_TYPE STREQUAL "QT_TOOL" OR arg_TYPE STREQUAL "QT_APP")
if(QT_SBOM_DEFAULT_QT_LICENSE_ID_EXECUTABLES
AND NOT arg_NO_DEFAULT_QT_LICENSE_ID_EXECUTABLES)
# A repo might contain only the "gpl3" license variant as the default for all
# executables, so allow setting it at the repo level to avoid having to repeat it
# for each target.
_qt_internal_sbom_get_spdx_license_expression(
"${QT_SBOM_DEFAULT_QT_LICENSE_ID_EXECUTABLES}" license_expression)
else()
# For tools and apps, we use the gpl exception variant by default.
_qt_internal_sbom_get_spdx_license_expression("QT_COMMERCIAL_OR_GPL3_WITH_EXCEPTION"
license_expression)
endif()
elseif(QT_SBOM_DEFAULT_QT_LICENSE_ID_LIBRARIES
AND NOT arg_NO_DEFAULT_QT_LICENSE_ID_LIBRARIES)
# A repo might contain only the "gpl3" license variant as the default for all modules
# and plugins, so allow setting it at the repo level to avoid having to repeat it
# for each target.
_qt_internal_sbom_get_spdx_license_expression(
"${QT_SBOM_DEFAULT_QT_LICENSE_ID_LIBRARIES}" license_expression)
else()
# Otherwise, for modules and plugins we use the default qt license.
_qt_internal_sbom_get_spdx_license_expression("QT_DEFAULT" license_expression)
endif()
endif()
# Some Qt entities might request a specific license from the subset that we usually use.
if(arg_QT_LICENSE_ID)
_qt_internal_sbom_get_spdx_license_expression("${arg_QT_LICENSE_ID}"
requested_license_expression)
_qt_internal_sbom_join_two_license_ids_with_op(
"${license_expression}" "AND" "${requested_license_expression}"
license_expression)
endif()
# Allow setting a license expression string per directory scope via a variable.
if(is_qt_entity_type AND QT_SBOM_LICENSE_EXPRESSION AND NOT arg_NO_DEFAULT_DIRECTORY_QT_LICENSE)
set(qt_license_expression "${QT_SBOM_LICENSE_EXPRESSION}")
_qt_internal_sbom_join_two_license_ids_with_op(
"${license_expression}" "AND" "${qt_license_expression}"
license_expression)
endif()
if(license_expression)
set(${arg_OUT_VAR} "${license_expression}" PARENT_SCOPE)
endif()
endfunction()
# Helper function to add a default license declared expression for a qt entity type.
function(_qt_internal_sbom_handle_qt_entity_license_declared_expression target)
_qt_internal_get_sbom_add_target_options(opt_args single_args multi_args)
list(APPEND single_args OUT_VAR LICENSE_CONCLUDED_EXPRESSION)
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
_qt_internal_sbom_is_qt_entity_type("${arg_TYPE}" is_qt_entity_type)
set(license_expression "")
# For qt entities we know the license we provide, so we mark it as declared as well.
if(is_qt_entity_type AND arg_LICENSE_CONCLUDED_EXPRESSION)
set(license_expression "${arg_LICENSE_CONCLUDED_EXPRESSION}")
endif()
if(license_expression)
set(${arg_OUT_VAR} "${license_expression}" PARENT_SCOPE)
endif()
endfunction()
# Get the default qt copyright.
function(_qt_internal_sbom_get_default_qt_copyright_header out_var)
set(${out_var}
"Copyright (C) The Qt Company Ltd. and other contributors."
PARENT_SCOPE)
endfunction()
# Helper function to add default copyrights for a qt entity type.
function(_qt_internal_sbom_handle_qt_entity_copyrights target)
_qt_internal_get_sbom_add_target_options(opt_args single_args multi_args)
list(APPEND single_args OUT_VAR)
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
_qt_internal_sbom_is_qt_entity_type("${arg_TYPE}" is_qt_entity_type)
set(qt_default_copyright "")
if(is_qt_entity_type AND NOT arg_NO_DEFAULT_QT_COPYRIGHTS)
_qt_internal_sbom_get_default_qt_copyright_header(qt_default_copyright)
endif()
if(qt_default_copyright)
set(${arg_OUT_VAR} "${qt_default_copyright}" PARENT_SCOPE)
endif()
endfunction()
# Helper function to add default CPEs for a qt entity type.
function(_qt_internal_sbom_handle_qt_entity_cpe target)
_qt_internal_get_sbom_add_target_options(opt_args single_args multi_args)
list(APPEND single_args OUT_VAR)
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
_qt_internal_sbom_is_qt_entity_type("${arg_TYPE}" is_qt_entity_type)
_qt_internal_sbom_is_qt_3rd_party_entity_type("${arg_TYPE}" is_qt_3rd_party_entity_type)
set(cpe_list "")
# Add the qt-specific CPE if the target is a Qt entity type, or if it's a 3rd party entity type
# without any CPE specified.
if(is_qt_entity_type OR (is_qt_3rd_party_entity_type AND NOT arg_CPE))
_qt_internal_sbom_compute_security_cpe_for_qt(cpe_list)
endif()
if(cpe_list)
set(${arg_OUT_VAR} "${cpe_list}" PARENT_SCOPE)
endif()
endfunction()
# Returns a vcs url for purls where qt entities of the current repo are hosted.
function(_qt_internal_sbom_get_qt_entity_vcs_url target)
set(opt_args "")
set(single_args
REPO_NAME
VERSION
OUT_VAR
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_REPO_NAME)
message(FATAL_ERROR "REPO_NAME must be set")
endif()
if(NOT arg_OUT_VAR)
message(FATAL_ERROR "OUT_VAR must be set")
endif()
set(version_part "")
if(arg_VERSION)
set(version_part "@${arg_VERSION}")
endif()
set(vcs_url "https://code.qt.io/qt/${arg_REPO_NAME}.git${version_part}")
set(${arg_OUT_VAR} "${vcs_url}" PARENT_SCOPE)
endfunction()
# Returns a relative path to the source where the target was created, to be embedded into a
# mirror purl as a subpath.
function(_qt_internal_sbom_get_qt_entity_repo_source_dir target)
set(opt_args "")
set(single_args
OUT_VAR
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_OUT_VAR)
message(FATAL_ERROR "OUT_VAR must be set")
endif()
get_target_property(repo_source_dir "${target}" SOURCE_DIR)
# Get the path relative to the PROJECT_SOURCE_DIR
file(RELATIVE_PATH relative_repo_source_dir "${PROJECT_SOURCE_DIR}" "${repo_source_dir}")
set(sub_path "${relative_repo_source_dir}")
set(${arg_OUT_VAR} "${sub_path}" PARENT_SCOPE)
endfunction()
# Gets a list of arguments to pass to _qt_internal_sbom_assemble_purl when handling a Qt entity
# type. The purl for Qt entity types have Qt-specific defaults, but can be overridden per purl
# component.
# The arguments are saved in OUT_VAR.
function(_qt_internal_sbom_get_qt_entity_purl_args target)
set(opt_args "")
set(single_args
NAME
REPO_NAME
SUPPLIER
VERSION
OUT_VAR
)
set(multi_args "")
_qt_internal_get_sbom_purl_parsing_options(purl_opt_args purl_single_args purl_multi_args)
list(APPEND opt_args ${purl_opt_args})
list(APPEND single_args ${purl_single_args})
list(APPEND multi_args ${purl_multi_args})
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(arg_VERSION)
set(purl_version "${arg_VERSION}")
endif()
if(arg_PURL_ID STREQUAL "GENERIC")
set(purl_type "generic")
set(purl_namespace "${arg_SUPPLIER}")
set(purl_name "${arg_NAME}")
elseif(arg_PURL_ID STREQUAL "GITHUB")
set(purl_type "github")
set(purl_namespace "qt")
set(purl_name "${arg_REPO_NAME}")
endif()
if(arg_PURL_TYPE)
set(purl_type "${arg_PURL_TYPE}")
endif()
if(arg_PURL_NAMESPACE)
set(purl_namespace "${arg_PURL_NAMESPACE}")
endif()
if(arg_PURL_NAME)
set(purl_name "${arg_PURL_NAME}")
endif()
if(arg_PURL_VERSION)
set(purl_version "${arg_PURL_VERSION}")
endif()
set(purl_version_option "")
if(purl_version)
set(purl_version_option PURL_VERSION "${purl_version}")
endif()
set(purl_args
PURL_TYPE "${purl_type}"
PURL_NAMESPACE "${purl_namespace}"
PURL_NAME "${purl_name}"
${purl_version_option}
)
if(arg_PURL_QUALIFIERS)
list(APPEND purl_args PURL_QUALIFIERS "${arg_PURL_QUALIFIERS}")
endif()
if(arg_PURL_SUBPATH)
list(APPEND purl_args PURL_SUBPATH "${arg_PURL_SUBPATH}")
endif()
set(${arg_OUT_VAR} "${purl_args}" PARENT_SCOPE)
endfunction()
# Helper to get the list of default purl ids for a qt entity.
#
# Qt entities have two purls by default:
# - a GITHUB one pointing to the qt github mirror
# - a GENERIC one pointing to code.qt.io via vcs_url
#
# Third party libraries vendored in Qt also have the same purls, like regular Qt
# libraries, but might also have an upstream one which is specified explicitly.
function(_qt_internal_sbom_get_qt_entity_default_purl_ids out_var)
set(supported_purl_ids GITHUB GENERIC)
set(${out_var} "${supported_purl_ids}" PARENT_SCOPE)
endfunction()
# Helper function to decide which purl ids to add for a qt entity.
# Returns either a list of qt purl ids, or an empty list if it's not a qt entity type or qt 3rd
# party type.
function(_qt_internal_sbom_handle_qt_entity_purl_entries)
_qt_internal_get_sbom_purl_handling_options(opt_args single_args multi_args)
list(APPEND single_args
OUT_VAR # This is unused, but added by the calling function.
OUT_VAR_IDS
)
cmake_parse_arguments(PARSE_ARGV 0 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
set(purl_ids "")
_qt_internal_sbom_is_qt_entity_type("${arg_TYPE}" is_qt_entity_type)
_qt_internal_sbom_is_qt_3rd_party_entity_type("${arg_TYPE}" is_qt_3rd_party_entity_type)
if(is_qt_entity_type OR is_qt_3rd_party_entity_type)
_qt_internal_sbom_get_qt_entity_default_purl_ids(purl_ids)
endif()
if(purl_ids)
set(${arg_OUT_VAR_IDS} "${purl_ids}" PARENT_SCOPE)
endif()
endfunction()
# Helper function to add purl values for a specific purl entry of a qt entity type.
function(_qt_internal_sbom_handle_qt_entity_purl target)
_qt_internal_get_sbom_purl_handling_options(opt_args single_args multi_args)
list(APPEND single_args
OUT_VAR # This is unused, but added by the calling function.
OUT_PURL_ARGS
PURL_ID
)
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
set(purl_args "")
_qt_internal_sbom_get_git_version_vars()
# Return early if not handling one of the default qt purl ids, or if requested not to add a
# default purl.
_qt_internal_sbom_get_qt_entity_default_purl_ids(default_purl_ids)
if(arg_NO_DEFAULT_QT_PURL OR (NOT arg_PURL_ID IN_LIST default_purl_ids))
set(${arg_OUT_PURL_ARGS} "${purl_args}" PARENT_SCOPE)
return()
endif()
_qt_internal_sbom_get_root_project_name_lower_case(repo_project_name_lowercase)
# Add a vcs_url to the GENERIC purl entry.
if(arg_PURL_ID STREQUAL "GENERIC")
set(entity_vcs_url_version_option "")
# Can be empty.
if(QT_SBOM_GIT_HASH_SHORT)
set(entity_vcs_url_version_option VERSION "${QT_SBOM_GIT_HASH_SHORT}")
endif()
_qt_internal_sbom_get_qt_entity_vcs_url(${target}
REPO_NAME "${repo_project_name_lowercase}"
${entity_vcs_url_version_option}
OUT_VAR vcs_url)
list(APPEND purl_args PURL_QUALIFIERS "vcs_url=${vcs_url}")
endif()
# Add the subdirectory path where the target was created as a custom qualifier.
_qt_internal_sbom_get_qt_entity_repo_source_dir(${target} OUT_VAR sub_path)
if(sub_path)
list(APPEND purl_args PURL_SUBPATH "${sub_path}")
endif()
# Add the target name as a custom qualifer.
list(APPEND purl_args PURL_QUALIFIERS "library_name=${target}")
# Can be empty.
if(QT_SBOM_GIT_HASH_SHORT)
list(APPEND purl_args VERSION "${QT_SBOM_GIT_HASH_SHORT}")
endif()
# Get purl args the Qt entity type, taking into account defaults.
_qt_internal_sbom_get_qt_entity_purl_args(${target}
NAME "${repo_project_name_lowercase}-${target}"
REPO_NAME "${repo_project_name_lowercase}"
SUPPLIER "${arg_SUPPLIER}"
PURL_ID "${arg_PURL_ID}"
${purl_args}
OUT_VAR purl_args
)
if(purl_args)
set(${arg_OUT_PURL_ARGS} "${purl_args}" PARENT_SCOPE)
endif()
endfunction()
# Get the default qt package version.
function(_qt_internal_sbom_get_default_qt_package_version out_var)
set(${out_var} "${QT_REPO_MODULE_VERSION}" PARENT_SCOPE)
endfunction()
# Get the default qt supplier.
function(_qt_internal_sbom_get_default_supplier out_var)
set(${out_var} "TheQtCompany" PARENT_SCOPE)
endfunction()
# Get the default qt supplier url.
function(_qt_internal_sbom_get_default_supplier_url out_var)
set(${out_var} "https://qt.io" PARENT_SCOPE)
endfunction()
# Get the default qt download location.
# If git info is available, includes the hash.
function(_qt_internal_sbom_get_qt_repo_source_download_location out_var)
_qt_internal_sbom_get_root_project_name_lower_case(repo_project_name_lowercase)
set(download_location "git://code.qt.io/qt/${repo_project_name_lowercase}.git")
_qt_internal_sbom_get_git_version_vars()
if(QT_SBOM_GIT_HASH)
string(APPEND download_location "@${QT_SBOM_GIT_HASH}")
endif()
set(${out_var} "${download_location}" PARENT_SCOPE)
endfunction()

View File

@ -0,0 +1,165 @@
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# Records information about a system library target, usually due to a qt_find_package call.
# This information is later used to generate packages for the system libraries, but only after
# confirming that the library was used (linked) into any of the Qt targets.
function(_qt_internal_sbom_record_system_library_usage target)
if(NOT QT_GENERATE_SBOM)
return()
endif()
set(opt_args "")
set(single_args
TYPE
PACKAGE_VERSION
FRIENDLY_PACKAGE_NAME
)
set(multi_args "")
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
_qt_internal_validate_all_args_are_parsed(arg)
if(NOT arg_TYPE)
message(FATAL_ERROR "TYPE must be set")
endif()
# A package might be looked up more than once, make sure to record it once.
get_property(already_recorded GLOBAL PROPERTY
_qt_internal_sbom_recorded_system_library_target_${target})
if(already_recorded)
return()
endif()
set_property(GLOBAL PROPERTY
_qt_internal_sbom_recorded_system_library_target_${target} TRUE)
# Defer spdx id creation until _qt_internal_sbom_begin_project is called, so we know the
# project name. The project name is used in the package infix generation of the system library,
# but _qt_internal_sbom_record_system_library_usage might be called before sbom generation
# has started, e.g. during _qt_internal_find_third_party_dependencies.
set(spdx_options
${target}
TYPE "${arg_TYPE}"
PACKAGE_NAME "${arg_FRIENDLY_PACKAGE_NAME}"
)
get_cmake_property(sbom_repo_begin_called _qt_internal_sbom_repo_begin_called)
if(sbom_repo_begin_called AND TARGET "${target}")
_qt_internal_sbom_record_system_library_spdx_id(${target} ${spdx_options})
else()
set_property(GLOBAL PROPERTY
_qt_internal_sbom_recorded_system_library_spdx_options_${target} "${spdx_options}")
endif()
# Defer sbom info creation until we detect usage of the system library (whether the library is
# linked into any other target).
set_property(GLOBAL APPEND PROPERTY
_qt_internal_sbom_recorded_system_library_targets "${target}")
set_property(GLOBAL PROPERTY
_qt_internal_sbom_recorded_system_library_options_${target} "${ARGN}")
endfunction()
# Helper to record spdx ids of all system library targets that were found so far.
function(_qt_internal_sbom_record_system_library_spdx_ids)
get_property(recorded_targets GLOBAL PROPERTY _qt_internal_sbom_recorded_system_library_targets)
if(NOT recorded_targets)
return()
endif()
foreach(target IN LISTS recorded_targets)
get_property(args GLOBAL PROPERTY
_qt_internal_sbom_recorded_system_library_spdx_options_${target})
# qt_find_package PROVIDED_TARGETS might refer to non-existent targets in certain cases,
# like zstd::libzstd_shared for qt_find_package(WrapZSTD), because we are not sure what
# kind of zstd build was done. Make sure to check if the target exists before recording it.
if(TARGET "${target}")
set(target_unaliased "${target}")
_qt_internal_dealias_target(target_unaliased)
_qt_internal_sbom_record_system_library_spdx_id(${target_unaliased} ${args})
else()
message(DEBUG
"Skipping recording system library for SBOM because target does not exist: "
" ${target}")
endif()
endforeach()
endfunction()
# Helper to record the spdx id of a system library target.
function(_qt_internal_sbom_record_system_library_spdx_id target)
# Save the spdx id before the sbom info is added, so we can refer to it in relationships.
_qt_internal_sbom_record_target_spdx_id(${ARGN} OUT_VAR package_spdx_id)
if(NOT package_spdx_id)
message(FATAL_ERROR "Could not generate spdx id for system library target: ${target}")
endif()
set_target_properties("${target}" PROPERTIES _qt_internal_sbom_is_system_library TRUE)
set_property(GLOBAL PROPERTY
_qt_internal_sbom_recorded_system_library_package_${target} "${package_spdx_id}")
endfunction()
# Goes through the list of consumed system libraries (those that were linked in) and creates
# sbom packages for them.
# Uses information from recorded system libraries (calls to qt_find_package).
function(_qt_internal_sbom_add_recorded_system_libraries)
get_property(recorded_targets GLOBAL PROPERTY _qt_internal_sbom_recorded_system_library_targets)
get_property(consumed_targets GLOBAL PROPERTY _qt_internal_sbom_consumed_system_library_targets)
set(unconsumed_targets "${recorded_targets}")
set(generated_package_names "")
message(DEBUG
"System libraries that were marked consumed "
"(some target linked to them): ${consumed_targets}")
message(DEBUG
"System libraries that were recorded "
"(they were marked with qt_find_package()): ${recorded_targets}")
foreach(target IN LISTS consumed_targets)
# Some system targets like qtspeech SpeechDispatcher::SpeechDispatcher might be aliased,
# and we can't set properties on them, so unalias the target name.
set(target_original "${target}")
_qt_internal_dealias_target(target)
get_property(args GLOBAL PROPERTY
_qt_internal_sbom_recorded_system_library_options_${target})
get_property(package_name GLOBAL PROPERTY
_qt_internal_sbom_recorded_system_library_package_${target})
set_property(GLOBAL PROPERTY _qt_internal_sbom_recorded_system_library_target_${target} "")
set_property(GLOBAL PROPERTY _qt_internal_sbom_recorded_system_library_options_${target} "")
set_property(GLOBAL PROPERTY _qt_internal_sbom_recorded_system_library_package_${target} "")
# Guard against generating a package multiple times. Can happen when multiple targets belong
# to the same package.
if(sbom_generated_${package_name})
continue()
endif()
# Automatic system library sbom recording happens at project root source dir scope, which
# means it might accidentally pick up a qt_attribution.json file from the project root,
# that is not intended to be use for system libraries.
# For now, explicitly disable using the root attribution file.
list(APPEND args NO_CURRENT_DIR_ATTRIBUTION)
list(APPEND generated_package_names "${package_name}")
set(sbom_generated_${package_name} TRUE)
_qt_internal_extend_sbom(${target} ${args})
_qt_internal_finalize_sbom(${target})
list(REMOVE_ITEM unconsumed_targets "${target_original}")
endforeach()
message(DEBUG "System libraries that were recorded, but not consumed: ${unconsumed_targets}")
message(DEBUG "Generated SBOMs for the following system packages: ${generated_package_names}")
# Clean up, before configuring next repo project.
set_property(GLOBAL PROPERTY _qt_internal_sbom_consumed_system_library_targets "")
set_property(GLOBAL PROPERTY _qt_internal_sbom_recorded_system_library_targets "")
endfunction()

View File

@ -62,10 +62,7 @@ function(__qt_internal_set_link_order_matters target link_order_matters)
message(FATAL_ERROR "Unable to set _qt_link_order_matters flag. ${target} is not a target.")
endif()
get_target_property(aliased_target ${target} ALIASED_TARGET)
if(aliased_target)
set(target "${aliased_target}")
endif()
_qt_internal_dealias_target(target)
if(link_order_matters)
set(link_order_matters TRUE)
@ -101,10 +98,7 @@ endfunction()
function(__qt_internal_check_cmp0099_available)
set(platform_target ${QT_CMAKE_EXPORT_NAMESPACE}::Platform)
get_target_property(aliased_target ${platform_target} ALIASED_TARGET)
if(aliased_target)
set(platform_target "${aliased_target}")
endif()
_qt_internal_dealias_target(platform_target)
__qt_internal_get_cmp0099_genex_check(cmp0099_check)
set_target_properties(${platform_target} PROPERTIES
@ -224,10 +218,7 @@ function(__qt_internal_collect_object_libraries_recursively out_var target initi
set(lib "${CMAKE_MATCH_1}")
endif()
if(TARGET ${lib})
get_target_property(aliased_target ${lib} ALIASED_TARGET)
if(aliased_target)
set(lib ${aliased_target})
endif()
_qt_internal_dealias_target(lib)
if(${lib} IN_LIST processed_object_libraries)
continue()
@ -424,3 +415,109 @@ function(_qt_internal_warn_about_example_add_subdirectory)
)
endif()
endfunction()
# Mark source files as generated.
#
# This sets `GENERATED` property to TRUE, along with other Qt relevant properties,
# e.g. `SKIP_LINTING`.
#
# Synopsis
#
# _qt_internal_set_source_file_generated(SOURCE <src1> ...
# [CONFIGURE_GENERATED]
# [SKIP_AUTOGEN]
# [DIRECTORY <dirs> ...]
# [TARGET_DIRECTORY <targets> ...]
# )
#
# Arguments
#
# `SOURCES`
# Source files that are generated.
#
# Equivalent to `set_source_files_properties(<files>)`.
#
# `DIRECTORY`
# Equivalent to `set_source_files_properties(DIRECTORY)`.
#
# `TARGET_DIRECTORY`
# Equivalent to `set_source_files_properties(TARGET_DIRECTORY)`.
#
# `SKIP_AUTOGEN`
# Set SKIP_AUTOGEN property to True as well.
#
# `CONFIGURE_GENERATED`
# Files are generated with `configure_file`.
# Does not set `GENERATED TRUE` property. This is needed to avoid removing the file when
# running the clean target.
function(_qt_internal_set_source_file_generated)
set(option_args
SKIP_AUTOGEN
CONFIGURE_GENERATED
)
set(single_args "")
set(multi_args
SOURCES
DIRECTORY
TARGET_DIRECTORY
)
cmake_parse_arguments(PARSE_ARGV 0 arg
"${option_args}" "${single_args}" "${multi_args}"
)
# Parse required variables
if(NOT arg_SOURCES AND QT_FEATURE_developer_build)
message(WARNING
"Unexpected call _qt_internal_set_source_file_generated with empty `SOURCES`."
)
endif()
# Prepend again the appropriate keywords to pass to `set_source_files_properties`
if(arg_DIRECTORY)
list(PREPEND arg_DIRECTORY DIRECTORY)
endif()
if(arg_TARGET_DIRECTORY)
list(PREPEND arg_TARGET_DIRECTORY TARGET_DIRECTORY)
endif()
# Construct the properties list
set(properties "")
if(NOT arg_CONFIGURE_GENERATED)
list(APPEND properties
GENERATED TRUE
)
endif()
if(arg_SKIP_AUTOGEN)
list(APPEND properties
SKIP_AUTOGEN TRUE
)
endif()
# Add SKIP_LINTING if possible. We do not add it unconditionally here to avoid
# confusion when CMake ignores this variable.
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.27" AND NOT QT_FEATURE_lint_generated_code)
list(APPEND properties
SKIP_LINTING TRUE
)
endif()
set_source_files_properties(${arg_SOURCES}
${arg_DIRECTORY}
${arg_TARGET_DIRECTORY}
PROPERTIES ${properties}
)
endfunction()
# Get the real target checking for ALIASED_TARGET
function(_qt_internal_get_real_target out_var target)
get_target_property(aliased_target "${target}" ALIASED_TARGET)
if(aliased_target)
set(${out_var} "${aliased_target}" PARENT_SCOPE)
else()
set(${out_var} "${target}" PARENT_SCOPE)
endif()
endfunction()
# Helpful shortcut to `_qt_internal_get_real_target` if we just need to dealias
function(_qt_internal_dealias_target target_var)
_qt_internal_get_real_target(${target_var} ${${target_var}})
set(${target_var} "${${target_var}}" PARENT_SCOPE)
endfunction()

View File

@ -68,7 +68,10 @@ is not specified")
# It's necessary to call actual test inside 'cmd.exe', because 'execute_process' uses
# SW_HIDE to avoid showing a console window, it affects other GUI as well.
# See https://gitlab.kitware.com/cmake/cmake/-/issues/17690 for details.
set(extra_runner "cmd /c")
#
# Run the command using the proxy 'call' command to avoid issues related to invalid
# processing of quotes and spaces in cmd.exe arguments.
set(extra_runner "cmd /c call")
endif()
if(arg_PRE_RUN)
@ -118,3 +121,35 @@ endfunction()
function(_qt_internal_test_batch_target_name out)
set(${out} "test_batch" PARENT_SCOPE)
endfunction()
# Create a *_check target of the ctest execution for alternative execution
# Arguments:
# : CTEST_TEST_NAME: (default: ${testname})
# name of the ctest test used
function(_qt_internal_make_check_target testname)
set(options "")
set(singleOpts CTEST_TEST_NAME)
set(multiOpts "")
cmake_parse_arguments(PARSE_ARGV 1 arg
"${options}" "${singleOpts}" "${multiOpts}"
)
if(NOT arg_CTEST_TEST_NAME)
set(arg_CTEST_TEST_NAME ${testname})
endif()
set(test_config_options "")
get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG)
if(is_multi_config)
set(test_config_options -C $<CONFIG>)
endif()
# Note: By default the working directory here is CMAKE_CURRENT_BINARY_DIR, which will
# work as long as this is called anywhere up or down the path where the equivalent
# `add_test` is called (not down a different branch path).
add_custom_target(${testname}_check
VERBATIM
COMMENT "Running ctest -V -R \"^${arg_CTEST_TEST_NAME}$\" ${test_config_options}"
COMMAND
"${CMAKE_CTEST_COMMAND}" -V -R "^${arg_CTEST_TEST_NAME}$" ${test_config_options}
)
endfunction()

View File

@ -139,7 +139,7 @@ macro(_qt_internal_execute_proccess_in_qt_env execute_process_args_var)
# We avoid escaping issues this way.
execute_process(${${execute_process_args_var}})
if(CMAKE_HOST_WIN32)
set(ENV{PATH} "${path_backup}")
set(ENV{PATH} "${_qt_internal_execute_proccess_in_qt_env_path_backup}")
unset(_qt_internal_execute_proccess_in_qt_env_path_backup)
endif()
endmacro()

View File

@ -153,9 +153,16 @@ function(__qt_internal_walk_libs
lib "${lib}")
endwhile()
# Skip static plugins.
# Skip processing static plugins.
# There are some abuses of this genex marker, because the more generic one below did
# not exist yet.
set(_is_plugin_marker_genex "\\$<BOOL:QT_IS_PLUGIN_GENEX>")
if(lib MATCHES "${_is_plugin_marker_genex}")
# Skip any genex expressions that contain the marker. Useful in cases like processing
# link expressions for prl file generation, where some link expressions should be
# skipped either because they don't make sense or they are handled differently.
set(_is_skip_marker_genex "\\$<BOOL:QT_SKIP_WALK_LIBS_PROCESSING>")
if(lib MATCHES "${_is_plugin_marker_genex}" OR lib MATCHES "${_is_skip_marker_genex}")
continue()
endif()
@ -172,10 +179,24 @@ function(__qt_internal_walk_libs
if(lib MATCHES "^\\$<TARGET_OBJECTS:")
# Skip object files.
continue()
elseif(lib MATCHES "^\\$<LINK_ONLY:(.*)>$")
set(lib_target ${CMAKE_MATCH_1})
else()
set(lib_target ${lib})
endif()
set(lib_target "${lib}")
# Unwrap targets like $<LINK_ONLY:$<BUILD_INTERFACE:Qt6::CorePrivate>>
while(lib_target
MATCHES "^\\$<(LINK_ONLY|BUILD_INTERFACE|BUILD_LOCAL_INTERFACE):(.*)>$")
set(lib_target "${CMAKE_MATCH_2}")
endwhile()
# If one of the values is "$<LINK_ONLY:$<BUILD_LOCAL_INTERFACE:Foo>>", this will be
# exported by cmake as "$<LINK_ONLY:>", which will become an empty value after the
# unwrapping above.
# In that case, skip the processing. Otherwise in some weird unknown conditions,
# CMake might consider the empty name to be a valid target, and cause errors further
# down.
if("${lib_target}" STREQUAL "")
continue()
endif()
# Skip CMAKE_DIRECTORY_ID_SEP. If a target_link_libraries is applied to a target
@ -240,10 +261,7 @@ function(__qt_internal_walk_libs
endif()
if(operation STREQUAL "promote_3rd_party_global")
set(lib_target_unaliased "${lib_target}")
get_target_property(aliased_target ${lib_target} ALIASED_TARGET)
if(aliased_target)
set(lib_target_unaliased ${aliased_target})
endif()
_qt_internal_dealias_target(lib_target_unaliased)
get_property(is_imported TARGET ${lib_target_unaliased} PROPERTY IMPORTED)

View File

@ -53,7 +53,7 @@ endfunction()
function(__qt_internal_get_emcc_recommended_version out_var)
# This version of Qt needs this version of emscripten.
set(QT_EMCC_RECOMMENDED_VERSION "3.1.56")
set(QT_EMCC_RECOMMENDED_VERSION "3.1.70")
set(${out_var} "${QT_EMCC_RECOMMENDED_VERSION}" PARENT_SCOPE)
endfunction()

Some files were not shown because too many files have changed in this diff Show More