Commit Graph

63854 Commits

Author SHA1 Message Date
Thiago Macieira
9aaf12ebaa Work around GCC 13's bogus "out of bounds" check to QByteArray::_empty
Nothing here is empty and even if anything were, QStringBuilder properly
handles empty strings.

In static member function ‘static void QConcatenable<QByteArrayView>::appendTo(QByteArrayView, char*&)’,
    inlined from ‘static void QConcatenable<QStringBuilder< <template-parameter-1-1>, <template-parameter-1-2> > >::appendTo(const type&, T*&) [with T = char; A = QByteArrayView; B = const char (&)[20]]’ at qstringbuilder.h:398:37,
    inlined from ‘T QStringBuilder< <template-parameter-1-1>, <template-parameter-1-2> >::convertTo() const [with T = QByteArray; A = QByteArrayView; B = const char (&)[20]]’ at qstringbuilder.h:117:54,
    ...
qstringbuilder.h:178:19: error: ‘void* memcpy(void*, const void*, size_t)’ forming offset [1, 5] is out of the bounds [0, 1] of object ‘QByteArray::_empty’ with type ‘const char’ [-Werror=array-bounds=]

QStringBuilder::convertTo() creates the target as
        const qsizetype len = QConcatenable< QStringBuilder<A, B> >::size(*this);
        T s(len, Qt::Uninitialized);

We know len can't be zero because GCC is complaining about a memcpy()
when the offset has been changed from 0, meaning QByteArray was given a
non-zero size and therefore its data pointer is not &QByteArray::_empty.

Fixes: QTBUG-116763
Pick-to: 6.5 6.6
Change-Id: I85599ea5ca7a4b79a8bbfffd178af437984080fb
Reviewed-by: Shawn Rutledge (away) <shawn.rutledge@qt.io>
2023-10-15 18:36:25 -07:00
Thiago Macieira
eedb715ece qTzName: suppress warning that tzname is deprecated with UCRT
Use the pre-existing MSVC code path, which uses UCRT.

warning: 'tzname' is deprecated: Only provided for source compatibility; this variable might not always be accurate when linking to UCRT. [-Wdeprecated-declarations]

Pick-to: 6.6
Change-Id: I8f3ce163ccc5408cac39fffd178dc618f1a8f034
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
2023-10-15 18:36:04 -07:00
Samuel Gaist
c7eac23d96 doc: improve property example slot
The current example shows a minimal implementation. However, neither
this example nor the documentation explains what happens without the
guard. Although it's not mandatory, the large majority of the time
it's a good practice to have it. This patch improves this part.

Change-Id: I411a9d66bd7d8ba16aac87e28b5cab219fd71a5d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2023-10-14 20:19:56 +00:00
Pavel Dubsky
3373247873 Introduce QComObject base class
This base class implementation for COM objects provides IUnknown
interface implementation with reference counting which will allow to
keep all this functionality and implementation in the same place.

Pick-to 6.6 6.5

Change-Id: I8ec597b1040ac33295317e06338ffdcb61b78f85
Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-13 21:29:48 +02:00
Kai Köhne
cb841b449a Doc: Improve documentation for qInstallMessageHandler()
Mention that QtMessageHandler needs to be reentrant,
as well as other caveats. Mention QLoggingCategory,
so people do know that they don't have to necessarily
implement their own handler to filter messages (and that
not all messages reach the handler). Also mention
qFormatLogMessage().

Finally, give a more useful example for a custom
message handler that logs to a file. Note that the example
leaks a file handle at exit, but that is arguably not that
bad.

Pick-to: 6.5 6.6
Change-Id: I5be44167b266c9bbdbb0e94806bb024c9b352a32
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-13 20:39:55 +02:00
Orkun Tokdemir
7a87149c25 CMake: Update timestamp file for multi-Config builds
Since https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8840 is
merged, the timestamp file for {target}_json_file.txt should be updated
for `multi-config` builds too.

A possible error message before this commit when `qt6_extract_metatypes()` is called with a newer
or equal version than `3.28` `CMake` and `Ninja Multi-Config`.

```
ninja: error: 'src/corelib/Core_autogen/timestamp', needed by 'src/corelib/meta_types/Core_json_file_list.txt', missing and no known rule to make it
```

Amends 8042bfba47305352627d910930e52da496904c17

Pick-to: 6.2 6.5 6.6
Change-Id: Ib404bd058d5f4c75501fb714c2ad9608d6852822
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-10-13 19:57:29 +02:00
Mårten Nordheim
7fd0397c66 tst_http2: Use QCOMPARE for the nRequests check
Makes it easier to get an idea of what went wrong

Change-Id: Idace20ecf008fa906780881b62ed44ac36751123
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-10-13 19:57:29 +02:00
Mikolaj Boc
1c8b4ac67b Fix problem with queued signals on main thread
Queued signals from main thread were not handled if enqueued on
a different thread. This is because qt_jspi_can_resume_js was
called on a thread (worker), where the Module object does not have
the property used for determining whether JSPI is suspended.

Change-Id: Icbc4dbfcf46c1091eb71b23c7de50760c8a339ae
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-10-13 19:36:34 +02:00
Christian Ehrlicher
262031d364 Fusion style/QProgressBar: fix High-DPI issues
Fix some issues for QProgressBar with fusion style:
 - no progress text was shown in vertical mode
 - the color change for the text was not correct in rtl mode
 - the two rounded rects were not drawn correctly in some modes
Also simplify the code by also using a QTransform for rtl mode and not
only for the vertical mode.

Fixes: QTBUG-117904
Change-Id: I1dd89daf34e8808417750f2ca714252afdab1416
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2023-10-13 18:23:44 +02:00
Mårten Nordheim
fe653b70ae QNetworkInfo[NetworkManager]: Mark invalid if unconnected
On some configs (e.g. using Snap) the NetworkManager service is not
available without some manifest or similar. In this case, the
_interface_ we have is still valid but we can't connect to the
service. So we need to mark the interface as invalid in this case, so
that we can avoid trying to use this plugin.

Pick-to: 6.6 6.5
Fixes: QTBUG-117490
Change-Id: I3c5ebb492f9ca4dfdf4353d77705ba993279eb69
Reviewed-by: Ilya Fedin <fedin-ilja2010@ya.ru>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-10-13 18:00:37 +02:00
Alexandru Croitor
8170e9e85a CMake: Fix Gui package to auto look up IntegrityPlatformGraphics v2
The previous attempt to record a dependency on the
IntegrityPlatformGraphics target for the Gui target was insufficient.

Aside from a qt_find_package(PROVIDED_TARGETS) call, we also need to
use qt_internal_extend_target(Gui PRIVATE IntegrityPlatformGraphics)
to ensure the dependency is written into the Qt6GuiDependencies.cmake
file.

Replace the target_link_libraries call with qt_internal_extend_target,
and remove the qt_find_package all together. A qt_find_package call
in src/gui/configure.cmake already exists, so the one in
CMakeLists.txt is redundant and can be removed.

Finally the
  qt_internal_extend_target(Gui PRIVATE IntegrityPlatformGraphics)
call will also result in a
  target_link_libraries(Gui INTERFACE
  $<LINK_ONLY:IntegrityPlatformGraphics::IntegrityPlatformGraphics>)
because Gui is a static library when building on Integrity, so the
transitive requirement will still be passed along to user projects.

Amends c03eb94c8a
Amends 8116fdde1c

Pick-to: 6.6
Fixes: QTBUG-118051
Task-number: QTBUG-102883
Change-Id: Ic962df94a20071d3f2459e705dbafaca0319a638
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-10-13 18:00:37 +02:00
Luca Di Sera
31eb5e238b Doc: Add missing return type to QDBusReply::value
When QDoc reads an `\fn` command it saves it to a file to parse it with
Clang, with the objective of using the produced AST to perform certain
sanity checks on the documented element.

Generally, `\fn` commands that do not represent correct C++ code are
accepted as long as Clang is still able to build an AST Node that QDoc
can work with, not resulting in any issue in the output documentation.

For example, an `\fn` that doesn't state a return type might be able to
be parsed correctly enough by Clang to produce a sensible Node for the
function that QDoc is interested into.

The documentation for `QDBusReply::value` make
use of this possibility by not stating a return type.

Up to Clang 15 this was not an issue, and a correct-enough AST was
produced when the `\fn` commands for those methods were parsed.

On Clang 16, Clang chokes on the missing return type, being unable to
recognize the function definition and produce an AST that QDoc can work
with.
This has the effect of losing those documented element in the output
documentation.

To avoid the issue, a return type is now added to the relevant `\fn`
commands.

Task-number: QTBUG-111580
Change-Id: Ia70404c7ad548cb1e144bec99943cf72c990bb83
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2023-10-13 18:00:37 +02:00
Luca Di Sera
6e7f7f6f48 Doc: Add missing return type to QRgbaFloat::fromRgba*
When QDoc reads an `\fn` command it saves it to a file to parse it with
Clang, with the objective of using the produced AST to perform certain
sanity checks on the documented element.

Generally, `\fn` commands that do not represent correct C++ code are
accepted as long as Clang is still able to build an AST Node that QDoc
can work with, not resulting in any issue in the output documentation.

For example, an `\fn` that doesn't state a return type might be able to
be parsed correctly enough by Clang to produce a sensible Node for the
function that QDoc is interested into.

The documentation for the various `QRgbaFloat::fromRgba*` make use of
this possibility by not stating a return type.

Up to Clang 15 this was not an issue, and a correct-enough AST was
produced when the `\fn` commands for those methods were parsed.

On Clang 16, Clang chokes on the missing return type, being unable to
recognize the function definition and produce an AST that QDoc can work
with.
This has the effect of losing those documented element in the output
documentation.

To avoid the issue, a return type is now added to the relevant `\fn`
commands.

Task-number: QTBUG-111580
Change-Id: Id9d8a713caf7d6cbb4d2de1040ce5ea5092f7b14
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2023-10-13 18:00:37 +02:00
Anton Kudryavtsev
2dce499561 qtextformat: port while loops to range for
to improve readability

Change-Id: I11b44154d8db35b93a887bb4797af9a985749f24
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-10-13 18:24:01 +03:00
Mitch Curtis
b90b624ce0 QWindowsTheme: only set inactive accent color to Window if not set
Otherwise it incorrectly changes to a white-ish color when the window
becomes inactive, when native apps keep the accent color.

Fixes: QTBUG-116826
Change-Id: I3837e7ca93a494e60dbe5f1b7f8607b3dd16d29e
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-10-13 20:12:27 +08:00
Luca Di Sera
11424b3f51 Doc: Add missing return type to QList/QVarLengthArray::assign
When QDoc reads an `\fn` command it saves it to a file to parse it with
Clang, with the objective of using the produced AST to perform certain
sanity checks on the documented element.

Generally, `\fn` commands that do not represent correct C++ code with are
accepted as long as Clang is still able to build an AST Node that QDoc
can work with, not resulting in any issue in the output documentation.

For example, an `\fn` that doesn't state a return type might be able to
be parsed correctly enough by Clang to produce a sensible Node for the
function that QDoc is interested into.

The documentation for the various overloads for QList::assign and
QVarLenghtArray::assign makes use of this possibility by not stating a
return type.

Up to Clang 15 this was not an issue, and a correct-enough AST was
produced when the `\fn` commands for those methods were parsed.

On Clang 16, Clang chokes on the missing return type, being unable to
recognize the function definition and produce an AST that QDoc can work
with.
This has the effect of losing those documented element in the output
documentation.

To avoid the issue, a return type is now added to the relevant `\fn`
commands.

Change-Id: Ic1434aaf71c39840c64ce04fbd503c4542dc4f42
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2023-10-13 14:12:27 +02:00
Mårten Nordheim
479c2add32 QNonContigByteDeviceThreadForwardImpl: NSDMI
Makes it clearer what members depend on arguments to the ctor. And
what the initial value of all the members are.

Change-Id: Ie1cd2361955053eaf4c4e6887d23ac245738288d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
2023-10-13 11:58:51 +02:00
Mårten Nordheim
5c7c44cf83 Http: don't try to send request on a closed socket
We have code in the protocolHandlers that tries to handle this case, but
if we have an error before we create protocolHandler (read: proxy
complains about something) we will assert in debug, or
deref nullptr in release.

Pick-to: 6.6 6.5 6.2
Change-Id: I4bde9c8af0fa96dc11f77ca4d4b5cb84c31b54fa
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-10-13 06:23:21 +00:00
Michał Łoś
9e93781b9c Remove --no-undefined for VxWorks Qt shared libs
Build system adds this flag to any module that it uses when built as a
shared library and not WASM.

VxWorks is specific in regards to type of applications:
 - static application, which do not use any dynamic libraries
 - dynamic application, which uses shared libraries, and as such needs
   to link against libdl.a

The latter is the only source of symbols related to dynamic loading and
thread local storage. This is an architectural decision, as application
is required to embed loading tools in itself (as opposed to Unix/Linux,
which contains dynamic loader which provides these symbols separately).
libdl.a is standard static library on VxWorks, compiled without PIC, and
as such can't be linked into shared library.

This results in compilation errors when building dynamic libraries which
use `thread_local`-related symbols, since these symbols will be
fulfilled at runtime (contained in executable which requires shared lib)
and are not available during linking.

Don't add `-Wl,--no-undefined` flag on VxWorks for Qt shared lib builds.

Task-number: QTBUG-115777
Change-Id: I47e5d68afcba2c3b4203e4c0beded2e18ea2563b
Reviewed-by: Pasi Petäjäjärvi <pasi.petajajarvi@qt.io>
2023-10-13 04:26:15 +02:00
Ahmad Samir
94a3914d3d QtWidgets: finally Q_FOREACH-free
These source files have been ported away from Q_FOREACH but weren't
blacklisted, so un-blacklist them by removing "#undef QT_NO_FOREACH",
and removing them from NO_PCH_SOURCES.

These are the last remnants of the Q_FOREACH blacklisting in QtWidgets.

Task-number: QTBUG-115803
Change-Id: Ib73d668687f64d39fa48397d75a0f342e525c1ad
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-13 00:54:57 +03:00
Ahmad Samir
8ce54407f2 QGestureManager: port Q_FOREACH to ranged-for [6/6]
These two QSetS are local to the function, the loop bodies don't modify
them but they can't be made const due to the way they're filled. So use
std::as_const and ranged-for.

Un-blacklist the file, by removing "#undef QT_NO_FOREACH", and removing
the source file from NO_PCH_SOURCES.

Change-Id: I49b852aa865b0321d3e2f617466557d77143a32b
Task-number: QTBUG-115803
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-13 00:54:54 +03:00
Ahmad Samir
2309b38a64 QGestureManager: port Q_FOREACH to ranged-for [5/6]
getGestureTargets() first parameter is a QSet created locally at the
call site in deliverEvents(); and the loop body doesn't change it.

Change-Id: I3484f7ecc9d85b22b45a123ccf75316d5316e031
Task-number: QTBUG-115803
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-13 00:54:52 +03:00
Ahmad Samir
cce946b3aa QGestureManager: port FOREACH to ranged-for, local const QSets [4/6]
Those QSetS are local to the function, make them const, proving that the
loop bodies didn't change them, and the copy Q_FOREACH took wasn't
needed.

Task-number: QTBUG-115803
Change-Id: Iec2fc31fc060c59760a84dc45baf8fa16f62eb6d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-13 00:54:50 +03:00
Ahmad Samir
a7d9ad9617 QGestureManager: port Q_FOREACH to ranged-for [3/6]
The "conflictedGestures" QHash is local to the function, and the code in
the loop body doesn't change it. The "gestures" QList (the value in the
QHash key/value pair) isn't changed in the loop (both the enclosing
for-loop and the for-loop iterating over the QList itself):
- the QGestureEvent constructor takes by const& so it couldn't have
  changed the QList

So use a const QList& instead of a copy.

Task-number: QTBUG-115803
Change-Id: I4d7f2f833fe0119b9c1ffa91b0cdba9561025382
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-13 00:54:48 +03:00
Ahmad Samir
3f94513670 QGestureManager: port to ranged-for [2/6]
The enclosing iterator-based loop: the loop body doesn't modify the
`m_objectGestures` QMap (the original loop was using const_iterators),
so port to ranged-for by using asKeyValueRange().

The foreach loop: the loop body doesn't modify the `gestures` QList, so
a simple port to ranged-for.

Task-number: QTBUG-115803
Change-Id: I92ba7ff6ef878d7e4b7115a8fab87e95a6d93182
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2023-10-13 00:54:45 +03:00
Ahmad Samir
a3a53cdde4 QGestureManager: port Q_FOREACH to ranged-for [1/6]
The loop doesn't modify the QHash while iterating over it, so use
std::as_const.

Drive by change: Use asKeyValueRange() to get a key/value pair:
- No need to allocate a QStringList to hold the keys
- Prevent double lookup which happened when hash.value(key) was used
  inside the loop body

Task-number: QTBUG-115803
Change-Id: Ic0473c0971089f6ca75d3397209fe1c909e975a1
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2023-10-13 00:54:43 +03:00
Ahmad Samir
4bfe6ea251 QWidgetRepaintManager: port Q_FOREACH to ranged-for
The loop body doesn't change the QHash, so use asKeyValueRange() and
ranged-for.

Un-blacklist the file, by removing "#undef QT_NO_FOREACH", and removing
the source file from NO_PCH_SOURCES.

Task-number: QTBUG-115803
Change-Id: I22924d2addeed75867edf9f6cac53f1c6f266dcc
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2023-10-13 00:54:38 +03:00
Marc Mutz
368ea559eb QSpan: add C++23 c{,r}{begin,end}()
It was weird that they were missing. Now that C++23 added them to
std::span, add them to QSpan, too.

Pick-to: 6.6
Change-Id: I4a9b1fdeda66bc7b133c8f7b3b269656e5faffa3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-12 21:38:54 +02:00
Marc Mutz
05888490db QSet: de-pessimize binary operators
Overload the binary QSet operators |, &, + and - for rvalue LHSs, so
chained operations like e.g. in qgesturemanager.cpp:

        QSet<QGesture *> endedGestures =
                finishedGestures + canceledGestures + undeliveredGestures + maybeToCanceledGestures;

become as efficient as chained op+= calls.

Make the operators hidden friends as a drive-by.

[ChangeLog][QtCore][QSet] The binary operators &, |, + and - are now
hidden friends, and chaining them has been made a lot more efficient.

Change-Id: I55d2247b11d088eb1ef88608f89d2bf9e1daeb58
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-12 21:38:54 +02:00
Marc Mutz
4a7c76d4a5 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: I3321cccdb41ce0ba6d8a709cea92427aba398254
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-10-12 21:38:54 +02:00
Christian Ehrlicher
0b6d2d9187 Widgets/QColumnView: use pmf-style connect in QColumnView
Follow-up patch for 39d486171b - don't
create a temporary container for the connections but add them directly
into the final one.

Task-number: QTBUG-117698
Change-Id: I6ea3b1a5a834f2581f3929cca13c53f47b8c9805
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-10-12 21:01:09 +02:00
Luca Di Sera
42bc1f9d27 Doc: Add missing return type to QPromise::emplaceResult/emplaceResultAt
When QDoc reads an `\fn` command it saves it to a file to parse it with
Clang, with the objective of using the produced AST to perform certain
sanity checks on the documented element.

Generally, `\fn` commands that do not represent correct C++ code are
accepted as long as Clang is still able to build an AST Node that QDoc
can work with, not resulting in any issue in the output documentation.

For example, an `\fn` that doesn't state a return type might be able to
be parsed correctly enough by Clang to produce a sensible Node for the
function that QDoc is interested into.

The documentation for `QPromise::emplaceResult/emplaceResultAt` make
use of this possibility by not stating a return type.

Up to Clang 15 this was not an issue, and a correct-enough AST was
produced when the `\fn` commands for those methods were parsed.

On Clang 16, Clang chokes on the missing return type, being unable to
recognize the function definition and produce an AST that QDoc can work
with.
This has the effect of losing those documented element in the output
documentation.

To avoid the issue, a return type is now added to the relevant `\fn`
commands.

Task-number: QTBUG-111580
Change-Id: I7d41fc52720ff8762bf2cce229969b7250e44754
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2023-10-12 20:24:55 +02:00
Assam Boudjelthia
3b6d288e3b Android: Simplify Qt for Android hierarchy, less Java reflection!
This changes takes Qt for Android Java code away from the Delegate
classes that uses heavily Java reflection to invoke Activity/Service
calls and overrides. So instead of that, now, we have a QtActivityBase
and a QtServiceBase classes which handle the override logic needed for
Qt directly without reflection.

These Base classes extend Android's Activity and Service directly, and
are inside the internal Qt android package (under Qt6Android.jar).

For example, to handle onConfigurationChanged, instead of the current
way where we need this in QtActivityDelegate:

 public void onConfigurationChanged(Configuration configuration)
 {
     try {
         m_super_onConfigurationChanged.invoke(m_activity, configuration);
     } catch (Exception e) {
         e.printStackTrace();
     }
         handleUiModeChange(configuration.uiMode &
Configuration.UI_MODE_NIGHT_MASK);
 }

And then this in QtActivity:

 @Override
 public void onConfigurationChanged(Configuration newConfig)
     {
         if (!QtLoader.invokeDelegate(newConfig).invoked)
             super.onConfigurationChanged(newConfig);
    }
    public void super_onConfigurationChanged(Configuration newConfig)
    {
        super.onConfigurationChanged(newConfig);
    }

And having to keep it's Method handles around and then use Java
reflection
to call the override behavior done by Qt and the superclass methods.

instead of that, we can do it now in QtActivityBase like:

 @Override
 public void onConfigurationChanged(Configuration newConfig)
 {
     super.onConfigurationChanged(newConfig);
     handleUiModeChange(newConfig.uiMode &
Configuration.UI_MODE_NIGHT_MASK);
 }

Then, we would still have our user facing QtActivity class which extends
QtActivityBase and benefit from the same implementation of Qt logic done
in the base class.

An additional benefit to this approach is that now QtActivity will be
very lightweight and doesn't need to have all the boilerplate code as
before.

[ChangeLog][Android] Simplify Qt for Android public bindings
(QActivity, QtService and QtApplication) by implementing base
classes which use the delegate implementions directly and avoid
reflection.

Task-number: QTBUG-115014
Task-number: QTBUG-114593
Change-Id: Ie1eca74f989627be4468786a27e30b16209fc521
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2023-10-12 19:16:47 +03:00
Juha Vuolle
beac5a6d72 QJniObject minor doc typo fix
Change-Id: Ife7ec986fd8033f3fda4b1c53b23f4bc3d3ac97b
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-12 17:12:04 +03:00
Juha Vuolle
6ac6c9452c Android: remove unnecessary static_cast
Change-Id: Id52b6ba74ee203118287745e52e90c5b36b66cc5
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-10-12 17:12:04 +03:00
Juha Vuolle
c0bc0d0643 Android: fix double-freeing of a global references on app exit
The m_activityObject and m_serviceObjects are no longer plain
jobjects. Instead they are constructed with a jobject.
The constructor makes it a global ref, which the destructor
then frees. The destruction happens when the stdlib exit()
is called.

However, since the terminateQt() function already had released the
global ref, the destruction of the objects crashes the
application with a JNI APPLICATION ERROR in Android logs.

In addition since the the code only ever freed the reference to
a reference, the actual reference was leaked.

Change-Id: I6bb637dba2de59e89436685a9d63950d36438fa5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-10-12 17:12:04 +03:00
Assam Boudjelthia
4102db752e Android: extract various constants into one common class
Various constant keys were duplicated in QtActivityDelegate,
QtServiceDelegate and QtLoader classes, and this de-duplicates that.

Task-number: QTBUG-115014
Task-number: QTBUG-114593
Change-Id: I3479fbb58293b26b7625f8653289c6b6d987a59f
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2023-10-12 12:00:01 +03:00
Assam Boudjelthia
d9845e2ac8 Android: Clean QtActivity and QtService from uneccessary overrides
Following the previous change in the chain, this removes override calls
that have no implementation under Qt Delegates, so they can be removed
and
the default behavior would persist.

Task-number: QTBUG-115014
Task-number: QTBUG-114593
Change-Id: Ia7c76e9b56c63cba935cb3d2ae3b6260d3462e51
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2023-10-12 11:59:55 +03:00
Assam Boudjelthia
1da7acd93d Android: remove overrides for uneccessary and deprecated methods
Those overrides are deprecated and will print a warning during Gradle
build, moreover, these calls don't have any implementation by Qt that's
being triggered by the Qt Delegates classes, so they don't need to be
kept in the Activity/Service main classes' implementations.

Task-number: QTBUG-115014
Task-number: QTBUG-114593
Change-Id: If0c241206652c1a52e2396a24ec7ab63236e6308
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2023-10-12 11:59:47 +03:00
Assam Boudjelthia
90b3b17545 Android: remove uneccessary calls to QtNative from QtActivity
These forward calls to QtNative don't need to be present inside the
QtActivity implementation, all those calls are invoked by the Delegate
classes.

Task-number: QTBUG-115014
Task-number: QTBUG-114593
Change-Id: Id1bfa694687af3edc4e9b82b09cf13e1f8eba1de
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2023-10-12 11:59:38 +03:00
Assam Boudjelthia
d1760bc810 Android: Simplify the user facing Java bindings
Move QtLoader classes outside of the bindings package and into
the internal Android Java package (Qt6Android.jar that is), to simplify
Qt for Android project templates. This is because QtLoader classes are
used to trigger Qt libs loading and the users don't need to necessarily
know about it or find it in the project's source files.

The classes in question: QtLoader, QtActivityLoader, and
QtServiceLoader.

Task-number: QTBUG-115014
Task-number: QTBUG-114593
Change-Id: I61f68abf6ee83fc45bc47ed9af7457db4f7deabc
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2023-10-12 11:59:32 +03:00
Alexandru Croitor
c03eb94c8a CMake: Fix Gui package to auto look up IntegrityPlatformGraphics
When building non-qtbase tqtc repos in CI, we don't load a lot of
Plugin Config files in static builds due to project names having a
tqtc- prefix. This is similar to the issue and workaround that was
done in 4c6292686259e4e232f29cb6fd6c79065e9fa96d for qtserialport.

The specific issue here is the following error:

CMake Error at Qt6Gui/Qt6GuiTargets.cmake:61 (set_target_properties):
  The link interface of target "Qt6::Gui" contains:

    IntegrityPlatformGraphics::IntegrityPlatformGraphics

  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.

Call Stack (most recent call first):
  /home/qt/work/install/target/lib/cmake/Qt6Gui/Qt6GuiConfig.cmake:52
   (include)
  /home/qt/work/install/target/lib/cmake/Qt6/Qt6Config.cmake:157
  (find_package)
  CMakeLists.txt:15 (find_package)

To work around the issue, explicitly record a dependency on the
IntegrityPlatformGraphics target for Gui when building on INTEGRITY.

The underlying issue is sadly still not fixed.

Change-Id: I9a9cff05d036f224aab8083ad6bc8b8e568abd8b
Pick-to: 6.6
Task-number: QTBUG-102883
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
2023-10-12 10:55:28 +02:00
Mitch Curtis
303d991136 Allow QPalettePrivate to be used outside of qpalette.cpp
We need access to bitPosition in order to check if a role was set.

This fixes the following build error:

[...] qwindowstheme.cpp(1150): error C2220: the following warning is treated as an error
[...] qwindowstheme.cpp(1150): warning C4506: no definition for inline function 'QPalette::ResolveMask QPalettePrivate::bitPosition(QPalette::ColorGroup,QPalette::ColorRole)'

Amends 417878904b.

Task-number: QTBUG-116826
Change-Id: I815c7e961198ab93b6ed6132badc2ec693522472
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2023-10-12 15:31:32 +08:00
Christian Ehrlicher
d70b873c37 QSqlDatabase: check if QCoreApplication::instance() exists
Check if QCoreApplication::instance() and print a warning if not instead
creating and assertion later on.

Fixes: QTBUG-117621
Change-Id: Iffb4f7097edbbaf19cb584bff6e5ba1535bf88a0
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-10-12 06:16:46 +02:00
Marc Mutz
9a0ae6c13b QSpan: remove a stale static constexpr extent from a base class
It's not needed, and might trigger -Wshadow on some compilers. Only
the public QSpan class has the `extent` static data member, everything
else uses the template argument, `E`, directly.

Amends f82cf6333e.

Pick-to: 6.6
Change-Id: If378119aff1e352d1e90854b570720444cd532a0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2023-10-12 00:20:32 +02:00
Michael Weghorn
0699ef1301 a11y atspi: Update text-attribute links
The previous ones no longer lead to the
corresponding documentation.

Pick-to: 6.6 6.5
Change-Id: I3f56ad71fa3f936898a25f20f718c7f65a0385a2
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-10-11 22:20:25 +00:00
Anton Kudryavtsev
a83a818791 QTextDocumentPrivate::plainText: simplify code
Use QSV more to avoid manual memcpy
Also port loop to range-based for

Change-Id: I06f4b424853a4b3ee245c66ccc650d87740e2cb8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-10-12 00:44:56 +03:00
Thiago Macieira
0f0371c830 Remove Qt_6_PRIVATE_API ELF version from a symbol used by QFuture::then()
QFuture::then() uses QtPrivate::Continuation::create(), which in turn
uses private API from an inline function:

    f->d.setContinuation(ContinuationWrapper(std::move(continuation)), fi.d);

f->d is QFutureInterfaceBase (a public class), but its setContinuation()
takes QFutureInterfaceBasePrivate by pointer. Our ELF versioning scripts
mark everything that uses that class as private, resulting in:

 4806: 0000000000287d70    365 FUNC    GLOBAL PROTECTED     16 _ZN20QFutureInterfaceBase15setContinuationESt8functionIFvRKS_EEP27QFutureInterfaceBasePrivate@@Qt_6_PRIVATE_API

This commit adds an exception for this symbol, causing it to go back to
the regular "Qt_6" ELF version:

 5629: 00000000003d6a16    366 FUNC    GLOBAL PROTECTED     16 _ZN20QFutureInterfaceBase15setContinuationESt8functionIFvRKS_EEP27QFutureInterfaceBasePrivate@@Qt_6

This solution can probably be cleaned up a bit by moving the marker into
the header files parsed by syncqt, so they follow code motion without
having to remember to update the CMakeLists.txt. That requires some
surgery with syncqt, so not suitable for cherry-picking.

As a drive-by, fix the target_type check
for the _qt_extra_linker_script_content genex property

Fixes: QTBUG-117514
Pick-to: 6.6
Change-Id: I85599ea5ca7a4b79a8bbfffd178b92e73dbe11de
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-10-11 22:06:20 +02:00
Ahmad Samir
042c38379f tst_Gestures: compile with QT_NO_FOREACH [2/2]
The loops are iterating over local const containers, so use ranged-for.

Remove '#undef QT_NO_FOREACH'.

Task-number: QTBUG-115839
Change-Id: I252f048e3c469bf9bb34cb0756ccbd57571fd886
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-11 23:06:20 +03:00
Ahmad Samir
e48e2b3b4a tst_Gestures: compile with QT_NO_FOREACH [1/2]
GestureWidget::ignoredGestures QSet:
- elements are inserted in the container in a top-level test function,
  then a CustomEvent is constructed and sendCustomGesture() is called,
  which sends the events, invoking the GestureWidget::event() overload,
  the latter iterates over the container, thus the container isn't
  changed while it's being iterated over, because the code can't recurse
  into the top-level test function and that's where the container is
  modified later on (by inserting or by calling widget.reset() which
  clears the container)
- the loop body doesn't change the container

So use ranged-for and std::as_const.

The same logic applies to the GestureItem::ignoredGestures QSet.

Task-number: QTBUG-115839
Change-Id: Icf95e90a8af5aa7e947035704121557494afc326
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-11 23:06:20 +03:00