Commit Graph

15702 Commits

Author SHA1 Message Date
Thiago Macieira
77c661b275 moveToTrash/Unix: use lower-level API to write the info file
So we can more easily get any errors from attempting to write the file.
It is possible to get them with QFile, by either doing .flush() or using
QIODevice::Unbuffered, but using the C API is a definite sure way. Plus,
since this is QFileSystemEngine, this avoids the possibility that QFile
may choose to use a different file engine than the native one, for some
reason. And it reduces overhead.

This allows us to more easily detect why the file creation failed and
therefore stop looping if the error wasn't EEXIST. That will avoid an
infinite loop in case the necessary directories exist but aren't
writable.

It's also moved above the renaming, such that the failure to populate
the info file prevents the renaming too. Both operations can have the
same likely errors, ENOSPC and EIO. The likelihood of EIO is very low,
for both; but for ENOSPC it's far more likely for writing the
file. Avoiding the ENOSPC error for the renaming is handled in a later
commit.

Change-Id: I9d43e5b91eb142d6945cfffd1786d417142ac728
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-10-17 19:08:25 -07:00
Tor Arne Vestbø
7152a1d0be Add missing static to constexpr in keyevents test
Change-Id: I9e83876aadca3254042eb48ed51287e403830cf0
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-10-17 23:34:22 +02:00
Mate Barany
0345f07dd1 Support body for an HTTP GET request
Add two overloads to QNetworkAccessManager to support GET requests
with body.

Modify QNetworkReplyHttpImpl as well as these requests should not
be cached.

If the request is redirected it is possible that its type changes
from POST/PUT to GET and in this case the message body is deleted.
However, if a GET request has a body it should keep it after it has
been redirected - modify QNetworkReplyHttpImpl to keep the message
body after it has been redirected.

Fixes: QTBUG-112871
Change-Id: Ib01898638ed94238a98291870a5c51d56030868a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2023-10-17 21:23:42 +02:00
Milla Pohjanheimo
5ceb78e8d9 Add binary compatibility file for 6.6.0
Task-number: QTBUG-117583
Pick-to: 6.6
Change-Id: I9b63b916a59ddaeb89d2b819b36ee9dc57851dac
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2023-10-17 22:23:42 +03:00
Mårten Nordheim
3e6b42ae9d compressEvents: limit iteration
Slightly improves performance in the new benchmark

Change-Id: I2d71143ff7bc1f32ebb172f20be1843dec123e6c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2023-10-17 21:23:41 +02:00
Mitch Curtis
ec5383efc3 selftests: document how to run subtests from Windows' cmd.exe
It deoesn't like single quotes, which must be replaced with doubled-up
double quotes.

Pick-to: 6.2 6.5 6.6
Change-Id: I8e5f8047e72e4433926a9f4f2044407a4d823682
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-10-17 12:26:07 +08:00
Mårten Nordheim
13c4e11c49 http2: When a reply is removed from the queue, only remove one
We were using the .remove(Key) API on the map instead of
erase(iterator), so we were removing any reply of the same priority that
had not yet been popped from the queues.

Rewrote to drop loop and only work with iterators.
This issue was there since SPDY days, so not picking all the way back to
5.15, where HTTP2 anyway is not enabled by default.

As a drive-by, drop the #ifndef QT_NO_SSL, which was also there from
SPDY times, which was TLS-only.

Pick-to: 6.6 6.5 6.2
Fixes: QTBUG-116167
Change-Id: Id7e1eb311e009b86054c1fe3d049c760d711a18a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-10-16 19:28:26 +02:00
Volker Hilsheimer
80d4d55e25 JNI: add QJniArray class for easier working with arrays
Implements an iterator API and other standard member access functions
for sequential containers so that we can use ranged-for over an object
that is a jarray. Provides read-only access to individual elements
(which is mostly relevant for arrays of objects), or the entire data()
as a contiguous memory block (which is useful for arrays of primitive
types).

QJniObject call functions can return QJniArray<T> when the return type
is either explicitly QJniArray<T> or T[], or their Qt equivalent (e.g.
a jbyteArray can be taken or returned as a QByteArray). If the return
type is a jarray type, then a QJniObject is returned as before.

Arrays can be created from a Qt container through a constructor or the
generic fromData named constructor in the QJniArrayBase class, which
implements the generic logic.

Not documented as public API yet.

Added a compile-time test to verify that types are mapped correctly.
The function test coverage is added to the QJniObject auto-test, as
that already provides the Java test class with functions taking and
returning arrays of different types.

Change-Id: I0750fc4f4cce7314df3b10e122eafbcfd68297b6
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-10-16 18:43:16 +02:00
Mitch Curtis
3f2b54f0a1 selftests: respect ASAN_OPTIONS
Ensure that this environment variable is respected, as ASAN errors
(e.g. memory leaks) can cause the selftests to fail since they expect
no errors in their output.

Fix an incorrect function name in a comment, while we're at it.

Fixes: QTBUG-118041
Pick-to: 6.5 6.6
Change-Id: I07502101aabd8743df898ae8fe4a693c4733c4af
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-10-16 12:37:08 +08:00
Thiago Macieira
b470da9107 tst_QStorageInfo: align the columns without newlines
Change-Id: I9d43e5b91eb142d6945cfffd17874a50565a97d6
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-15 18:37:07 -07:00
Thiago Macieira
b0329f8560 tst_QFile::moveToTrash: add tests for /var/tmp
These must pass, but they're highly unlikely to be trashable because
/var/tmp is usually not its own filesystem (it might be a subvolume of
its own, but usually isn't). Instead, it's usually part of / or /var.

On my machine:
 openat(AT_FDCWD, "/var/.Trash", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
 openat(AT_FDCWD, "/var/.Trash-1000", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
 mkdirat(AT_FDCWD, "/var/.Trash-1000", 0700) = -1 EACCES (Permission denied)

Change-Id: Ifeb6206a9fa04424964bfffd17884246a4d27443
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-15 18:36:50 -07:00
Thiago Macieira
a40341366f tst_QFile::moveToTrash: use QDir::tempPath() for the rows w/ "temporary"
Both QTemporaryFile and QTemporaryDir are documented to use the current
directory if given a pattern. That can be anything & arbitrary, so it
doesn't give us consistency in checking. Moreover, it might be a read-
only directory.

Drive-by fix the number of 'X'.

Task-number: QTBUG-117449
Pick-to: 6.6
Change-Id: Ifeb6206a9fa04424964bfffd178841c44e9636a0
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-10-16 01:36:49 +00:00
Thiago Macieira
ef22527bf5 tst_QFile::moveToTrash: avoid QSKIP+FAIL condition
QtTest can't handle a test that does both. This ends up recorded as a
skip in the summary.

Pick-to: 6.6
Change-Id: Ifeb6206a9fa04424964bfffd1788412a438085b0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-10-15 18:36:48 -07: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
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
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
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
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
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
Edward Welbourne
29af4b1833 Sort out an anomaly in tst_QDateTime::springForward()
It noted that an unspecified function claimed the offset it was
checking should be +1, while testing it against that or -1. The
function turns out to be QDateTime::addDays(), whose doc did indeed,
misleadingly, say that it lands after a gap it would have hit. It in
fact overshoots the gap in the direction of its change. Amend its
docs, likewise those of addMonths() and addYears(), to reflect the
true behavior.

Amend the test to look at the direction of the step its taking and
anticipate that the adjustment will be in the same direction; then
compare the actual adjustment to that.

Change-Id: I9ab918fac0ab2195ef014983f37fccc435bf0498
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-10-11 22:06:20 +02:00
Edward Welbourne
c23d00078c Let QDateTime::offsetFromUtc() work for invalid date-times
The implementation previously worked for non-short date-times, where
the offset has been remembered since construction. This included the
case of zoned times (and local times more than 2^55 msec away from the
start of 1970) that hit a spring-forward's gap; but excluded local
times that did the same (within 2^55 msec of the epoch).

This precluded an offset check in a spring-forward test, now added.

We can in fact determine the offset whenever we got a valid date and
time (we do so in the course of initializing the object, and when
asked for toMSecsSinceEpoch(), even when invalid), and we should not
use the value of the recorded offset if we didn't get a valid date and
time, so amend to always return 0 if we didn't get valid date and time
and always report the correct offset otherwise.

In the process, amend offsetFromUtc()'s computation to directly
resolve the date-time, rather than doing so via toMSecsSinceEpoch(),
which has to repeat decision-making offsetFromUtc() has already done
by the time it calls it. Also amend toMSecsSinceEpoch() to return 0 if
we didn't have a valid date and time to begin with, so it only
attempts to produce a useful result in the case where construction
attempted to resolve the date-time.

Change-Id: I6574e362275ccc4fbd8de6f0fa875d2e50f3bffe
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-10-11 22:06:19 +02:00
Edward Welbourne
4aba97e062 Adjust msecs instead of offset for spring-forward resolution times
The resolution selects a point in time outside the gap, which will be
represented by toMSecsSinceEpoch()'s return, despite the QDT object's
isValid() returning false. Previously we retained the
originally-calculated msecs, so as to keep date() and time() matching
what was asked for. However, this required adjusting offset, which was
not remembered for local times within 2^55 milliseconds of the start
of 1970. This lead to an inconsistency between the offset from UTC
reported for the resolution for a local time further from the epoch,
or for a time-zone, and the actual offset from UTC at the time
indicated by the return from toMSecsSinceEpoch().

Instead, retain the actually calculated offset (even if we aren't
going to remember it) and adjust the msecs to the value that ensures
toMSecsSinceEpoch() will get the selected resolution. This
incidentally means that, when toMSecsSinceEpoch() has to re-resolve
(for a local time within 2^55 msecs of the epoch), it avoids
revisiting the complications of hitting the gap.

In passing, change internal stateAtMillis() to take the QTimeZone it
is passed by const reference, to save a copy (noticed during debug).
Also tweak a comment in a test to be explicit about a default value.

[ChangeLog][QtCore][Possibly Significant Behavior Change] When
QDateTime is instantiated for a combination of date and time that was
skipped, by local time or a time-zone, for example during a
spring-forward DST transition, the invalid result's time() - and, in
rare cases, date() - no longer match what was asked for. Instead,
these values and offsetFromUtc() now match the point in time
identified by toMSecsSinceEpoch().

Change-Id: Id61c4274b365750f56442a4a598be5c14cfca689
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-10-11 22:06:19 +02:00
Tor Arne Vestbø
cd4000a97d Use QtGui to match QWindow based shortcuts, even when QApplication is used
If a QShortcut is registered with a QWindow as its parent, but QApplication
is used, we end up in QApplicationPrivate::createShortcutPrivate(), and
create a QtWidgetsShortcutPrivate that implements shortcut context matching
via qWidgetShortcutContextMatcher.

The problem is that qWidgetShortcutContextMatcher expects the windows
to be QWidgetWindows, which meant that plain QWindow based shortcuts
would always fail.

This can happen for example if a QApplication is used in Qt Quick
to provide dialog fallbacks, but QShortcuts are otherwise used
with plain QWindows, or QQuickWindows e.g.

We now defer the check of whether there's an active (widget) window,
and fall back to QtGui's simpleContextMatcher in case we don't find
a QWidget, QAction, or QGraphicsWidget shortcut owner to handle
the matching for.

Note: We don't support shortcut matching for QAction in QtGui,
but this is left for another day. There is also a discrepancy
between how QtGui and QtWidgets handles Qt::ApplicationShortcut.
The former will treat it as a match even if there is no active
QWindow, while the latter requires that there's an active widget
window.

Fixes: QTBUG-116221
Change-Id: I487995f2e660a40f6556828b84a521d81a58f1b6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-11 20:32:05 +02:00
Tor Arne Vestbø
260ac1891a tst_QInputMethod: Don't assume test is the only one calling functions
After d9bb8c0a17 we call inputDirection()
on the platform input context to initialize the direction at startup.

The test can't assume there are no other callers to the functions
in the QPlatformInputContext layer.

Change-Id: Ic1cecd608b2759e703a17838fcf24b4ff53ad07e
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-10-10 19:29:27 +02:00
Shawn Rutledge
8e0bf6e05b Make tests/manual/qtabletevent/device_information build standalone
It's very hard to test on Android otherwise: Creator isn't cooperating
well enough with Android Studio / SDK manager with where stuff is
installed, qmake doesn't build an apk, and qt-cmake-standalone-test
doesn't work wth Android either.

Renamed the executable to tablet_device_info so it's a bit less
confusing on device launcher UIs.

Task-number: QTBUG-86297
Change-Id: I3bb7f816e43f8df4183be1c0866e228befa9e8d9
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2023-10-10 18:27:22 +02:00
Anton Kudryavtsev
ebf1538fa6 Qt::mightBeRichText: port to QAnyStringView
[ChangeLog][QtGui] Ported Qt::mightBeRichText() to QAnyStringView
(was: QString).

Change-Id: Ib5633ed45cba5f4f1211438397624574f7431908
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-09 22:19:24 +00:00
Mårten Nordheim
0fa4af060e QTemporaryFile: Add support for std::filesystem::path
Since it hides QFile's overloads this was not supported for
QTemporaryFile.

[ChangeLog][QtCore][QTemporaryFile] Added support for passing
std::filesystem::path to rename and createNativeFile.

Change-Id: I909ff1d5b9c586824c9901d7dad278dfad09ffc3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-09 16:25:57 +02:00
Tor Arne Vestbø
ab99cf6077 QKeySequence::toString(): Treat Modifier+Qt::Key_Unknown as empty string
We were already doing this for a key combination without modifiers,
but now we do the same for e.g. Control+Unknown. This matches the
behavior we have for QKeySequencePrivate::decodeString(), where
we return Qt::Key_Unknown if we can't resolve the key, even if
we have resolved some valid modifiers, e.g. "Meta+Trolls" as in
the tst_QKeySequence::parseString() test.

Change-Id: I238e29276e6ce356ae60c67585739587fa388f07
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-10-09 15:25:54 +02:00
Thiago Macieira
1033780b3c tst_QFile: extend moveToTrash tests to exercise more corner cases
Added moveToTrashDuplicateName() to see what happens if you attempt to
trash two files with the same exact full path. Both files should get
independently moved to the trash bin and not clobber each other.

Added moveToTrashXdgSafety() to test that QFileSystemEngine will
properly skip over an unsafe $root/.Trash directory, as required by the
XDG specification. I think the specification should also make security
requirements on $root/.Trash-$uid too, but that's for another change.

Pick-to: 6.6
Change-Id: I9d43e5b91eb142d6945cfffd1786cd60e4244c7c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-06 18:43:29 -07:00
Ahmad Samir
032ffb70a8 QAbstractSocketEngine: port to QDeadlineTimer
qnativesocketengine_win.cpp: don't check if timeout is < 0, because
remainingTimeAsDuration() doesn't return negative values.

All the changes done in one go, not function by function, as that causes
the least churn. You can think of them as a couple of very similar
changes repeated various times.

Drive-by change: replace `forever {` with `for (;;)`

Task-number: QTBUG-113518
Change-Id: Ie9f20031bf0d4ff19e5b2da5034822ba61f9cbc3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-10-07 02:28:12 +03:00
Axel Spoerl
92d837e684 QDockWidget: Do not propagate title from a closed dock widget
When a dock widget is closed while floating, it still reports being
floating even though the QWidget::windowHandle()->isVisible() returns
false. This is documented behavior and will not be changed.

c153066baa relied on the isFloating() to
return false, if the dock widget is closed. When the window title was
changed by setWindowTitle(), the change was overridden by reading the
old value from the window handle.

=> Amend the patch and add a windowHandle()->isVisible() as a condition.

In c153066baa, an autotest for the title
propagation (QTBUG-113591) was added to floatingTabs().

=> Harden the setWindowTitle() test function. Move the tests related to
QTBUG-113591 and QTBUG-117764 to this function.

Fixes: QTBUG-117764
Pick-to: 6.6 6.5
Change-Id: Id37a9a22d4d13abad4ea55c74ea4e834bdb2bfab
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2023-10-07 00:01:22 +02:00
Mårten Nordheim
0c4b2779ff tst_http2::redirect: reduce length of test
By fixing how many requests we are expecting to _finish_.

Since the nRequests variable is only decreased once a
request is finished, we only actually expect 1. No matter
how many times it gets redirected.

This was the slowest test-function in the test, clocking in at
10 seconds. Now it's sub 500ms.

Pick-to: 6.6 6.5
Change-Id: I544360f0928466c1bc0fbc6806952ccec588d131
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-10-06 17:40:23 +00:00
Tor Arne Vestbø
5fce4ff2c2 keyevents test: Force left to right when outputting key combinations
Otherwise characters in right to left languages like Hebrew might
mess up the output.

Change-Id: I8753e7e672159ed515dc6152c3629adf91cfd4a9
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-10-06 15:48:46 +02:00
Marc Mutz
bc3ae300c5 tst_QStringApiSymmetry: add more invalid UTF-8 sequences
These represent US-ASCII characters incorrectly encoded as a two-octet
UTF-8 sequence.

Pick-to: 6.6 6.5
Change-Id: I5b1d58066d08cf61583dabcd71dd2f3ac7a3585a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-06 06:59:02 +02:00
Christian Ehrlicher
4e8b54eb81 Preparations to deprecate QItemDelegate
QItemDelegate was superseded since Qt4 by QStyledItemDelegate but it
took until Qt6.7 to remove the last occurrences in qtbase.
 - remove unused includes / replace with qabstractitemdelegate.h
 - replace references in the documentation with QStyledItemDelegate
 - adjust the examples and tests to use QStyledItemDelegate

Pick-to: 6.5 6.6
Change-Id: I246755004ce2d01192a726ca0972106c237df0cc
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2023-10-05 21:08:45 +02:00
Christian Ehrlicher
9ed25b413f Tests/QListView: fix internalDragDropMove test for openSUSE
On some xcb platforms the xcb_configure_notify_event_t is sent after the
window is fully exposed which leads to a wrong position for
QWidget::mapToGlobal() which makes the test fail.
Fix it by waiting for a move event with a position != 0,0 before
starting the drag'n'drop operation.

Fixes: QTBUG-94250
Change-Id: If91a15815205ba9dcea36248d9de03ed0a7e5822
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-10-05 19:08:45 +00:00
Anton Kudryavtsev
9187348505 qtextdocument::insertText: port to QSV
and add QChar overload to reduce allocations
Also port tests from char* literals to char16_t literals

Change-Id: I99381a2da08d9d35e6135c48bd92bd8d72533065
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-10-05 22:08:45 +03:00
Marc Mutz
1219dbcd12 QPointer: ensure construction from nullptr is constinit'able
Construction from nullptr wasn't, before, because it was using the
QPointer(T*) constructor, which cannot be constexpr. Add a constexpr
QPointer(std::nullptr_t) constructor to enable this use-case.

This requires to mark the (T*) constructor as Q_WEAK_OVERLOAD,
otherwise legacy construction from a literal 0 would be ambiguous.

No documentation changes needed, as the set of valid expressions
(apart from constinit'ing) has not changed. Mention the nullptr ctor,
though, without \since.

Add a test to confirm that contruction from derived still works.

Change-Id: If9d5281f6eca0c408a69f03fecba64a70a0c9cf0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-05 20:19:40 +02:00
Volker Hilsheimer
fd4319700f JNI: Silence and harden QJniEnvironment test
Ignore expected warning messages when looking up classes, methods, or
field that don't exist. Make the test implicitly fail for any other
warning messages.

Change-Id: I79ec799102b1ab9424aa39c5255413931b8ad152
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-10-05 19:50:33 +02:00
Hatem ElKharashy
888016a53f Fix compilation error for QRhi stereo manual test
Add a guard to prevent compilation error on
non-Windows platform

Change-Id: Ibe0d74c1dfe3d4656addeb80c702b6e254d37d84
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Kristoffer Skau <kristoffer.skau@qt.io>
2023-10-05 08:18:01 +00:00
Thiago Macieira
3a49d7d4e5 tst_QFile: extend virtualFile() to find QtCore and QtTest
In non-static builds, of course.

Change-Id: Ifbf974a4d10745b099b1fffd1777ac97c0921759
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-10-04 12:04:45 -07:00
Rym Bouabid
b956fec7ee Remove Custom Type Example and Custom Type Sending Example
The whole Q_DECLARE_METATYPE part is superfluous in these two examples,
as QVariant works with any type as long as it is copy-constructible.
And QVariant will call the equivalent of qRegisterMetaType, so that
doesn't need to happen, either.
Showing how to integrate the type with qDebug is fine in theory, but
also a repetition of content that can be found in other places.

Given that there isn't much else being shown in these two examples, it's
better to remove them from examples and move them to manual tests.

Some parts of "Custom Type Example" were used as snippets in other
documentations under qtbase/src/corelib. So, they were added in
customtypeexample.cpp file in the snippets folder.

Fixes: QTBUG-117001
Pick-to: 6.6 6.5
Change-Id: I45b16338912e3f7394cbb5169642bd31af32d5e1
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-10-04 21:04:45 +02:00
Tor Arne Vestbø
c8599f1626 Add QShortcut test for Qt::ApplicationShortcut
A Qt::ApplicationShortcut shortcut is not tied to a specific window.

We do however document that the shortcut "is active when one of the
applications windows are active", which seems like a strange limitation,
but for now we honor it in our test as well by making another window
active.

Change-Id: I235230ff69df29ee43d356d3efaeedb20071faf3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-04 20:36:53 +02:00
Marc Mutz
8b66184625 tst_QPointer: ensure default-constructed objects are constinit'able
Construction from nullptr isn't, because it's using the QPointer(T*)
constructor, which cannot be constexpr.

Pick-to: 6.6 6.5
Change-Id: I19129a0fca5873e83d20351a909a7994399bfcce
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-04 07:44:04 +02:00
Marc Mutz
1cf0f8e7c3 tst_QPointer: add checks for CTAD
No pathological findings :)

Pick-to: 6.6 6.5 6.2
Change-Id: Ifbbca223a5e612e7abb67c0364d4354a9d8174e3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-04 07:44:01 +02:00
Christian Ehrlicher
cb4e7f4176 QHeaderView: add test for rows/columns moved
Add a testcase to make sure the signals for moveing rows are properly
connected from the model to the corresponding QHeaderView slots.

Task-number: QTBUG-117698
Pick-to: 6.6 6.5
Change-Id: I354f8836d3de58a8bf51da7a8c0859a673ec9339
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-10-03 18:49:43 +00:00
Eskil Abrahamsen Blomfeldt
a890df0283 coretext: Support variable application fonts
Named instances of variable application fonts are exposed
automatically through CTFontManagerCreateFontDescriptorsFromData()
(and also for the URL equivalent).

The main change here is just to call this instead of the overload
which only returns the first font.

Note that this also updates the test: This is because the conversion
from CoreText normalized weight values to TTF values is not 100%.
In the CoreText code, we map Heavy (0.56) to ExtraBold, but ExtraBold
gets converted to 0.6, which is closer to the CoreText value for Black
(0.62).

To avoid hitting this inconsistency, the QtExtraBold has been changed
to Black weight instead, which resolves to the same on all platforms.

Task-number: QTBUG-108624
Change-Id: Ied6d42e9e3e1ba8b7102936c5be3d285b3d9e07f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-10-03 19:25:46 +02:00
Tor Arne Vestbø
8606f33641 Simplify tst_QShortcut
There's no need for the manual sendKeyEvent, as QTest already
has the ability to send synthetic clicks, and we don't need
a colored window to test shortcut activation.

Pick-to: 6.6
Change-Id: I8409888664e2316bec4ea64f21dbb8b6915091f4
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2023-10-02 22:53:11 +02:00
Ahmad Samir
76afc35328 QStringList: refactor a unittest
- Initialize QStringList with an initializer_list instead of old style
  operator <<()
- Use Qt::StringLiterals more, better readability
- Test CaseSensitivity

Change-Id: If7dde14333d54b8c2f682036634ad94d5f9f9c74
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-02 22:12:35 +03:00