Commit Graph

15845 Commits

Author SHA1 Message Date
Christian Ehrlicher
1ffd12a8dc QComboBox: don't eat non-printable key strokes
QComboBox in non-editable mode passes all keyboard input to the internal
item search. This was done regardless if the character is printable or
not and therefore e.g. '\t' composed by Key_Tab + ControlModifier was
accepted and not passed to the parent (in the bug report to the
QTabWidget which could not switch tabs due to that).

Pick-to: 6.6 6.5
Fixes: QTBUG-118605
Change-Id: If39423587460a70231c735df4912b72c5ae77475
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-11-23 10:33:28 +00:00
Volker Hilsheimer
5ae6355487 Add initial implementation of macOS and iOS icon theme implementations
From macOS 13 on, AppKit provides an API to get a scalable system image
from a symbolic icon name. We can map those icon names to the XDG-based
icon names we support in Qt, and render the NSImage with palette-based
coloring when needed, in an appropriate scale.
On iOS, we can use the equivalent UIKit APIs. Coloring functionality is
only available from iOS 15 on.

Implement a QAppleIconEngine that does that in its scaledPixmap
implementation. Use basic caching to store a single QPixmap version of
the native vector image. We regenerate the pixmap whenever a different
size, mode, or state is requested.

Add a manual test for browsing all icons we can get from the various Qt
APIs that: standard icons and pixmaps from QStyle, QPlatformTheme, and
QIcon::fromTheme, in addition to showing all icon variations for a
single QIcon.

Task-number: QTBUG-102346
Change-Id: If5ab683ec18d140bd8700ac99b0edada980de9b4
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-11-23 00:52:12 +01:00
Volker Hilsheimer
d2c6e9ab99 Blacklist tst_QGuiEventLoop::processEvents on QNX
The test log shows flaky failures of this test several times a day on
QNX, so blacklist it.
To do that, we need to be able to isolate the "GUI" mode of this test.
To do that, add a single data tag that depends on whether the test
project is built for GUI or Core, and blacklist only the "gui" data tag.

Task-number: QTBUG-119359
Pick-to: 6.6
Change-Id: I91c2380de0a3febedcf781f27fed4a1fa6aa5515
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-11-22 21:15:38 +01:00
Vladimir Belyavsky
18aa36cf87 QTest: make failOnWarning() functional on temp objects destruction
We need to be able to handle warnings that may occur when temporary
objects, that were created in a test function, are destroyed.
For example, now we miss all warnings that might be triggered from
the object destructor, if the object's deletion was delayed (e.g. via
deleteLater()). Also we miss all the warnings that were triggered on
the test's cleanup() call.

To fix this we need simply move QTestLog::clearFailOnWarnings()
from QTestResult::finishedCurrentTestData() to the later stage,
i.e. into QTestLog::clearCurrentTestState() which is actually called
in appropriate time from QTestResult::finishedCurrentTestDataCleanup().

Same for QTestLog::clearIgnoreMessages(), since they are interrelated,
so we need to clear them at the same time.

We need this change for QML tests in particularly, to be able
fail on warnings that might be triggered from Component.onDestruction()
of some temporary test object.

Pick-to: 6.6 6.5
Change-Id: I58a57691f20761619f56bd1bea3a862f2c26f569
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-11-22 20:15:38 +00:00
Kalle Viironen
a397247e2b qtestlib: Add option to skip blacklisted tests
Add a command-line option "-skipblacklisted" to testlib to skip
blacklisted test cases. Currently, blacklisted test cases are run,
but results are ignored. For test code coverage measurements, it's
important to see the code coverage of the actually tested code in
comparison to the code that was run but not actually tested.

The default approach remains unchanged, meaning that blacklisted
tests are run with the results ignored.

Fixes: QTBUG-112793
Change-Id: I6fe0a6353cb1c021e0232c79bb4f404632fb0bce
Reviewed-by: Jason McDonald <macadder1@gmail.com>
2023-11-22 20:09:34 +02:00
Rym Bouabid
bf946e8e3b QObject: allow calling findChild() without a name
Add an overload of findChild() without a name argument to be able to
call the function with options value only.

[ChangeLog][QtCore][QObject] Added findChild() overload taking no name.

Task-number: QTBUG-103986
Change-Id: Id06b6041408fcf4cc1eeba975afce03f3a28f858
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-11-22 14:42:17 +00:00
Tor Arne Vestbø
b232af9583 Disable tst_ForeignWindow::embedForeignWindow() null-parent check on Linux
It's flakey, so let's unbreak the build while we investigate further.

Pick-to: 6.6
Change-Id: I9f7559803dd3ebc80946e5e5c5d31292101cd36f
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-11-22 15:42:01 +01:00
David Faure
6ea2a12e27 QDBusConnection: output error message from findSlot
This helps debugging why an adaptor's method fails to be called.
Example output:
QDBusConnection: couldn't handle call to LaunchCommand: Type not registered with QtDBus in parameter list: QByteArrayList

tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall shows many warnings
after this commit, since it's testing many cases of "no such slot".

Pick-to: 6.0 6.1 5.15
Change-Id: Ic4ddcd91d005555a02d531fc8960aea2c809e20b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-11-22 07:18:08 +01:00
David Faure
b7657ddccb qDebug: add support for std::optional and std::nullopt_t
[ChangeLog][QtCore][QDebug] Added support for std::optional
and std::nullopt_t

Change-Id: I1e6196adb408401cae8776cd0c60af294a39a83f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-11-22 05:56:25 +01:00
Ahmad Samir
9cf47946fc tst_QTimer: refactor CMake code
It's used to build different variations of the unittest,
linking against QtCore-only/QtGui, with/without GLib, that's four
individual tests.

Change-Id: Iaf0f37041dbb148134631f86be99feaa881a8ce8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-11-22 06:34:29 +02:00
Rym Bouabid
e608bc0192 QObject: port findChild/ren() to QAnyStringView
Change the object's name type in QObject::findChild/ren() to
QAnyStringView, because they are only used for comparison against
objectName property.

qt_qFindChild{,ren}_helper() functions taking an objectname as
QString have to stay in the ABI as they were exported in inline
methods before Qt 6.7.

Unlike QString, constructing a null QAnyStringView doesn't involve
any code-size overhead. So, get rid of the split in qt_qFindChildren_helper
that was introduced for QString. Remove unneeded
qt_qFindChildren_with_name helper function and qt_qFindChildren_helper
overload without a name.
findChildren(options) method used to call qt_qFindChildren_helper overload.
Instead, call findChildren overload with name argument and pass
QAnyStringView{} as the object name.

[ChangeLog][QtCore][QObject] Ported QObject::findChild/ren() and
their helper functions to QAnyStringView.

Task-number: QTBUG-103986
Change-Id: I68bda0e581f984ae48b7581ad86cc1b95008c1b0
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-11-22 01:26:46 +01:00
Marc Mutz
bdd41f491c Rename Q*Ordering to Qt::*_ordering
Since we cannot re-use the pre-existing QPartialOrdering type due to
binary-compatibility issues (it's not BC to std::partial_ordering),
we're no longer bound to copy its API for consistency.

So copy std::*_ordering type API for consistency instead, to ease
porting for users that can already use C++20 and everyone else come
Qt 7.

This patch is another step in that direction, renaming classes and
their memmbers to std-compatible names. QPartialOrdering cannot
change, as it's pre-existing. So add a completely new type
Qt::partial_ordering.

Adding conversions from QPartialOrdering is left for a follow-up
patch.

As a drive-by, change `\c Less` to `\l Less` in the \class
documentation blocks of the new classes.

Amending c6fe64b17c, which didn't have a
ChangeLog:

[ChangeLog][QtCore] Added Qt::{partial,weak,strong}_ordering as
drop-in C++17 stand-ins for C++20's std::{partial,weak,strong}_ordering.

Task-number: QTBUG-119108
Change-Id: Ib1296de6b708571a6abca8843ba36c114f6fd34f
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-11-21 11:46:27 +01:00
Marc Mutz
67072a70af Q*Ordering: supply is_{lt,gt,n,}eq
std::is_eq etc work fine on our Q*Ordering types when C++20 is
available. But in C++17 mode, they're absent.

Plug the hole by providing them for our own types as hidden friends,
so that users can use unqualified calls to transparently support both
std::*ordering and Q*Ordering types, just like with comparison to
literal zero.

For some reason, we running here into
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100903, even though this
wasn't seen in other commits of the chain that use comparisons to
literal zero. Suppress the warning. Then at least is_eq etc provide a
safe fall-back for compilers and users affected by this bogus warning.

Fixes: QTBUG-119100
Change-Id: Ie8519c92363401a0c9c8efba6eb0b6e030a8e235
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-11-21 11:46:27 +01:00
David Faure
64b6e6b85c QMimeDatabase: update freedesktop.org.xml to shared-mime-info 2.4
A severe incompatibility was detected in 2.3, which is why 2.4
is being released so soon afterwards. The mimetype for *.bz2 files
changed (from bzip to bzip2), breaking much code in KDE for instance.
This is now handled in a more compatible way. And the two last-minute
fixes in the Qt copy of 2.3 are part of 2.4, so this is now more in line
with upstream shared-mime-info.

Change-Id: Ibca358cf2ca9f341d148f54bb18044683c4a05eb
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-11-20 17:21:20 +01:00
Ahmad Samir
66345ce785 tst_qtimer: remove extra ; after Q_DISABLE_COPY
Fixes warning from sanitize-commit.

Change-Id: Ie52de4e34fce903d898619bc8e2338a15b7b7e68
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-11-19 20:19:04 +02:00
Tor Arne Vestbø
340b972995 Stabilize tst_ForeignWindow::embedForeignWindow()
We only care about no longer being a child of the old parent window,
not what the system does when we reparent to nullptr.

Pick-to: 6.6
Change-Id: Ibd670432f0fd2595195d3951014a570dfdb7a998
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2023-11-19 16:08:06 +01:00
Axel Spoerl
e6d85cf28b QDockWidget: Fix group unplugging
A floating dock widget could either be a single QDockWidget object,
or a QDockWidgetGroupWindow with a single QDockWidget child.
The former could be dropped on the latter. Dropping the latter on
the former caused a crash.

The existence of QDockWidgetGroupWindows with a single dock widget
child was accepted to be by design.
Previous fixes, such as  9ff40b59da,
attempted to wrap all single floating dock widgets in
QDockWidgetGroupWindows.

These attempts fell short, because of the manifold programmatic and
manual options to create a floating dock widget:
- drag a single dock widget out of a main window dock area
- drag a dock widget out of a tab bar on the main window
- drag a dock widget out of a floating tab
- call `QDockWidget::setFloating(true)` in any situation
- create a new QDockWidget, that floats from the beginning

Whenever a QDockWidgetGroupWindow with a single QDockWidget child
was hovered and/or dropped on a QDockWidget without a group window,
crashes or screen artifacts were observed. Previous fixes made them
occur less often.

QDockWidgetGroupWindow is not designed to hold a single QDockWidget
child. Such a state is inconsistent and may only exist, while a
QDockWidgetGroupWindow is constructed.

The reason why such invalid QDockWidgetGroupWindows started to exist,
is a bool trap: QDockWidgetPrivate::mouseMoveEvent() starts a drag
operation, when a dock widget is moved by mouse.
It called startDrag() with no argument, which defaulted to
startDrag(true) and caused a group drag.

This assumption is
*correct*, when a tabbed group of dock widgets is dragged out of the
main dock as a whole, to become floating tabs.
*wrong*, when a single dock widget is dragged out of a docked group,
to become a single floating dock widget.

In the second case, the dock widget was wrapped in a new, floating,
invisible QDockWidgetGroupWindow. Looking like a single, floating dock
widget, the group window caused a crash, when attempted to be dropped
on another dock widget.

This patch eliminates all cases, where a QDockWidgetGroupWindow with
a single QDockWidget is created:
(1) Implement QDockWidgetPrivate::isTabbed().
This enables mouseMoveEvent to determine, whether the move relates to a
group of tabbed dock widgets, or to a single dock widget.
startDrag() can therefore be called with the right argument. It will no
longer create a QDockWidgetGroupWindow with a single QDockWidget child.

(2) Change QMainWindowTabBar::mouseReleaseEvent
When a dock widget was dragged out of a tab bar and became a single,
floating dock widget, it was still parented to the group window.
That is wrong, because it has no more relationship with that group
window.
=> Reparent it to the main window, just like any other single floating
dock widget. That enables QDockWidgetGroupWindow to detect, that the
2nd last child has gone and no more group window is needed (see next
point).

(3) React to reparenting, closing and deleting
If the second last dock widget in a floating tab gets closed (manually
or programmatically), reparented or deleted, also unplug the last one
and remove the group window.

(4) Amend 9ff40b59da
Remove the code path where a QDockWidgetGroupWindow with a single
QDockWidget child was created 'just in case', to make it compatible
others, created by (1), (2) or (3).

(5) Change QMainWindowLayout::hover()
When the hover ends without a successful drop and a temporary group
window with a single dock widget child has been created, remove the
group window.

The patch fixes smaller inconsistencies, which have not become visible
due to assertions and crashes earlier in the chain.

The patch finally extends tst_QDockWidget, to cover all 4 cases.

- Creation of floating tabs
The creation of floating tabs is extracted from floatingTabs() to
the helper function createFloatingTabs(). In addition to creating
floating tabs, the helper verifies that dragging a dock widget out
of the main window doesn't accidently wrap it in a group window.
This covers case (1).

- tst_QDockWidget::floatingTabs()
The test function verifies now, that both test dock widgets have the
same path before plugging them together and after unplugging them from
the floating tab. This covers case(4).

- tst_QDockwidget::deleteFloatingTabWithSingleDockWidget()
This test function is added, to cover cases (2) and (3).

- tst_QDockWidget::hoverWithoutDrop()
This test function hovers two floating dock widgets hover each other,
and returns the moved dock widget to its origin before releasing the
mouse. This covers case(5).

This fixes a lot of long standing bugs, making the author of this patch
modestly happy :-)

Fixes: QTBUG-118223
Fixes: QTBUG-99136
Fixes: QTBUG-118578
Fixes: QTBUG-118579
Fixes: QTBUG-56799
Fixes: QTBUG-35736
Fixes: QTBUG-63448
Fixes: QTBUG-88329
Fixes: QTBUG-88157
Fixes: QTBUG-94097
Fixes: QTBUG-44540
Fixes: QTBUG-53808
Fixes: QTBUG-72915
Fixes: QTBUG-53438
Found-by: Keith Kyzivat <keith.kyzivat@qt.io>
Found-by: Frederic Lefebvre <frederic.lefebvre@qt.io>
Pick-to: 6.6 6.5
Change-Id: I51b5f9e40cb2dbe55fb14d769541067730538463
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-11-18 20:48:44 +01:00
Axel Spoerl
0b10b7476c Refactor tst_QDockWidget::closeAndDelete()
The test function was temporarily blacklisted on Ubuntu, but also
failing on other Linux platforms (e.g. openSuSE).

It tested, whether closing all dock widgets and the main window, would
close the application as well. It used one single shot timer, to close
the windows and later one to check, whether the application was shut
down.

While that mechanism must work in an application environment, it is not
guaranteed to work in testlib. More specifically, I could happen that
the XCB / glib event loop continued to spin and wait for events.

=> Check the signal QGuiApplication::lastWindowClosed() instead. If the
signal is fired, it is proven that all windows have been closed and
the application would quit in a production environment.

The underlying test case was: Application didn't quit with the last
dock widget closed, because there was a dangling
QDockWidgetGroupWindow.

=> finally: Clean up BLACKLIST

Pick-to: 6.6 6.5
Change-Id: Ic5fde5967fc8dde70ab64dc30cc7367c908b5c51
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-11-18 20:48:21 +01:00
Thiago Macieira
b3eb951d18 QStorageInfo/Linux: switch the non-Android version to also use statfs()
It's the actual system call on Linux, inspired by the 4.4BSD call of the
same name (and our BSD code also uses statfs(), except for NetBSD, but
it probably could use statfs() there too). statvfs() wasn't introduced
until POSIX.1-2001, though glibc added it in 1998 for version 2.1 and
Bionic only for NDK version 19 in 2019.

So we could merge the Android code to the POSIX version, but it's easier
to merge the non-Android code to the raw system call.

Change-Id: I8f3ce163ccc5408cac39fffd178dbd83567a78d5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-11-17 15:36:37 -07:00
Laszlo Agocs
9f3d6e325f Make contextinfo example a manual test
Change-Id: I9023016d50e82bba1fa73632cc1409b3d016f352
Reviewed-by: Kristoffer Skau <kristoffer.skau@qt.io>
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2023-11-17 22:27:01 +01:00
Tor Arne Vestbø
99c70de9a6 Add dedicated child and parent events for QWindow reparenting
When a QWindow is parented into another window, either via its constructor,
or via setParent(), we also update the QObject parent of the window. This
in turn sends ChildAdded and ChildRemoved events to the new and old parent
of the window, as well as ParentAboutToChange and ParentChange to the window
itself.

But at the point when these events are sent, the QWindow parent relationship
has not been fully established. We have not updated d->parentWindow, nor
have we propagated the parent relationship to the platform window.

This is problematic because clients can not use these events to react to
window parent changes synchronously. For example. trying to raise a child
window when added to a parent is not going to work, because at that point
the child window isn't a native child of the parent.

Instead of re-using the QObject events for QWindow, like QWidget does,
by delaying the events or sending them manually at a point when the
window parent relationship has been fully formed, we opt to add new
dedicated events.

Change-Id: I019c14eba444861f537e4f68ab3a82297f843cf7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-11-17 22:10:48 +01:00
Ahmad Samir
c94bcecb22 QMdiArea: fix initial single-sub-window in TabbedView
This is somewhat of a corner case, where there is a single sub-window,
setViewMode(TabbedView) is called before addSubWindow(), and the latter
is called before show(). The sub-window would be active, i.e.
subwindow->d_func()->isActive is true and QMdiArea::aboutToActivate() is
emitted, but QMA::emitSubWindowActivated() is never called for that
sub-window, resulting in that sub-window shown as
unmaximized/with-a-title-bar instead of as maximized/tabbed as is
expected in TabbedView.

Pick-to: 6.6 6.5
Fixes: QTBUG-114188
Change-Id: Ia7b2cfd07c51867707866a1f99f70129bbdc0e3e
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-11-17 23:07:01 +02:00
Alex Henrie
54656da9ac QMimeDatabase: handle buggy type definitions with circular inheritance
This fixes an infinite loop reported by a user who had both the
definition of text/javascript from shared-mime-info 2.3 and the
definition of text/javascript from shared-mime-info 2.4 installed at the
same time. In 2.3, text/javascript is a subtype of
application/ecmascript, but in 2.4 application/ecmascript is a subtype
of text/javascript. Having both at the same time resulted in circular
inheritance.

https://gitlab.freedesktop.org/xdg/shared-mime-info/-/merge_requests/258#note_2167707

[ChangeLog][QtCore][QMimeDatabase] Added code to detect and break
circular inheritance loops in the MIME data, which were causing infinite
loops

Pick-to: 6.6 6.5
Change-Id: Ic207b1593a49c7bb88e4fd810d8f88aa630087ce
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2023-11-17 02:50:11 +00:00
Dimitrios Apostolou
569320f402 Blacklist tst_Android::orientationChange because it's flaky
Task-number: QTBUG-119205
Change-Id: I2e143198dc1192747900fd38988a4819969fd662
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-11-16 20:22:38 +01:00
Assam Boudjelthia
37add5dcb8 Android: skip tst_qwidget::render()
Task-number: QTBUG-118984
Change-Id: Ie9f30608ae96dd53900501d7b5f90c38ca6bc40f
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-11-16 21:07:46 +02:00
Friedemann Kleint
cea33d7387 uic: Use fully qualified enum value for remaining cases
Task-number: PYSIDE-2492
Task-number: PYSIDE-1735
Task-number: QTBUG-118473
Change-Id: I4e5e328b0757145df2ceb550e2f90a64be91d5e9
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-11-15 23:40:24 +01:00
Friedemann Kleint
effe9bd026 uic: Write fully qualified enum values for QMainWindow enumerations
Task-number: PYSIDE-2492
Task-number: PYSIDE-1735
Task-number: QTBUG-118473
Change-Id: Ief50914bae3cc8e55f61113e8c8b6d6d24fe2c0f
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-11-15 23:40:24 +01:00
Friedemann Kleint
2e82796022 uic: Prepare for encountering fully qualified enum values in new .ui files
This means checks have to be rewritten using endsWith().

It mainly affects the QSizePolicy handling whose values originate from
different sources, including numbers. To address this, refactor the
code to deal with unqualified enum value names and introduce a helper
function that fully qualifies the enumeration when writing out.

Pick-to: 6.6 6.5
Task-number: PYSIDE-2492
Task-number: PYSIDE-1735
Task-number: QTBUG-118473
Change-Id: Iccbb884777aa9c696fbf48f9d7329353ef945b0f
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-11-15 23:40:24 +01:00
Assam Boudjelthia
d6861926a1 Android: set displayManager listener after QtLayout is initialized
the QtDisplayManager listener uses m_layout but it can be called
before m_layout is actually initialized, so set the listener after
the layout has been initialized.

Task-number: QTBUG-118077
Fixes: QTBUG-119007
Fixes: QTBUG-119134
Change-Id: Icebc350f09210c12dbd011f86ce88a90b6f27d12
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2023-11-15 22:52:23 +02:00
Tor Arne Vestbø
c3a1fe7bd7 Prevent reparenting of foreign window embedding container
A foreign window used to embed a Qt window into it should not end up
with changes to its own parent, as its only job is to give the embedded
Qt window a parent handle.

Pick-to: 6.6
Change-Id: If1bc89658fedf449d266bc0cc750c90b6a841a68
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2023-11-15 18:25:04 +01:00
Tor Arne Vestbø
189f9873ae macOS: Take window mask into account when computing QCocoaScreen::topLevelAt
Although not explicitly documented, this is the behavior in practice
on XCB and Windows, and we rely on this behavior in our implementation
of QApplication::widgetAt(), where we punch a temporary hole in the
widget using a mask if it has Qt::WA_TransparentForMouseEvents set.

Pick-to: 6.5 6.6
Fixes: QTBUG-41696
Task-number: QTBUG-119092
Change-Id: Ie7abc31b6930ee6b56fcdf391befc625c1ddf502
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-11-15 18:25:04 +01:00
Ivan Solovev
6658ccf5a1 Add QCborValue(StringLike) constructor benchmark
... to test the impact of migrating the underlying implementation to
QAnyStringView.

As a drive-by: use [[maybe_unused]] instead of Q_UNUSED in the
benchmark for operator[].

Task-number: QTBUG-101707
Pick-to: 6.6 6.5 6.2
Change-Id: I4bae7deadbe9bbd6f267364d78e94ea4541c1339
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-11-15 19:25:04 +02:00
Mårten Nordheim
f4c8e11ad7 tst_http2: increase testing for authenticationRequired
Make sure the reply is marked as finished and that the body is received
even if we didn't succeed.

In a real scenario that would include some text like Access Denied.

Also, no longer clear() the authenticationHeader in the server, since
that meant the server would not send the header again if the client
failed to authenticate. Luckily this wasn't actually causing any
problems before, since we only tested the expected www-authenticate
header.

As a drive-by: clang-tidy complained about not using const-ref for a
lambda.

Pick-to: 6.6 6.5 6.2
Change-Id: Ia4452fff7d9370d7d460433257d84eff0a6f469b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-11-15 13:18:13 +02:00
Jøger Hansegård
80a14c86b2 Add QTest option for repeating the entire test execution
Repeated test execution can be useful, under a debugger, to catch an
intermittent failure or, under memory instrumentation, to make memory
leaks easier to recognize.

The new -repeat flag allows running the entire test suite multiple times
within the same process. It works by executing all tests sequentially
before repeating the execution again.

This switch is a developer tool, and is not intended for CI. It can only
be used with the plain text logger.

Change-Id: I2439462c5c44d1c8aa3d3b5656de3eef44898c68
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-11-15 11:07:09 +00:00
Michael Weghorn
d2bf45c6ed a11y: Report strikethrough via text attribute
Let `QAccessibleTextWidget::attributes`
report whether strikeout is applied to text
via the "text-line-through-type" IAccessible2 text
attribute [1].
Use a value of "single" when strikeout is applied,
and "none" otherwise.

A previous change already implemented bridging that to
the corresponding AT-SPI "strikethrough" attribute.

Update the existing test tst_QAccessibility::textAttributes_data
to take into account that this attribute is reported
as well now.

[1] https://wiki.linuxfoundation.org/accessibility/iaccessible2/textattributes

Fixes: QTBUG-118106
Change-Id: I0416f00b1c11709d9cd0ca0ee38cc6df6caa6dcf
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2023-11-15 12:06:23 +01:00
Jøger Hansegård
8d367dec15 Add QUniqueHandle - a general purpose RAII wrapper for non-memory types
When interfacing with C-style APIs, such as the Windows API, resources
are often represented using handle objects. Lifetime management of such
resources can be cumbersome and error prone, because typical handle
objects (ints) do not give any help to release resources, and to manage
ownership.

Although std::unique_ptr can be retro-fitted with a custom deleter, and
helps transfer of ownership, it is inherently a pointer type. It can
therefore be clumsy to use with C-style APIs, particularly if the
invalid (uninitialized) handle value is not a nullptr. Also, the
std::unique_ptr does not work well when an allocating function returns
the handle as a pointer argument.

The QUniqueHandle addresses these issues by providing a movable only
value type that is designed as a RAII handle wrapper.

A similar handle wrapper exists in the Windows SDK, as part of the WRL
library. Unfortunately, this is Microsoft specific, and is not supported
by MINGW.

Since the QUniqueHandle is platform independent, it can be used also
with non- Microsoft platforms, and can be useful with other C-style APIs
such as FFmpeg or SQLite.

Pick-to: 6.6 6.5
Change-Id: Ibfc0cec3f361ec004febea5f284ebf75e27c0054
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-11-15 05:01:51 +01:00
Christian Ehrlicher
6259f4e7b4 QGuiApplication: check return value of platformTheme::palette()
Under some circumstances (e.g. setDesktopSettingsAware(false) on
windows) it may happen that the call to platformTheme::palette() returns
a nullptr which is not checked before dereferencing the pointer.
Therefore add a check for this to avoid a crash.

Fixes: QTBUG-111527
Change-Id: I6443d5d1a9b813f499d8f65b4fee55b0b8299b16
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-11-14 20:24:58 +01:00
Ahmad Samir
6e8563fb2d QStandardItem: store Qt::UserRole-1 in a static constexpr var
Change-Id: I809135aed1883130891863e7c8650d0b3e7f3a35
Reviewed-by: David Faure <david.faure@kdab.com>
2023-11-14 21:23:50 +02:00
Ahmad Samir
85eebedb16 QStandardItem: add note about reimplementing data/setData() wrt. flags
Extend the unittests.

Drive-by change: add missing include, otherwise static analyzers
(clangd) complain.

Fixes: QTBUG-105150
Pick-to: 6.6 6.5 5.15
Change-Id: I312133d5b35119e2e51002dfefe0e141c0708e3d
Reviewed-by: David Faure <david.faure@kdab.com>
2023-11-14 21:23:45 +02:00
Volker Hilsheimer
536fd29bdf JNI: Add convenience overloads for registerNativeMethods
Add a template overload for the QJniEnvironment member function so that
a declared type can be used.

And add a static registerNativeMethods class member function to declared
types.

As a drive-by, document the initializer_list overloads. The
"template <typename Class>" convenience wrappers are currently all
undocumented, as we first need to document the QtJniTypes type system
and declaration macros.

Change-Id: I8ff9edc4e493694e6d2c26d4bc7b06bd8e05bf0c
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-11-13 22:35:27 +01:00
Marcin Zdunek
c706011dc0 Add checking if using eglfs
We are using eglfs in VxWorks which make 3 few testcases fail, because eglfs windows are fullscreen by default.
This is the same solution as in qt5 in tag 5.12.6 from commit with hash 39027ef076c.

[...] EGLFS forces the first top-level window - either a QWidget or a QQuickView - to become fullscreen. [...]
from: https://doc.qt.io/qt-6/embedded-linux.html

Change-Id: I3ab3208b3c7c1b2e27d879bac1ee0679f48109e2
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-11-13 18:42:01 +00:00
Marc Mutz
51c75ae2ff tst_qxp_is_virtual_base_of: disable all warnings for GCC < 10
The -Winaccessible-base switch was added for GCC 10. Older GCCs had no
way to suppress the warnings, and the existing suppression of
-Winaccessible-base caused a warning of its own:

  qcompilerdetection.h:1125:49: warning: unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas]
   1125 | #define QT_DO_PRAGMA(text)                      _Pragma(#text)
        |                                                 ^~~~~~~
  qcompilerdetection.h:1150:49: note: in expansion of macro ‘QT_DO_PRAGMA’
   1150 | #  define QT_WARNING_DISABLE_GCC(text)          QT_DO_PRAGMA(GCC diagnostic ignored text)
        |                                                 ^~~~~~~~~~~~
  tst_is_virtual_base_of.cpp:53:1: note: in expansion of macro ‘QT_WARNING_DISABLE_GCC’
     53 | QT_WARNING_DISABLE_GCC("-Winaccessible-base")
        | ^~~~~~~~~~~~~~~~~~~~~~

Since GCC 8 and 9 are slowly fading away as supported compilers, the
simplest fix to get a clean build is to suppress all warnings for the
test on these compilers, by passing -w, as suggested by
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90449.

Short of moving the affected code into a separate header file and
applying `#pragma GCC system_header` to it, there appears to be no
other way to get rid of the warning.

Amends a1bdee4697.

Change-Id: I12eb1f8d486b1e2413675991659bf9ad3a7869ae
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-11-13 18:42:01 +00:00
Marc Mutz
ddce99989f Improve tst_QStringConverter::encodingForName_data()
Add more tests and DRY the code using the usual row() lambda trick.

Pick-to: 6.6 6.5
Change-Id: I810fba0ab2a96e740e67392155f9507675fe57ae
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-11-13 19:42:01 +01:00
Marc Mutz
47325e01b7 Rename QImageReader benchmark to tst_bench_
Helps finding it, e.g. in QtCreator, as it's now disambiguated from
tst_QImageReader, the auto-test.

As a drive-by, remove all empty functions.

Pick-to: 6.6 6.5 6.2 5.15
Task-number: QTBUG-114253
Change-Id: Icb0a3627488bbf4cb0c9d6bc9890f31a88096afd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-11-13 19:42:00 +01:00
Marc Mutz
54c25c7c31 tst_QFactoryLoader: remove unused member variable
Commit 862f42e806 removed the last use
of the Android-only `directory` member, but didn't remove the member's
definition.

Remove it now, probably fixing a Clang -Wunused-private-field warning
on Android.

Pick-to: 6.6 6.5 6.2
Task-number: QTBUG-87438
Change-Id: I67a1d97f29a0dde20ff29fb9b5bbaa5611cb9e17
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-11-13 19:42:00 +01:00
Tor Arne Vestbø
df834fde52 tst_QWindow::setVisibleThenCreate(): Fix unused argument warning
Use the arguments to call the parent class implementation.

Pick-to: 6.5 6.6
Change-Id: I602a66447fb8681b3ec9ef8e2e281828612d178c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-11-13 18:16:50 +00:00
Tor Arne Vestbø
db33628452 Ensure foreign window can be reparented out of contained window again
A foreign window embedded into a Qt hierarchy must also support
being removed from that window hierarchy.

Pick-to: 6.6
Change-Id: Id4d08079ff19d67a8989937bc72602e8bd14b31b
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-11-13 19:14:59 +01:00
Marc Mutz
9bccfb56c2 Q(Persistent)ModelIndex: use new test framework for op==
All good, except missing noexcept.

Can't test ordered relational operators because the classes provide
only op<, not the full set, so this has to wait until we port
Q*ModelIndex to the new comparison framework.

Change-Id: I05e26c88f0bd8c035ef0461c7c50b218c513da08
Reviewed-by: David Faure <david.faure@kdab.com>
2023-11-13 17:35:54 +02:00
Ivan Solovev
bfb237d19a TestLib: provide helper functions to test relational operators
The patch provides two sets of functions:
* functions to perform compile-time check for all cv-ref combinations
* functions that actually verify the comparison results for all
  cv-ref combinations.

For now it does not test operator<=>(), even if compiled with C++20,
because Qt types do not yet implement it.

The patch uses the new helper functions to improve testing of date and
time classes, because they already provide a full set of relational
operators.

Change-Id: I8bd869c489543719ea856d6609cac53cbd4dc122
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-11-13 16:35:54 +01:00
Christian Ehrlicher
e4315204b1 QDial: don't crash when min==max and setting a value != min & max
QDial::bound() is crashing when min == max due to a division by zero.
Therefore check for this condition beforehand and return min.

Pick-to: 6.6 6.5 6.2 5.15
Fixes: QTBUG-104641
Change-Id: I612625af1ad18333d59a7771abfdec602301b58e
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-11-12 23:45:30 +01:00