Commit Graph

1458 Commits (152153cb111db1bbd42e94f27712bbc39accf310)

Author SHA1 Message Date
Volker Hilsheimer 34a41d83d8 QTranslator: rewrite loadLocale test, include failing cases
Add test coverage for the bug reported in QTBUG-124898 with
QEXPECT_FAIL to document the failure in our truncation logic in
QTranslator.

The attempted fix in 9a11273b745a30cebb5cd648c89eb224e9704492 then
introduced QTBUG-129434, as we ignored the order of languages reported
by the system locale. Add a test case for that, and use a QSystemLocale
subclass inspired by the QLocale unit test to override the system locale
with a specific one that supports multiple languages for this test.

Pick-to: 6.5
Task-number: QTBUG-124898
Task-number: QTBUG-129434
Change-Id: Iaae80d29e267fd3a2d14df0e73db27ba4c58b31a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 1f2ab46745af12e4776695c1b1a2523ac170368e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-10 11:21:41 +00:00
Fabian Kosmale dd5c13d09e QMetaObjectBuilder: Fix construction logic for enums
We need to put metatypes in the correct place; this is especially vital
starting with Qt 6.9, given that we need it to query it to figure out
whether we have a 64bit value or not.

As a drive-by, replace some ugly casting when constructing the meta-type
array with a call to QMetaType::iface.

Change-Id: I4b1f42f974e9f7a21f6aa4c87c3f8919f6965d6e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit d392d3b22c94f86fea50f26284bc9ac8b35f6851)
2024-10-09 08:48:13 +02:00
Santhosh Kumar be974c4855 Avoid referring to invalidated observer during binding evaluation
The property observer reference used during binding evaluation can
become invalidated as the container used to maintain the
the observer would invalidate the existing observers during its
resize, leading to referring to invalid memory.

Recognize that we do not need to store the observer, but only its
binding - the observer itself is not used later.

Therefore, change the PendingBindingObserverList to become a list of
QPropertyBindingPrivatePtr to avoid the issue.

Fixes: QTBUG-127596
Original-patch-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Pick-to: 6.5 6.2
Change-Id: I8c97721ca563083d6280194175f8a915dac2ff04
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
(cherry picked from commit 275202215376238bf414d5008d3c727085e58a4c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-07 17:26:50 +00:00
Kai Köhne e5c1d02ac6 Revert "QTranslator: fix loading order when loading from locale"
This reverts commit 9a11273b745a30cebb5cd648c89eb224e9704492.

Reason for revert: The fix tried to find a sensible order if
the same language is listed multiple times in QLocale::uiLanguages().
Anyhow, it breaks for lists where entirely different languages are listed. This needs more thought.

Fixes: QTBUG-129434
Pick-to: 6.7 6.5
Change-Id: I8c074cbf1ddc2ddf223ec09aef38dfc1ef7fc85f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit f3fc7b210f79e5eb427b0ff49c45c5d6d390fb34)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit a30c1bcd3c8b8eb4befeb254840224ca7bb52497)
2024-10-02 04:35:19 +00:00
Tim Blechmann c5a27f4cfe QObject: disconnect - document behavior with queued connections
QObject::disconnect does not cancel pending events. This can cause hard
to find bugs in application code, so we explicitly document and unit
test this behavior.

Task-number: QTBUG-127675
Change-Id: I5e94d60c27b9ce2dd2bceb832eb817b7eaa9cdcd
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 0681e720a9851f1873ce5a5f99b5567d2b418261)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-20 01:30:56 +00:00
Volker Hilsheimer d05438454f JNI: Add test coverage for a jobjectArray in a native function
Make sure this works as it should. The bug report/support request wants
to have a String[] parameter on the Java side, but then the C++ side can
not use jobjectArray (as that has "[Ljava/lang/Object;" as signature),
so use Object[] instead (which is one solution; the other is to use
QList<jstring> or (in 6.8) QStringList on the C++ side.

What's easy to miss is that the jobjectArray that we get is a local ref,
so we have to extend its lifetime by creating a QJniObject holding it as
a global reference. We can then create a QJniArray from that QJniObject
(without any type safety).

Task-number: QTBUG-128456
Change-Id: I1e03b811165f9bc5106324d39fb58114ee8cf398
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
(cherry picked from commit f9fd5870f7379103005839bc03543bb8f6da94c3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-02 18:10:38 +00:00
Marc Mutz f8b3c1f0a7 QChronoTimer: remove static singleShot() functions
They match what QTimer already provides these days, and we want to
minimize porting for users come Qt 7, so we don't want users to first
write QChronoTimer::singleShot() (because it exists) and then back to
QTimer::singleShot(); we want them to continue to use QTimer.

The only reason QChronoTimer is a separate class from QTimer is that
the latter has an int interval property and we can't just port it to
milli- or nanoseconds chrono types if we want users to actually access
the extra range or precision afforded by the chrono types. But that's
not an issue for the singleShot() static methods, as they never return
an object that could be asked for its timeout.

(No ChangeLog needed, as QChronoTimer is new in 6.8)

Found in API-review.

Fixes: QTBUG-128426
Change-Id: Ief8b7c8d25380c0e9e9c5c36c90ce34c147557ae
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 6e5eb082c934cb94c45f3e13b3f7c2deb2e7b2e6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-29 20:41:50 +00:00
Thiago Macieira 3d90aa1771 QDebug: cast the QFlags value to the right-sized unsigned type (2/2)
This applies to the Q_ENUM/Q_FLAGS overload of the debugging functions.
This prevents the sign-extension of a signed QFlags field when
converting to quint64, which would have resulted in 0x8000'0000 becoming
0xffff'ffff'8000'0000.

Right now, this is a no-op change because the implementation in
qt_QMetaEnum_flagDebugOperator() calls QMetaEnum::valueToKey(), which is
limited to int (32 bits).

Change-Id: I8a96935cf6c742259c9dfffd17e998c3a0538146
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 232ad339ab14965b6207d04a45d8d37ec3139558)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-12 09:43:38 +00:00
Marc Mutz 57ad4caa7b tst_QDeadlineTimer: fix format-string in toString() implementation
The second value (like the first) has type qint64 (aka long long), so
%d is wrong; need to use %lld instead.

Found while porting to std::snprintf() (qsnprintf() never actually got
the __attribute__((printf)), so compilers didn't warn).

Drive-by replace qAbs() with std::abs().

Amends 13c3558fe9.

Pick-to: 6.7 6.5
Change-Id: I9082a1aceefe8a5b04ad0d5725ab666e23483b29
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 61e4be2b62f9b6556a145f226850bf5e62d53e9d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-22 21:00:13 +00:00
Volker Hilsheimer 5797326b16 JNI: Constrain QJniArray::toContainer to compatible target containers
We can populate a container with the contents of the Java array as long
as the element types are convertible without narrowing (taking various
special cases into account, such as jstring to QString). The container
has to be either support emplace_back, or be a contiguous container
if a primitive element type.

The template helpers need to be in QJniArrayBase in order for qdoc to
accept the input.

Add test coverage, including static compile time tests.

Change-Id: Id9372deed5cf33446ee1969dc284a88991db2aee
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 8f04defa1e3973faec19a9cb1ab9bbf1ea7fb031)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-20 01:13:40 +00:00
Volker Hilsheimer c21612d246 JNI: Improve the constraint on QJniArray::fromContainer
We can create a QJniArray from any container that has a forward
iterator. A contiguous container can be used to optimize the code path,
as long as the element type is primitive (i.e. not an object type).

Fixes: QTBUG-126151
Change-Id: I21915f944d226d6d4f1113a54e5602ddc9cd727e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 71be7834e67216010dc74ed855dc7b513e302f1a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-20 01:13:35 +00:00
Volker Hilsheimer c4bd8a5492 JNI: clean up move semantics for QJniArray
Explicitly define (compiler-implemented) copy and move SMF's for
QJniArrayBase; we need to, as the destructor is declared, so without
them the compiler will implicitly convert an array to a QJniObject
and call that constructor.

Constrain the constructors and assignment operator from a QJniArray of
another type so that no narrowing conversion is allowed. Due to the
implicit conversion to QJniObject, we have to explicitly delete the
overload for narrowing conversions. Use the detector we have in
qobjectdefs_impl.h for that.

Make the detection helpers private, and add test coverage.

Change-Id: I1b2bb4435d52223567d20bb55ceb0d516e3b0b15
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit ebbf7b0fdf866190cd20e62d6b13c7c6808101da)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-20 01:13:28 +00:00
Volker Hilsheimer 43f0b1fcee QJniObject: specialize the QtJniTypes::Traits to treat it like jobject
It doesn't make a lot of sense to pass QJniObject instances into APIs,
but to be able to consistently treat QJniObject as an object type we
have to register it with the java/lang/Object signature.

Change-Id: Ic40e2676186bf327fa92764da51404985f74b565
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 82254fa836a21b5ec450a4ec7635e72403dded18)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-20 01:13:11 +00:00
Volker Hilsheimer 6c3513f514 QJniArray: implement operator-> for the iterator
The QJniArray doesn't store values, so at() always returns a temporary.
As we cannot hand out a pointer to a temporary, use a wrapper reference
struct that stores the value and implements operator->. It's all inline,
so we can move it out in the future to return mutable references, if we
ever want to enable write access to QJniArray elements.

Change-Id: I3962df6160db8c5b573d47ebb7975864f8ea7a8b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 3d5af4b912e60beb791f874c2dbfef5597b9aad7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-20 01:13:06 +00:00
Volker Hilsheimer 92b1923e31 JNI: clean up move and swap semantics in QJniObject
QJniObject is a value type with move semantics, but didn't provide swap,
so add it.
Make it safe to check a moved-from QJniObject for validity, and to
compare it with another QJniObject. As before, two invalid objects
compare as equal.

Change-Id: Ie08bb7c50da831f3e7e98e731e8ddbc0ebb3af78
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit 3e0c21691dd2be6911c417f4cbfaf54d10b4d634)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-13 23:00:24 +00:00
Volker Hilsheimer d9c38b66aa QJniArray: implement offset dereference operator
The last requirement for making the iterator random-access, so
change category type.

Based on review comments.

Task-number: QTBUG-126150
Change-Id: I617f38f92d0f9279781e62ea3ab1929dbf6a07cd
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit e4b2d7607c0243f2a7ca3f38f59e8532c543fcc7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-11 10:57:27 +02:00
Volker Hilsheimer 0db64ca53b QJniArray: add arithmetic operators
Required for making the iterator random access.

Based on review comments.

Task-number: QTBUG-126150
Change-Id: I80ee8ed584747759acb17ee956551caba4d5bdaa
Reviewed-by: Soheil Armin <soheil.armin@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit c4e406e3792405cfc0b8cc97a29f136c0fd44a2e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-11 10:57:24 +02:00
Volker Hilsheimer 46ed4e47d2 QJniArray: make iterator strongly ordered
Required for making the iterator random access.

Implement compareThreeWay, add tests. Comparing iterators operating
on different containers is undefined behavior, so assert if they don't
match (even if they are different QJniArrays referencing the same
Java array).

Based on review comments.

Task-number: QTBUG-126150
Change-Id: Ib3b94558fc66fb9cff19139d2110c6bbd4ac14b5
Reviewed-by: Soheil Armin <soheil.armin@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit d04f38f6f5e49a81211ab598ba23049dc4ef1507)
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-07-11 10:57:22 +02:00
Volker Hilsheimer 708b84be11 JNI: establish API symmetry across QJniObject and QJniArray
We implicitly support QString, QStringList, and QByteArray, as well as
C++ types that are equivalent to JNI primitive types (such as bool for
jboolean, or int for jint) in QJniObject and some QJniArray APIs. Make
this symmetrical for QJniArray::to/fromContainer.

Add more compile- and run-time time test coverage.

Change-Id: I8cc84e6181a93f889282d2d3f0a05207416c4dbe
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit d9dd8c4986373789b8bd250d0c2b36b660fe210f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-07-11 10:57:19 +02:00
Volker Hilsheimer eedbcad7a4 QJniArray: allow container type for toContainer to be set explicitly
Add a template parameter that is defaulted to what our logic would
select as the appropritate container type. If the type is contiguous
and the element is primitive, use the optimized implementation with
the JNI helpers for copying the entire array region.

Otherwise, use an emplace_back loop.

Change-Id: I669bc3261f111bc0c7e3dd2af8fd33293c083801
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit a6b1f80cd6c833f6eb2fbfb778254cd7fcbc000f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-11 10:57:16 +02:00
Volker Hilsheimer f715325932 Document in a test that mixing connect/disconnect syntax doesn't work
We cannot go from member function pointer to method index for slots (we
can for signals), so using string-based syntax to connect and PMF-syntax
to disconnect doesn't work, and vice versa.

Document this in a (partially failing) test, and add a warning to the
relevant QObject::disconnect documentation.

Task-number: QTBUG-126580
Task-number: QTBUG-126581
Change-Id: I4b17662aa9aa7b624049c5b0a3b046ed35230f05
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 27a3229626249a100d8e6fa495927715aba6963d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-03 06:02:34 +00:00
Volker Hilsheimer de23caa4f6 JNI: don't declare namespaces nested into QtJniTypes as inline
Sadly, inline namespaces are resulting in ambiguities. With two
declarations

    QtJniTypes::android::io::File

and

    QtJniTypes::org::qtproject::qt::android::QtWindow

referring to QtJniTypes::android already is ambiguous if `org`,
`qtproject`, and `qt` namespaces are all inline. This breaks the
idea behind Q_DECLARE_JNI_CLASS as a variadic macro that generates types
that we can transparently use as QtJniTypes.

So remove the inline keyword from the namespace declarations. The macro
might still be the way to go, but user code will to either fully qualify
the types, or use `using namespace QtJniTypes::java::lang` to use e.g.
the `String` type without ambiguities.

Types declared with the two-argument overload continue to live
directly in the QtJniTypes namespace anyway.

As a drive-by, break the excessively long lines.

Change-Id: Ie9303e6c9117fb96b3cff31c7df4df92237b5520
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit d1b89671de70ac9ffca52337058e976d86a367c1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-23 03:39:05 +00:00
Volker Hilsheimer 8352306cdc QTranslator: fix loading order when loading from locale
A locale's UI language includes the script, e.g. the QLocale::uiLanguage
list for the Australian locale en_AU is {"en_Latn_AU", "en_AU", "en"}.
The old code iterated over each language in the outer loop, and for each
language tried several times, removing a segment from the back with each
try in the inner loop. The de-facto search order was then

en_Latn_AU
en_latn_au
en_Latn
en_latn
en
en_AU
en_au
en

Usually, translation files are provided for country_Territory, i.e.
en_AU. But if an en file (for a generic English translation) was also
present, then en_AU was never tried.

Fix this by breaking the logic into two loops: first, create a list of
candidates by removing segments from each UI Language. Then sort that
list of candidates so that entries with more segments come first. The
search order is now:

en_Latn_AU
en_latn_au
en_Latn
en_latn
en_AU
en_au
en

This way, en_AU gets loaded correctly, before en is tried.

Adjust the test, which was essentially duplicating the logic from
QTranslator to generate files. This only tested that two identical loops
result in the same thing. Instead of using the system locale, make the
test data-driven, and explicitly try en_US and en_AU, with candidate
files generated based on a hardcoded list for each data row.

Pick-to: 6.7 6.5
Fixes: QTBUG-124898
Change-Id: I6bdcff289d2843e61c9053c116e955b79e09e95a
Reviewed-by: Mate Barany <mate.barany@qt.io>
(cherry picked from commit 9a11273b745a30cebb5cd648c89eb224e9704492)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-20 19:30:33 +00:00
Volker Hilsheimer 5c17246188 JNI: add test coverage to confirm assumptions about array validity
When the Java array that we hold a reference to is changed on the Java
side, then our reference continues to be valid, and references a
different object than the new array in Java.

Change-Id: If8743cc1b2fabb254b9c0009f41377455719ec3e
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit 37bb00d8507a4def05b5d85a6ef4ea23cca70ab6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-20 19:30:08 +00:00
Volker Hilsheimer 9cb2200d4f JNI: pre-declare JNI classes for standard Java types
This avoids that we or users have to declare e.g. String or Uri in
several places in Qt. This also prevents problems where multiple
declarations (possibly from different headers) cause build errors.

As a drive-by, remove some unnecessary type declarations (e.g.
UriType, which had the same class string as Uri).

To ease the submodule update process, define a preprocessor symbol
that submodules can use to conditionally declare the type locally.
Once the dependency update is through, the symbol can be removed
and submodules can use the declaration from qjnitypes.h.

Change-Id: I7d96edf644a54246302b5c5cb478e66fa615e73e
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit 457a1c973d68e705f9cf72ac72b19fc26cdb2917)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-20 19:30:06 +00:00
Volker Hilsheimer 1adc8648c1 JNI: Allow list of namespace to be passed into Q_DECLARE_JNI_CLASS
Make the macro variadic. For N > 2 arguments, interpret the first
N-2 arguments as nested namespaces that are declared as inline
namespaces. We can then construct the signature string from those
namespaces, so

Q_DECLARE_JNI_CLASS(String, "java/lang/String")

is equivalent to

Q_DECLARE_JNI_CLASS(java, lang, String)

except that with the second overload, the C++ type will be in the
QtJniTypes::java::lang namespace. Since both the java and the lang
namespaces are made inline, QtJniTypes::String still works.

This helps with avoiding conflicts, as there might be Java classes
in different packages, but with the same name.

Change-Id: I0355239e7fc3c91cb26e041f19c4e0853d3678ac
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit 2b1312bc954b72f59d0c1d7b1192e2f029016012)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-20 19:30:04 +00:00
Volker Hilsheimer b2f8a7b6a8 JNI: make it safe to iterate over or convert an invalid QJniArray
This is expected behavior for default-constructed containers.

Also add the missing isEmpty() member function to QJniArrayBase.

Change-Id: I23111f6906ef5476567272cb23746fec962afa35
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit e5516191b25d70ee9d6e87246d932fa559ef0b59)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-18 21:12:12 +00:00
Marc Mutz 2ec36e7ebe tst_QEventDispatcher: port to QTEST_THROW_ON_FAIL
Dogfooding the new QtTest 6.8 feature.

Change-Id: I4ded1fabac25fb283eb26b5eef341892b4459e96
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit 7a93e815d2489b97510a1ab7aaf6a140e2e2c587)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-18 08:09:13 +00:00
Michał Łoś 4afbfa8626 Exclude VxWorks from test for leaking objects
tst_QCoreApplication test fails due to leaking object. Investigation
about the reason of this issues was started, but no conclusion was made
and reason for object leak is still unknown. To prevent this test from
crashing exclude this check for VxWorks as well.

Pick-to: 6.7
Task-number: QTBUG-115777
Change-Id: I2c543a3b8320e2d96b2e7cd7e14c1980e500ce0d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 92e420aefb373c2dc1dd39a05ff43037edb2a145)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-18 01:34:51 +00:00
Volker Hilsheimer e4c386b0b7 QJniArray: add deduction guide for direct construction from container
That way,

QList list{1, 2, 3};
QJniArray array(list);

works.

Change-Id: If04f8115c51fce533cb4287bf36841ff0daeb11b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit f199d4f78d528f7a70170d2469ae4807e4a5e765)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-08 08:52:49 +00:00
Marc Mutz aec1edfe40 qtypeinfo.h: move QTypeTraits part to qttypetraits.h
Makes sense to collect the stuff in a similarly-named header, and it's
not like any of the QTypeTraits stuff was needed for QTypeInfo.

Makes #include <qtypeinfo.h> _much_ lighter again, at the expense of
qminmax.h now getting <variant>, <tuple> and <optional> instead, but
qminmax.h is much easier to avoid in Qt headers (just use the std
versions) than qtypeinfo.h.

[ChangeLog][QtCore][Potentially Source-Incompatible Changes] The
qtypeinfo.h header no longer transitively includes <optional>, <tuple>
and <variant>.

Task-number: QTBUG-97601
Change-Id: Ied96113f38c1232fef3ec79847ee62f06c68f268
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit b2eb422699118f4ae8370519b4c7bb3fe121beb2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-04 13:42:16 +00:00
Rym Bouabid 890c270b9b QPointer: Use new comparison helper macros
Provide the new comparesEqual() helper function as an implementation of
(in)equality operators.
Use QT_DECLARE_EQUALITY_OPERATORS_HELPER macro instead of
Q_DECLARE_EQUALITY_COMPARABLE for the comparison between QPointer<T>
and QPointer<X> to avoid creating the reversed version of the
operators in C++17 mode.

Use new \compares command in the documentation to describe the
comparison operators provided by QPointer.

Task-number: QTBUG-120306
Change-Id: Iff24d3ef5c790de7f06ab825f853e06186fa1471
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-05-30 20:51:46 +02:00
Thiago Macieira 26a81bd4fb QVariant: do reset is_null after setValue()
Issue introduced by a68e4f3b96 ("Use the
new QMetaType API in QVariant") in 6.0, which removed the d.is_null
reset at the same time as it replaced the std::destroy_at /
std::construct_at pair with an assignment operation.

[ChangeLog][QtCore][QVariant] Fixed a bug that would allow the class to
keep returning isNull() = true even after calling setValue().

Fixes: QTBUG-125472
Pick-to: 6.5 6.7
Change-Id: If05cb740b64f42eba21efffd17d13f6b1e8113c2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-05-21 18:25:02 -05:00
Kai Köhne 5e699c2a8b Replace 'Qt Designer' and 'Qt Widgets Designer' in code
Use new term in examples, code comments, error messages and and mime types.

Task-number: QTBUG-122253
Change-Id: I355452d6eb02a7a0ffbb20acf82ddb8ebbfa4837
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-05-16 13:04:41 +01:00
Tatiana Borisova 199e1a1091 QElapsedTimer: use new comparison helper macros
Replace public friend operators operator==(), operator!=(),
of QElapsedTimer to the friend method comparesEqual().

Add compareThreeWay() for the <=> operator.

Save friend bool Q_CORE_EXPORT operator<() method and
add defined(__cpp_lib_three_way_comparison) condition for the C++20
spaceship operator.

Task-number: QTBUG-120304
Change-Id: I575865403f4e333578ff174e8e6879e8925d4b09
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-05-14 00:32:34 +02:00
Tatiana Borisova 5a0faa9198 QMetaType: use modern comparisons
Internal QPropertyBindingPrivatePtr, QArgumentType classes
also have been updated;

Replace class operators operator==(), operator!=() of
QRegularExpression to friend method comparesEqual() and
Q_DECLARE_EQUALITY_COMPARABLE macro.

Task-number: QTBUG-120304
Change-Id: I010617cbcb8bd6afb7c21ee4345398648821f72c
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-05-10 21:54:54 +02:00
Mårten Nordheim fd54b88d39 tst_QMetaProperty: expand testing around enums and flags
Test more scenarios, like separate namespaces, free enums, etc.
And test that the enumerator() function returns a valid QMetaEnum when
expected.

Change-Id: Ie4fa816ffb66d6b6e1b4c7c50674c31eddbd642e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-05-06 16:52:05 +02:00
Jari Helaakoski 30cc8a28de Fix test compilation issues with QtLite configuration
Now developer build tests compile, but some are not working.
Functional fix will come later via separate tasks.

Task-number: QTBUG-122999
Change-Id: I70487b46c1b32ba4279cb02a4978e4f55ac0d310
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-05-06 14:29:02 +00:00
Tatiana Borisova 51420d910b QMetaMethod: use new comparison helper macros
Replace public friend operators operator==(), operator!=() of
QMetaMethod to friend method comparesEqual() and
Q_DECLARE_EQUALITY_COMPARABLE macro.

Task-number: QTBUG-120304
Change-Id: Idb3f880a1db4850d73a58ed37f8cbd3454dd5ea2
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-04-30 00:11:33 +02:00
Jarek Kobus 159ea47e2f QThread: Reuse isMainThread()
Internally, reuse threadId and theMainThreadId.

Change-Id: Iea6e7d8fcbcaf7e2f4dbf8ab33890d0f7954edc0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-04-29 23:11:04 +02:00
Tatiana Borisova de0f145022 QMetaSequence and QMetaAssociation: use new comparison helper macros
Replace public friend operators operator==(), operator!=() of
QMetaSequence and QMetaAssociation
classes to friend methods comparesEqual() and
Q_DECLARE_EQUALITY_COMPARABLE macroses.

Task-number: QTBUG-120304
Change-Id: I88e9b228220d36092437bfb71ae2f053d2e99fdf
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-04-29 22:28:51 +02:00
Thiago Macieira 038c199d59 QMimeData: fix setData on URI list without ending CRLF
Commit 8d127c5737 refactored this code
from QByteArray::split to manually iterate over the list (and
QStringTokenizer doesn't work for QByteArray), so we missed the last
element in the iteration.

Pick-to: 6.7
Fixes: QTBUG-124580
Change-Id: I455fe22ef4ad4b2f9b01fffd17c867f6ed350af7
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2024-04-22 13:57:38 -07:00
Tatiana Borisova 7689127d83 QDeadlineTimer: use new comparison helper macros
Replace public friend operators operator==() and operator!=() of
QDeadlineTimer to friend method comparesEqual().
Replace public friends operator<(),<=(),>(), etc of QDeadlineTimer to
friend method compareThreeWay().

Task-number: QTBUG-120304
Change-Id: Ib855ccac9b31b54fe28b822f2985154608fefa27
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-04-18 20:55:50 +02:00
Thiago Macieira 8381a4b44f tst_QVariant: fix stringification of char16_t and char32_t
QVariant::toUInt() cannot convert from those two, so we always ended up
with 0, producing lots of duplicated test rows.

Pick-to: 6.7
Fixes: QTBUG-124349
Change-Id: Ie28eadac333c4bcd8c08fffd17c5a3e39a2cc3f6
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-04-15 23:50:51 -07:00
Thiago Macieira 848451095b tst_QVariant: remove duplicate rows from compareNumerics
Task-number: QTBUG-124349
Pick-to: 6.7
Change-Id: Ie28eadac333c4bcd8c08fffd17c5a3d824fe76ec
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-04-15 23:50:51 -07:00
Thiago Macieira d204ea9873 tst_QVariant: fix copy & paste error in double-float comparisons
We wanted to test the (min,max) of each of the two types, but one of the
four combinations wasn't correctly done.

Task-number: QTBUG-124349
Pick-to: 6.7
Change-Id: Ie28eadac333c4bcd8c08fffd17c5a3ccb4205139
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2024-04-15 23:50:51 -07:00
Assam Boudjelthia 0a45996376 JNI: check for pending exception first in getCleanJniObject()
returning early if the object is null will not clear pending exceptions
from the previous failed JNI call, and that will crash the app on the
next jni call if an explicit exception clearing is not done, wish mostly
the case. Checking and clearing for exceptions has to always be done
under this call.

Pick-to: 6.7
Fixes: QTBUG-122135
Change-Id: I0d42d012a4d1305fa07147fd22860d7c005f9b83
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2024-04-04 19:12:55 +00:00
Mitch Curtis 907181cb21 Fix Qt::AA_DontUseNativeMenuWindows being unsettable on 32 bit systems
f1bb9cfbf6 added this value, but it was
only when a test in qtdeclarative tried to use it that it was
discovered that it couldn't be set on 32 bit operating systems (armv7,
AKA imx7) due to overflow as a result of the bit shifting that is done.

Fix it by using an old, deprecated value. If any old codebase using
that older flag tries to build against a newer Qt with this change, it
shouldn't affect it, as setting the flag does nothing in Widgets, and
native menus didn't exist in earlier versions.

Task-number: QTBUG-69558
Change-Id: I520154d02e9ccf007ebd73807685212a19fbee1b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-04-04 11:31:51 +08:00
Giuseppe D'Angelo 8414a0aa2c Tests: check the output of QFile::open
Wrap the call in QVERIFY.

tst_QTextStream::read0d0d0a was also faulty as it *never* opened
the file because of a broken path. Fix it with QFINDTESTDATA.

Change-Id: I61a8f83beddf098d37fda13cb3bfb4aaa4913fc5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-27 04:24:11 +01:00
Marc Mutz 78db468f48 QMetaMethod: document that fromSignal(nullptr) is ok
... and add a test.

Pick-to: 6.7 6.6 6.5 6.2 5.15
Change-Id: I907899d7c54349d2fc23ea5ab58a1e67826b622b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-21 11:20:49 +01:00