Commit Graph

58797 Commits

Author SHA1 Message Date
Edward Welbourne
da5dd84858 Add more tests of QLocale and "single character" data that aren't
This tests that strings using the first Unicode code-point of such a
multi-character token don't get recognized as "valid" number strings.
This would catch an implementation issue if the parsing code
mistakenly matched against only the first code-point of each "single
character" token.

It also adds tests of integer formatting, with multi-character sign,
and reworks some QStringView().toString()s to use u"..."_s.

Task-number: QTBUG-107801
Change-Id: I7b868ce2955bb322b3ecfc200438a21437090a0c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-11-11 16:32:53 +01:00
Edward Welbourne
cf36db4df9 Add benchmarks for QLocale number parsing
Based on those for QString, but with locale variation and exercising
some of the locales with multi-character signs and exponents.

Pick-to: 6.4 6.2 5.15
Change-Id: Id0253449f9abcc154285f89337aa0e26dd69900d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-11-11 16:32:52 +01:00
Edward Welbourne
7fef433004 Add benchmarks for QString number parsing
Based on the tests for QString::number(), but run in reverse, with
some embelishments. Also moved some shared code from number_*_data()
to their shared number_integer_common template.

Pick-to: 6.4 6.2 5.15
Change-Id: I74e7082372166c3cdbcd6bcbc31f9003e07cbcbc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-11-11 16:32:52 +01:00
Thiago Macieira
28d9f05fa1 Gtk3: fix stack smashing on mismatch between bool and gboolean
Glib is written in C and predates C99 (though not really, glib 2.0 was
released in 2002), so it defines gboolean as int, a 4-byte type. C++'s
bool is a 1-byte type, so this caused a buffer overflow.

Problem introduced in 2b77e779ce
("QGtk3Theme: implement appearance function to detect dark themes").

Pick-to: 6.2 6.4
Change-Id: Ieba79baf5ac34264a988fffd172650701fa54da8
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-11-11 06:44:26 -08:00
Thiago Macieira
e76bcaa203 QLocale: update the disabling of -Wfree-nonheap-object to GCC 10 only
Testing with 11 and 12 does not produce the warning.

Change-Id: I3d74c753055744deb8acfffd17243f3bd60e6855
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-11-11 07:44:26 -07:00
Axel Spoerl
52dcd47850 emit QWindow::windowStateChanged only when state has changed
Upon programmatic window state changes, windowStateChange was fired
once in QWindow::setWindowStates and once when the visual state had
been changed by the window interface.

This patch adds if guards to ensure that the singal is fired only once.

It adds a corresponding autotest to tst_QWindow.
tst_QWidget::resizePropagation() is adapted to no longer expect double
signal emission.

Fixes: QTBUG-102478
Pick-to: 6.4 6.2
Change-Id: If093c0a883d76d8a676e4fab90db6b0676452267
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-11-11 11:21:32 +01:00
Volker Hilsheimer
b58876c296 Windows: Inform accessibility system about the focused child item
When a complex object (i.e. one with children that are themselves not
fully exposed objects) gets focus, then we need to inform the
accessibility system about which child object actually has focus. This
was only done for item views, but not for other complex widgets.

An editable QComboBoxes is the focus proxy for its line edit. The line
edit never gets focus itself (QComboBox forwards relevant events),
and is the accessible child item with index 1. So when an editable
combobox gets focus, it needs to raise the automation event for the
line edit child.

Implement QAccessibleComboBox::focusChild to return the interface to the
lineedit for editable comboboxes so that the UI Automation bridge can
correctly notify about the focus being moved to an editable text input
field.

Fixes: QTBUG-107572
Pick-to: 6.4 6.2
Change-Id: Id60e2791ec859365255baa9bfd01547979cd2b44
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2022-11-11 10:21:32 +00:00
Tang Haixiang
de16300661 QTextLayout: Reconsider cursor drawing on TextObject
Revert: e99a883bd3
Revert: 33238ea2c6

These two commits made the drawing of the cursor incomprehensible,
but their purpose was to fix the problem of abnormal cursor drawing
when QScriptAnalysis::Object is present. Because objects require
some special handling, they can be specially aligned or floated.

Anyway, the alignment is already reflected by ascent and descent,
and when drawing, y = position.y() + (sl.y + sl.base() - base).toReal();
works fine. So roll them back now.

We just need to specially consider the case where the QScriptItem is a
QScriptAnalysis::Object, keeping the base and descent the same as the row.

Task-number: QTBUG-92468
Task-number: QTBUG-86823
Task-number: QTBUG-96288
Pick-to: 6.2 6.4
Change-Id: I6d9a0e00fbc3823e0cc8e0e8bd061da5782d1f8a
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-11-11 07:41:39 +01:00
Ahmad Samir
df82396123 QString: prevent crash in remove(pos, len)
If pos < 0, the code assumes it should count from end of string, i.e.
 pos += size(); if pos is still < 0, do nothing.

Change-Id: I5a90a082ec2833835ce0240d40a271f711a33f7e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-11-10 21:43:21 +02:00
Laszlo Agocs
3916c57718 Remove unused internal rhi backingstore parameters
There is no user for these at this point: QOpenGLWidget does not
need any of these by nature, whereas QQuickWidget is also currently
in the works-as-is category, it has no need to communicate the need
for additional Vulkan device extensions for example.

Pick-to: 6.4
Task-number: QTBUG-108277
Change-Id: Idc09552027377a21a0e904fbb9bfbd95c3d0e0a1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-11-10 20:25:20 +01:00
Jan Arve Sæther
6707efcb97 a11y: Add support for Tables in macOS bridge
For a11y purposes, a table needs to be mapped into a logical
accessibility hierarchy.  There are several ways of doing this mapping,
and unfortunately macOS expects something different than what
QAccessibleInterface does.

So suppose we have a a 2x2 QTableView with both horizontal and vertical
header like this (the names reflect the QAccessible::Role names):

  +-----------+--------------+--------------+
  |           | ColumnHeader | ColumnHeader |
  +-----------+--------------+--------------+
  | RowHeader | Cell         | Cell         |
  +-----------+--------------+--------------+
  | RowHeader | Cell         | Cell         |
  +-----------+--------------+--------------+

In order to be presented to the screen reader on a platform, it goes
through two rounds of mapping:

QAccessibleInterface will have all headers and cells as direct children of the table:

 - Table
   +- ColumnHeader
   +- ColumnHeader
   +- RowHeader
   +- Cell
   +- Cell
   +- RowHeader
   +- Cell
   +- Cell

macOS expects a deeper hierarchy:

 - AXTable [QAccessible::Table]
   +- AXRow     [Qt:no eqiuivalent]
      +- [QAccessible::Cell] (The content of the cell, e.g. AXButton, AXGroup or whatever)
      +- [QAccessible::Cell] (The content of the cell, e.g. AXButton, AXGroup or whatever)
   +- AXRow
      +- [QAccessible::Cell] (The content of the cell, e.g. AXButton, AXGroup or whatever)
      +- [QAccessible::Cell] (The content of the cell, e.g. AXButton, AXGroup or whatever)
   +- AXColumn (this seems to just store the geometry of the column)
   +- AXColumn (this seems to just store the geometry of the column)
   +- AXGroup   (this represents the column headers)
      +- AXSortButton (clicking a header cell will trigger sorting)
      +- AXSortButton (clicking a header cell will trigger sorting)

It's unclear to me how RowHeaders are mapped (they are rarer than
ColumnHeaders, I expect to find them in e.g. spreadsheet applications).
I haven't found any native usage of them. So this patch simply ignores
them.

Notice that macOS have a three layer deep hierarchy to represent a table
(Table->Row->Cell), while QAccessibleInterface has a two-layer deep
hierarchy (Table->Row/Cell).

In the macOS bridge we therefore need to "inject" the Row/Column element
to be "between" the table and the cell.

The table will take ownership of all row and column elements that are
children of the table. These elements are not inserted into the cache
(it would be pointless, since the cache is basically just a mapping
between the QAccessibleInterface -> QMacAccessibilityElement, and the
row and column elements does not have a corresponding
QAccessibleInterface to be mapped from).

The rows and columns are therefore also created as soon as the table
element is initialized, and they are stored in two NSMutableArray
members of QMacAccessibilityElement.

A table is constructed like any other accessibility element, with a
valid axid and synthesizedRole set to nil.
Each child row and column element is constructed with the same axid as the
parent table element, and they will have the synthesizedRole set to
either NSAccessibilityRow or NSAccessibilityColumn.
With the synthesizedRole member we can then identify if we are a row,
column or the actual table, and implement their respective behaviors.

Notice that the child row/column is created with the parent's table axid
in order for them to have a way of finding their parent table element.
(there is no 'parent' member variable in QMacAccessibilityElement)

This glorious scheme isn't pretty, but seems to work.

Fixes: QTBUG-37207
Change-Id: I7c2451e629f5331b9a0ed61dc22c6e74a82cc173
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-11-10 19:50:14 +01:00
Fushan Wen
2cf5253b91 Send accessible focus event after list view has focus
QListView::currentChanged sends an accessible focus event even if the
list view doesn't have focus. For screen readers like Orca, accessible
focus events will be ignored if the target item does not have focus
when screen reader receives the event.

This corrects the behavior by calling QAbstractItemView::currentChanged
before sending an accessible focus event.

Pick-to: 6.4
Change-Id: I71732f62e2f27d7856b4781b268495b88b24b715
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2022-11-10 18:29:52 +00:00
Alexey Edelev
60b5ca5a23 Use module-specific names for 'module_headers[_generated]' files
Fix the syncqt issue when two modules are created in the same
CMakeLists.txt and share the build directory. In this case the
second module in the dependency chain rewrites
'module_headers[_generated]' files, so syncqt is not able to
proccess these files correctly.

Amends b89d63515b

Task-number: QTBUG-87480
Change-Id: Ibdcb66e96bdaabadc1c51611f5ed4a637d2f797f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-11-10 19:29:52 +01:00
Axel Spoerl
baa1228b43 Fix type mismatch compiler warning in tst_QGlyphRun
When comparing a glyphIndex with a hard coded number, the number is
cast to an int, whereas the glyphIndex is an unsigned int.
That causes a compiler warning.

This patch forces the numbers to be cast to an unsigned int.

Change-Id: I8a31124c6afacfc4ecfb13caf2cb8133dad44a21
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-11-10 17:16:59 +01:00
Axel Spoerl
3cadb68a59 Fix unused variable compiler warning in tst_qpalette
Debug serials and detatch numbers of deep and shallow detatch in test
function cacheKey, if it fails.
That implicitly removes a compiler warning about these variables being
unused.

Change-Id: I481f4b63e3ed0d50fb442dffc658b97d913059bc
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-11-10 17:16:59 +01:00
Assam Boudjelthia
e4125863f0 Add permissions feature example and manual test to the build
And add license headers and some minor fixes for warnings in the
example and test.

Task-number: QTBUG-90498
Change-Id: I34592f7f2844c92c25a6a676c8ac1ffca9e03c6d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-11-10 17:54:02 +02:00
Tor Arne Vestbø
12a74666b7 Remove unused tst_qwidget_mac_helpers.h/mm
The usage of the helpers was removed in 2011,
in bf8dfc394a.

Change-Id: I950812982148fd76bcc65c4781a144c21cb3c901
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-11-10 13:31:01 +01:00
Thiago Macieira
224d795ec9 QPlainTestLogger: include extra information in each result
RESULT : tst_MyClass::QString_toInt()
     367 nsecs per iteration (total: 3,672,848, iterations: 10000)
     1,019 CPU cycles per iteration, 2.775 GHz (total: 10,193,637, iterations: 10000)
     3,123 instructions per iteration, 3.055 instr/cycle (total: 3,123,000,194, iterations: 1000000)
     536 branch instructions per iteration, 1.459 G/sec (total: 5,360,022, iterations: 10000)

Change-Id: I3c79b7e08fa346988dfefffd17203fff3ff5b774
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-09 21:34:13 -07:00
Thiago Macieira
f341e99aab QPlainTestLogger: don't print "RESULT" before each additional result
We do that by passing the full list of results to the logger, to a
virtual that is present in the base class to call the existing
function. For all but the plain logger, we'll just print multiple
results. The plain logger now prints:

RESULT : tst_MyClass::QString_toInt()
     383 nsecs per iteration (total: 3,837,324, iterations: 10000)
     1,069 CPU cycles per iteration (total: 10,692,457, iterations: 10000)
     3,123 instructions per iteration (total: 31,230,101, iterations: 10000)
     536 branch instructions per iteration (total: 5,360,022, iterations: 10000)

Change-Id: I3c79b7e08fa346988dfefffd17203cb5802693dd
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-09 20:34:12 -08:00
Thiago Macieira
0e8eb20af4 QPlainTestLogger: simplify printBenchmarkResult()
Avoids having lots of buffers that occupy the stack.

Change-Id: I3c79b7e08fa346988dfefffd17203c5045a7fc86
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-09 21:34:11 -07:00
Johannes Kauffmann
c958e5daf1 tests: fix build with -no-feature-concurrent
Pick-to: 6.2 6.4
Change-Id: I91602931bfb63e7d6659599a26e00e0bc4f854ab
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-11-09 20:33:49 +01:00
Laszlo Agocs
514ae97640 rhi: metal: Move macOS 13 pipeline cache workaround to the backend
To allow removing the MACOS && IOS ifdefs from Qt Quick. The check is
taken care of by the QRhi Metal backend instead.

The logic is now slightly more sophisticated than just outright
skipping the whole feature: we know that the problems (crash on
M1/M2, and suspicious, constant blob size increases also on Macs
with Intel graphics once upgraded to macOS 13) are triggered when
new render/compute pipelines are registered to a MTLBinaryArchive
that already loaded some data from a file serialized in a previous
run of the application. Therefore, we just skip registering new
pipelines when we believe it is not going to be safe. The rest of
the persistent pipeline cache support is left intact and operates
normally.

Task-number: QTBUG-106703
Task-number: QTBUG-108216
Change-Id: Id3cc931dfbd940a3e6820ee9294459e4993e9ca7
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-11-09 19:02:00 +01:00
Ahmad Samir
fee46831fd QThread/Unix: use chrono for time arithmetic
Change-Id: I090d204db6126b3b6336637779b190509a9f0778
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-11-09 20:01:59 +02:00
Mårten Nordheim
7898de4258 QNetworkInformation[Win]: Fix potential use-after/during-free
The WinRT NetworkStatusChanged callback may happen during or slightly
before we unregister our token, which we usually follow up by destroying
the object. So we have to avoid potentially doing work on a deallocated
object.
Do this using the old QPointer-trick. Neither me nor reporter can
reproduce it locally, so this is only a best-measure.
Further problems may be that the storage for the lambda has already
been destroyed and repurposed, in which case the pointer may be valid,
but junk, which would lead to another crash. But this is unavoidable as
long as MS does not synchronize callbacks with (un)registering new
callbacks. To attempt combatting this we hold our own lock around
unregistration and the "meat" of the callback.

Pick-to: 6.4 6.4.1
Fixes: QTBUG-108218
Change-Id: Iacf8b8f458cca3152ff395e9a38e8df193534f46
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-11-09 15:14:54 +01:00
Volker Hilsheimer
7cc0a8741c Make QMacMime::canConvert a non-virtual helper for other virtuals
Implementors are expected to return whether the converter can convert
both ways between a mime and a uti. However, this is implied in the
mimeForUti and utiForMime functions, and almost all converter implemented
canConvert by returning mimeForUti(uti) == mime.

A notable exception is the QMacMimeTypeName implementation, which can
only convert from from mime to uti using hard-coded special format names
and dummy data to provide place holders for drag'n'drop operations that
originate in Qt. That converter returned always false from canConvert,
but mapped the special "application/x-qt-mime-type-name" mime type to
the special "com.trolltech.qt.MimeTypeName" uti. Since nobody ever
requests data as "com.trolltech.qt.MimeTypeName", we still always ignore
that converter. The uti is then special-cased in the QMacClipboard code.

Lower-level code where only mime type or UTI are known can still call
the virtuals directly and check whether the returned string is empty,
which indicates that the converter does not support the conversion.

As a drive-by, fix coding style and variable naming.

Change-Id: I3d5d60faa82f8b31d9873c9da0097a308b9eeb50
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-11-09 13:22:30 +01:00
Volker Hilsheimer
2bdc027f5c macOS: delay initialization of small font
During construction of a QStyle, QApplication might not yet be
initialized, e.g. when calling QApplication::setStyle("macOS") before
constructing QApplication. In that case, we cannot access the platform
theme.

We don't just want to skip initializing the small font either though.
Store the smallSystemFont as a std::optional so that we can initialize
it once, when the first widget gets polished.

As a drive-by, remove the unused miniSystemFont variable.

Fixes: QTBUG-108047
Pick-to: 6.4 6.2
Change-Id: Id750770a563611fdbc6c7031fe102a99ea692be7
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
2022-11-09 13:22:29 +01:00
Shawn Rutledge
963f3c678c QTextDocument::loadResource(): invoke parent via direct connection
If QTextDocument::loadResource() gets called from a different thread
than the thread that the QTD object (and *necessarily* its parent, if it
has one) live in, we would get the warning "Unable to invoke methods
with return values in queued connections". Rather, ensure that it's
invoked only via a direct connection.

Amends ac300a166f

Pick-to: 6.4
Task-number: QTBUG-35688
Change-Id: I35644f7cd54b1f40362d3d45c2a120883f7a2e61
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-11-09 13:22:29 +01:00
Ahmad Samir
cb9d76169a QFileSystemEngine/Unix: remove futimes related code
- futimes isn't a standard system call[1]:
«
This system call is nonstandard.  It was implemented from a specification
that was proposed for POSIX.1, but that specification was replaced by the
one for utimensat(2).

A similar system call exists on Solaris.
»
[1] https://man7.org/linux/man-pages/man2/futimesat.2.html
[2] https://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html

- futimens is a standard system call[2], it's available on:
 - Linux: https://man7.org/linux/man-pages/man2/futimesat.2.html
 - FreeBSD: https://www.freebsd.org/cgi/man.cgi?query=futimens&sektion=2&n=1
 - OpenBSD: https://man.openbsd.org/futimens.2
 - QNX: https://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.lib_ref/topic/f/futimens.html

So, remove futimes related code.

Change-Id: I58ac466f08161a88219e3a32eab98d168f065140
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-11-09 14:22:29 +02:00
Tor Arne Vestbø
ef935f6e37 Plumb public permission APIs to Android backend
The lock and unlock of the Android deadlock mutex is now part
of the internal implementation instead of limited to the enum
based permission API. It is unclear why 8bca441b6f added
the guard only to this API and not to the string based API
as well.

The check for isBackgroundLocationApi29 has been removed,
as the logic seemingly resulted in accepting every single
permission type except location permissions if used via
the enum-based API.

Since Android's platform permission API doesn't have an
Undetermined status, we keep a hash of the status for each
permission type, and by default checkPermission() would
return Undetermined, until a requestPermission() call
is done which updates the internal hash, and after that
checkPermission() would return properly Granted/Denied.

Task-number: QTBUG-100413
Change-Id: Ia95c76af754481a281bc90198e349966c9c2da52
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-11-09 14:22:29 +02:00
Thiago Macieira
64dc886db7 tst_QVariant: convert some test functions to table-driven
Most of them were easy to change. The pair one was a bit of a stretch,
but still worked. I've removed the lines on QPair, since QPair is
std::pair in Qt 6.

Change-Id: I3d74c753055744deb8acfffd17246ec98c583d08
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-09 04:05:50 -07:00
Thiago Macieira
bdc8778d7a QVariant: add support for numeric comparisons for char16_t and char32_t
Change-Id: I3d74c753055744deb8acfffd17248af45fd20556
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-09 04:05:50 -07:00
Thiago Macieira
cf0a1c2e51 QVariant: fix comparison of enums to numerics
qIsNumericType does not return true for enum types, which meant we never
called numericCompare() or numericEquals() when one of the types was an
enum.

Task-number: QTBUG-108188
Change-Id: I3d74c753055744deb8acfffd172449c68af19367
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-09 04:05:50 -07:00
Thiago Macieira
da6efbb12b QVariant: simplify getting integer contents by using the type size
This reduces the chances of mistakes in forgetting a type. Plus, this
makes it easier to add char16_t and char32_t.

Drive-by change some type().id() code that doesn't need the ID for user
types to typeInterface()->typeId.

Change-Id: I3d74c753055744deb8acfffd17248aa81bf8ce55
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-09 04:05:50 -07:00
Thiago Macieira
8a3a87d13c QVariant: move the NaN comparison into the spaceShip function
Note: NaN = not Not A Naan

Change-Id: I3d74c753055744deb8acfffd17248a02f7968121
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-09 04:05:50 -07:00
Thiago Macieira
a3b4fffc04 QVariant: use QPartialOrdering for the internal comparison functions
Avoids having to have a convertOptionalToPartialOrdering() function
to convert back.

std::optional<int> is 64 bits on any platform, though it's returned in
registers for the IA-64 C++ ABI. Unfortunately, that's not the case for
Windows.

Change-Id: I3d74c753055744deb8acfffd172480eee189b3b2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-09 04:05:50 -07:00
Thiago Macieira
9ad44f28c1 QVariant: merge the equality and ordering compare functions
As we're not doing any deep analysis, the code is almost exactly the
same anyway. It is possible to simplify further by avoiding the
signed/unsigned conversion rules, but it's not worth the
effort. Instead, we can share code.

Change-Id: I3d74c753055744deb8acfffd17248a5c51cbbfcb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-09 04:05:50 -07:00
Thiago Macieira
393d5efda3 QVariant: make a major simplification in the numeric comparison
The code implementing the C++ rules of type promotion and conversion
was too pedantic. There's no need to follow the letter of the standard,
not when we can now assume that everything is two's complement (this was
true for all architectures we supported when I wrote this code in 2014,
but wasn't required by the standard).

So we can reduce this to fewer comparisons and fewer rules, using the
size of the type, not just the type ID.

Change-Id: I3d74c753055744deb8acfffd172446b02444c0c0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-09 04:05:50 -07:00
Thiago Macieira
250ca8d5f8 QVariant: get rid of output argument to qConvertTo{Real,}Number
Change-Id: I3d74c753055744deb8acfffd1724476a2e0e5a49
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-09 04:05:50 -07:00
Milla Pohjanheimo
e36abea63b Add binary compatibility file generated against 6.4.0
Generate bc file using the "new way".

Task-number:QTBUG-106331
Pick-to: 6.4
Change-Id: I70d2c0e5026636deee1b8389f50f51e075187b76
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2022-11-09 13:18:42 +03:00
Thiago Macieira
a90f041a0a QPlainTestLogger::formatResult: use QByteArray instead of QString
Avoids operating in UTF-16 and having to convert.

Drive-by fix int to qsizetype.

Change-Id: I3c79b7e08fa346988dfefffd17203b044914d68d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-09 02:18:45 -07:00
Thiago Macieira
dbc9467ca3 QBenchlib/Perf: use one system call to enable/disable measurements
The man page says the prctl() should apply to any performance counters
measuring the current process, so it should work with a perf stat
started with --delay=-1... but I couldn't make that work.

Change-Id: I3c79b7e08fa346988dfefffd172032f06cc10fa0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-09 02:18:45 -07:00
Thiago Macieira
1fef390ad7 QBenchlib/Perf: use C++11 range-fors for the event list
This code predated C++11 and thus had a sentinel element.

Change-Id: I3c79b7e08fa346988dfefffd17202ef3f9735683
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-09 02:18:45 -07:00
Thiago Macieira
3cafd26c1d QBenchlib/Perf: parse multiple counters from -perfcounter
Change-Id: I3c79b7e08fa346988dfefffd17202ec98947308e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-09 02:18:45 -07:00
Thiago Macieira
4731baf6d3 QBenchlib: add support for a measurer reporting multiple results
Implemented for the Linux Perf measurer, with four measurements by
default.

RESULT : tst_MyClass::QString_toInt():
     149.574444 CPU cycles per iteration (total: 149,574,445, iterations: 1000000)
RESULT : tst_MyClass::QString_toInt():
     620.000181 instructions per iteration (total: 620,000,182, iterations: 1000000)
RESULT : tst_MyClass::QString_toInt():
     131.000046 branch instructions per iteration (total: 131,000,047, iterations: 1000000)
RESULT : tst_MyClass::QString_toInt():
     32.118771 nsecs per iteration (total: 32,118,771, iterations: 1000000)

Change-Id: I3c79b7e08fa346988dfefffd17202cda3df8431b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-09 02:18:45 -07:00
Thiago Macieira
b5b00e7790 QBenchlib: use QBenchmarkMeasurerBase::Measurement in QBenchmarkResult
Change-Id: I3c79b7e08fa346988dfefffd17202a818cde1d84
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-09 02:18:44 -07:00
Thiago Macieira
985b942152 QBenchlib: pass the metric type alongside the measurement value
And pass the value in a qreal, which is what QBenchlib stores
anyway. This increases the code size a little because the conversion
from integer to qreal is in multiple places, but doesn't meaningfully
increase the overhead: in the SysV ABI, we still return Measurement in
registers and even using the floating point registers where applicable.

This is the first step in allowing the Perf benchmarker to benchmark more
than one event.

Change-Id: I3c79b7e08fa346988dfefffd172027a8677f17c0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-09 02:18:44 -07:00
Thiago Macieira
0f55580ec5 Update the poll-exit-on-error code: include the message for everyone
I think it's useful for everyone to know what error it was, not just if
it's about to abort. And then simply abort() when we want to.

Change-Id: I3d74c753055744deb8acfffd1724c5b2b293ca9a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-11-08 23:07:22 -07:00
Thiago Macieira
fd34da6c47 Update the poll-exit-on-error feature to be private
User code shouldn't have to know about this.

Amends 0e1ce757d5.

Change-Id: I3d74c753055744deb8acfffd1724c5282f60ea59
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Dominik Holland <dominik.holland@qt.io>
2022-11-08 23:07:21 -07:00
Axel Spoerl
ca254a0937 Stabilize flakiness in tst_QOpenGLWidget
qWaitForWindowActive was called in two test functions without
activating the relevant widget.
This patch adds widget activation before calling
qWaitForWindowActive.

Helper function verifyColor:
A loop made six comparison attempts of widget size, pixel color and
image with a 200ms waiting time after each unsuccessful attempt.
The widget size was tested at the beginning of the loop.
The test was failed on the first size mismatch, which occurred when
verifyColor was called before the widget was rendered.
That has lead to flakiness (e.g. on openSuSE).

This patch encapsules each check in a lambda and calls qWaitFor to
ensure event processing until each condition has become true.

Change-Id: Ic98f93c8acf41459bc728f2969fe8b01768048dd
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-11-08 21:51:14 +01:00
Tor Arne Vestbø
fe67c69643 tst_QGraphicsEffectSource: Reset effect repaint count after flushing events
Follow-up to 8222e06d12, which only reset
the item repaint count.

Flushing the queued paint events will bump numRepaints, and the whole
point of calling reset() is to prepare a consistent state before the
next test, so we need to call it after flushing the events.

Pick-to: 6.2 6.4
Change-Id: Id1fe840c14c0940d7020cf8f8cc6a3aeceaa5fb5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-11-08 19:44:59 +01:00