71055 Commits

Author SHA1 Message Date
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
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