Commit Graph

15570 Commits

Author SHA1 Message Date
Ivan Solovev
516d828f24 QCborValue: add benchmark for operator[]
In order to test the impact of migration to QASV.

Task-number: QTBUG-101707
Pick-to: 6.6 6.5 6.2
Change-Id: I17f84ca98fc87d89bb4cd6ad98c8a12aecd315ee
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-06 16:17:52 +02:00
Edward Welbourne
54c2383e81 Add _tzset() call before mktime() on MS
Add a change-of-zone manual test, based on a bug-report by Felix
Kälberer. This failed: debugging revealed that MS's mktime() doesn't
pick up a change to system zone.

Fixes: QTBUG-83881
Change-Id: I9b86398ef870627a059e269f85a0f5d9d9de284b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-09-05 22:41:35 +02:00
Volker Hilsheimer
e73f35d9c6 QPrintDialog on macOS: Don't crash when parent is not a window
The test case is an incomplete version of the test that will be added to
verify the fix for the referenced bug report. The test crashes already
when showing the dialog without this fix.

Task-number: QTBUG-116277
Pick-to: 6.6 6.5 6.2
Change-Id: I969a723157f6453b78bafae5cb24a6b37b1eea50
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-09-05 22:41:35 +02:00
Dennis Oberst
b134718c11 QString: use new assign() in operator=({QByteArray, QChar, char *})
operator=(~) and assign() share similar names but, until now, have not
shared the same functionality. This patch introduces the usage of
QString::assign() within the non-sharing assignment operators to
effectively boost efficiency by reusing the available capacity.

Since we're re-using the capacity we update the test case in places
where they don't hold true anymore.

Since these assignment operators are frequently used in many places,
both within Qt and non-Qt code, this patch comes with benchmarks.

The preview of the benchmark results are compared with this patch and
before this patch. The results show a boost in performance for the
QByteArray and 'const char*' overload. The QLatin1StringView overload
already preserved the capacity and has a better performance than the
assign() alternative, so don't us it there.

(x86_64-little_endian-lp64 shared (dynamic) release build (O3); by
gcc 13.2.1, endeavouros ; 13th Gen Intel(R) Core(TM) i9-13900K

benchmarks executed with -perf -iterations 1000000

  * The last value at the EOL represent the string size.

QString &operator=(const QByteArray &a) (current)
  64.3  cycles/iter; 300  instructions/iter; 17   nsec/iter (5)
  65.8  cycles/iter; 366  instructions/iter; 12   nsec/iter (10)
  62.9  cycles/iter; 301  instructions/iter; 11.5 nsec/iter (20)
  61.3  cycles/iter; 315  instructions/iter; 11.1 nsec/iter (50)
  71.4  cycles/iter; 386  instructions/iter; 13   nsec/iter (100)
  136.9 cycles/iter; 811  instructions/iter; 24.5 nsec/iter (500)
  245.8 cycles/iter; 1394 instructions/iter; 42.5 nsec/iter (1'000)

QString &operator=(const QByteArray &a) (before)
  78   cycles/iter; 399  instructions/iter; 15.3 nsec/iter (5)
  82.3 cycles/iter; 465  instructions/iter; 15   nsec/iter (10)
  76.7 cycles/iter; 400  instructions/iter; 14   nsec/iter (20)
  79.5 cycles/iter; 414  instructions/iter; 14.5 nsec/iter (50)
  91.4 cycles/iter; 485  instructions/iter; 16.7 nsec/iter (100)
  189  cycles/iter; 910  instructions/iter; 34.4 nsec/iter (500)
  320  cycles/iter; 1666 instructions/iter; 56   nsec/iter (1'000)

QString &operator=(const char *ch) (current)
  70  cycles/iter; 317  instructions/iter; 12   nsec/iter (5)
  71  cycles/iter; 383  instructions/iter; 12.3 nsec/iter (10)
  64  cycles/iter; 318  instructions/iter; 11.1 nsec/iter (20)
  69  cycles/iter; 340  instructions/iter; 12   nsec/iter (50)
  77  cycles/iter; 419  instructions/iter; 13.5 nsec/iter (100)
  141 cycles/iter; 899  instructions/iter; 24.4 nsec/iter (500)
  280 cycles/iter; 1518 instructions/iter; 48.4 nsec/iter (1'000)

QString &operator=(const char *ch) (before)
  86.7  cycles/iter; 416  instructions/iter; 15   nsec/iter (5)
  87.8  cycles/iter; 482  instructions/iter; 15.7 nsec/iter (10)
  82.4  cycles/iter; 417  instructions/iter; 14.3 nsec/iter (20)
  90.2  cycles/iter; 443  instructions/iter; 15.6 nsec/iter (50)
  101.4 cycles/iter; 518  instructions/iter; 17.7 nsec/iter (100)
  204.4 cycles/iter; 994  instructions/iter; 36.5 nsec/iter (500)
  337.9 cycles/iter; 1789 instructions/iter; 58.9 nsec/iter (1'000)

 * current implemented as: assign(other)
QString &operator=(QLatin1StringView other) (current)
  47.4 cycles/iter; 237 instructions/iter; 8.2  nsec/iter (5)
  46.2 cycles/iter; 237 instructions/iter; 7.9  nsec/iter (10)
  46.8 cycles/iter; 255 instructions/iter; 8    nsec/iter (20)
  59   cycles/iter; 273 instructions/iter; 10.2 nsec/iter (50)
  55   cycles/iter; 300 instructions/iter; 9.5  nsec/iter (100)
  94.3 cycles/iter; 525 instructions/iter; 16.3 nsec/iter (500)
  166  cycles/iter; 804 instructions/iter; 28.7 nsec/iter (1'000)

QString &operator=(QLatin1StringView other) (before)
  14  cycles/iter; 79  instructions/iter; 2.5  nsec/iter (5)
  14  cycles/iter; 79  instructions/iter; 2.6  nsec/iter (10)
  16  cycles/iter; 97  instructions/iter; 3    nsec/iter (20)
  19  cycles/iter; 115 instructions/iter; 3.5  nsec/iter (50)
  23  cycles/iter; 142 instructions/iter; 4.2  nsec/iter (100)
  91  cycles/iter; 367 instructions/iter; 16.6 nsec/iter (500)
  131 cycles/iter; 646 instructions/iter; 23.4 nsec/iter (1'000)

Task-number: QTBUG-106201
Change-Id: Ie852f6abd1cf16164802acddb048eae5df59758f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-05 20:58:47 +02:00
Marc Mutz
5a96d13bb5 QCheckBox: add new checkStateChanged(Qt::CheckState) signal
... to replace the old stateChanged(int) one, which a) had the wrong
name and b) the wrong argument type.

Mark the old one as \obsolete, so new users don't see it
anymore. Prepare for deprecation in the test, but don't actually
deprecate, yet (this author does not know how to deprecate signals).

Found in API-review.

Amends 37b47ebf94.

As a drive-by, replace explicit qWait() calls with QTRY_COMPARE().

[ChangeLog][QtWidgets][QCheckBox] Added new
checkStateChanged(Qt::CheckState) signal, obsoleting
stateChanged(int).

Fixes: QTBUG-104688
Change-Id: I01791fd003b752c47d99bea65151202be9175c21
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-09-05 13:43:44 +00:00
Dennis Oberst
c8be7c6a6c tst_QString: assign(it,it) add test-cases for empty range
Pick-to: 6.6
Change-Id: Iaf2ddb247aa279166110ad8793b1e37e66e8b11b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-09-05 15:00:38 +02:00
Ilya Doroshenko
1eb15adee3 Add stereo support for DirectX12 and Vulkan backends
Change-Id: Id12723d6c392e25935ccb265c58af91aff968984
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-09-05 10:28:42 +00:00
Santhosh Kumar
4cf92d83c3 Reset palette resolve mask in windows vista style
The palette set by windows vista style during polish doesn't allow style-
sheet style to override it.

This patch reset resolve mask for the palette set by windows vista style
and thus it can be overridden.

Fixes: QTBUG-115511
Pick-to: 6.6 6.5
Change-Id: Ifcaf441f806cfa0273599b3dce83fdfaec3f5a66
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-09-05 10:59:00 +02:00
Ahmad Samir
0ce51dee0e tst_QDnsLookup: fix typo in CMakeListst.txt
There was an extra `q` before dnslookup.

Found while trying to build tst_qdnslookup, the target wasn't seen by
CMake/Ninja.

Pick-to: 6.6
Change-Id: Id594aab30dc9081fc269541561e0f2db5e615657
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-09-04 14:17:12 -07:00
Ahmad Samir
9b40272562 tst_QDnsLookup: skip a unittest on Windows
See code review 496440 on Gerrit for the details.

Change-Id: Ibd32a44cf7e2e07f36687cc2f0eeaf3008f64e73
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-09-04 22:40:35 +03:00
Ahmad Samir
909893344c tst_qeventdispatcher: port to QDeadlineTimer
Easier logic for these use-cases.

Change-Id: I97a18c45d9bd8cfcfee5d379d271366276d5a435
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-04 22:40:35 +03:00
Mårten Nordheim
6577242adf tst_QString: deduplicate datatags
By saying what's special about some of them

Pick-to: 6.6 6.5
Change-Id: I17bf2e12a27bf55f621020ddf3819ee9e606847d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-04 12:00:48 +02:00
Thiago Macieira
961620824c QArrayData: make calculateBlockSize() account for the extra null element
Instead of adding it after the block size was calculated. This makes no
difference for non-growing (exact) blocks. For growing blocks, this
means we take that extra element into account before rounding to the
next power of two, instead of after. That results in a change of the
thresholds of when a block grows and also what capacity it will
contain.

For example, for a QString growing to 22-25 elements:

      Request     |       Previously        |           Now           |
elements |  bytes | malloc()ed | capacity() | malloc()ed | capacity() |
    22   |    44  |        66  |        24  |        64  |        23  |
    23   |    46  |        66  |        24  |        64  |        23  |
    24   |    48  |        66  |        24  |       128  |        55  |
    25   |    50  |       130  |        56  |       128  |        55  |

To avoid wasting elementSize - 2 bytes in this footer, we only include
this footer if elementSize <= 2. Thus, for a QList<int> growing to 11-13
elements:

      Request     |       Previously        |           Now           |
elements |  bytes | malloc()ed | capacity() | malloc()ed | capacity() |
    11   |    44  |        66  |        12  |        64  |        12  |
    12   |    48  |        66  |        12  |       128  |        28  |
    13   |    52  |       130  |        28  |       128  |        28  |

In both cases, we now only allocate powers of two while growing, which
may be beneficial to some allocators.

Pick-to: 6.6
Change-Id: Ifa1111900d6945ea8e05fffd177dcb96e251d0a1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-09-03 17:43:24 -07:00
Ivan Solovev
d752da1857 QAnyStringView: fix construction from QL1SV for bootstrapped builds
The SizeShift was not taken into account when constructing QASV from
QL1SV. This is not an issue in normal Qt builds, because SizeShift == 0
there.
But in bootstrapped case (and in future Qt 7) SizeShift changes to 2,
and the bug becomes visible.

The added test-cases do not really reveal the issue, because we do
not run tests in bootstrapped builds, but at least they will help
to prevent the issues in Qt 7.

Pick-to: 6.6 6.5 6.2
Change-Id: I337b37b5230323a5357f48fd1c9bf799ca507d52
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-03 18:22:06 +02:00
Ivan Solovev
1ad424aed5 QLocal{Socket,Server}: extend the test coverage for property bindings
The pre-existing test for QLocalServer was testing only a minor subset
of cases, so replace it with the call to
QTestPrivate::testReadWritePropertyBasics.

The test for QLocalSocket's bindable properties was missing, so add
it.

The new tests didn't reveal any problems.

Task-number: QTBUG-116346
Pick-to: 6.6 6.5
Change-Id: I695bb050d39eeae9ffb84c097c36601a4ca89af6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-09-03 18:20:59 +02:00
Ivan Solovev
96a62cd1f5 tst_QDnsLookup: extend test coverage for property bindings
The pre-existing tests were not using the QTestPrivate helpers, so
extend them with the call to QTestPrivate::testReadWritePropertyBasics.

The updated test didn't reveal any problems with binding loops, so no
other action is required for now.

Task-number: QTBUG-116346
Pick-to: 6.6 6.5
Change-Id: I51a17974a7f5bec3c969fcb55b6f28e3e9218eb5
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-03 18:20:56 +02:00
Ivan Solovev
ac59fcdab8 QStandardItemModel: extend the test coverage for property bindings
The pre-existing tests were not using the QTestPrivate helpers, so
extend them with the call to QTestPrivate::testReadWritePropertyBasics.

The updated test didn't reveal any problems with binding loops, so no
other action is required for now.

Task-number: QTBUG-116346
Pick-to: 6.6 6.5
Change-Id: I360614a40fe2bacb796051607ed67e7e666b4f22
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-09-03 18:20:54 +02:00
Ivan Solovev
7d70edd31c QTimer: extend property tests and fix binding loop
The bindable property tests were not using the QTestPrivate helpers, so
add a new test which uses them.

The new tests revealed a binding loop for the interval property.
Fix it in a usual way by explicitly removing the binding and using
{set}ValueBypassingBindings() in the setter.

Task-number: QTBUG-116346
Pick-to: 6.6 6.5
Change-Id: If94f57938da449a68e3527aead5ebd55ba410adb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-09-03 18:20:51 +02:00
Ivan Solovev
cdb50edc98 tst_QMovie: extend the test coverage for property bindings
The old tests were not using the test methods from QTestPrivate, so
add another test case.

Task-number: QTBUG-116346
Pick-to: 6.6 6.5
Change-Id: I291ede26461e79a615630f1decad2ad7549b4dd8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-09-03 18:20:48 +02:00
Ivan Solovev
6a873778b9 QAbstractProxyModel: fix binding loops
... by using valueBypassingBindings() when accessing the properties
from the setters.

This commit is mostly trivial.
Had to change the template parameters in the unit-test, because the
updated QTestPrivate::testReadWritePropertyBasics() creates an instance
of the TestedClass, and QAbstractProxyModel cannot be instantiated,
since it has pure virtual methods.

Task-number: QTBUG-116346
Pick-to: 6.6 6.5
Change-Id: I0cae29263ea9bb92c9de06891b0ba8633fb9fd72
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-09-03 18:20:33 +02:00
Ivan Solovev
22c2c15b27 QSequentialAnimationGroup: extend bindable property unit tests
The bindable property tests should use the helper functions from
QTestPrivate.

Task-number: QTBUG-116346
Pick-to: 6.6 6.5
Change-Id: Ie1a61ab80e6f737eac02246214c2c93129a1cf94
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-09-03 18:20:21 +02:00
Ivan Solovev
b64e36240b QPauseAnimation: extend tests and fix binding loop
Extend the unit-tests for bindable properties and fix the discovered
binding loop by using {set}ValueBypassingBindings() in the setter of
the duration property.

The code refactoring does not modify the setter logic, because
previously the binding was anyway implicitly removed when calling the
assignment operator. The updated code just does it explicitly.

Task-number: QTBUG-116346
Pick-to: 6.6 6.5
Change-Id: I0f339d182efb60500ee7f12e407f200d739da312
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-09-03 18:20:18 +02:00
Thiago Macieira
2b06d41b46 tst_QFileInfo: don't trigger libstdc++ std::filesystem bug
libstdc++'s std::filesystem::path implementation incorrectly assumes
that any 8-bit char input is UTF-8, when it patently isn't on Windows.

Reported at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111244

Pick-to: 6.5 6.6
Fixes: QTBUG-116609
Change-Id: I2b24e1d3cad44897906efffd17803f2862935c9b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-09-01 13:05:45 -07:00
Thiago Macieira
9e8c93fac1 tst_QFileInfo: replace a portion of a macro with a lambda
It's very hard to debug a macro.

Pick-to: 6.5 6.6
Change-Id: I2b24e1d3cad44897906efffd17803b8eac9bd844
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-09-01 13:05:40 -07:00
Thiago Macieira
5b9e2f31bd tst_QFileInfo::stdfilesystem: add extra Unicode string tests
Pick-to: 6.6
Change-Id: I2b24e1d3cad44897906efffd17803f70bd4d60f6
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-09-01 13:05:34 -07:00
Volker Hilsheimer
c59b34b8cf QAccessible: consistently respect rootIndex of item views
Accessibility implementations rely on correct information about the
model dimensions when operating on item views. An item view that has a
root index set needs to report it's size based on the root index, rather
than for the view's model directly.

Pass the rootIndex to all calls to QAbstractItemModel::column/rowCount.
Refactor the code to avoid excessive dereferencing of a QPointer, apply
const and fix/improve coding style in touched lines.

Emit a ModelReset notification when the root index changes, or (in the
case of QListView) when the model column changes.

Split long Q_ASSERTs into multiple lines to be able to better trace the
exact reason for an assertion, and replace the assert with an early
return of nil when it's plausible that a cached cell is no longer part
of the view (i.e. because the root index changed).

Add a test case that verifies that changing the root index changes the
dimension of the view as reported through the accessibility interface.

Pick-to: 6.6 6.5
Fixes: QTBUG-114423
Change-Id: I7897b79b2e1d10c789cc866b7f5c5dabdabe6770
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2023-09-01 18:03:29 +02:00
David Faure
1b39e61a77 QMimeDatabase: fix detection of pattern conflict in different prefixes
Installing a second mimetype with *.txt as glob had a different
effect depending on whether it was installed into the same prefix
or a different prefix as the one where text/plain is installed.

Pick-to: 6.6
Change-Id: I7f54b8efe22f620eb57257745c48fe5402c87626
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-01 15:04:33 +02:00
Shawn Rutledge
801b8304fb Add QTextDocument* constructor argument to QTextMarkdownImporter
QTextMarkdownImporter::import() took a QTD* as if it would be ok to
reuse one instance of QTextMarkdownImporter for repeated importing into
different documents; but in practice, we never do that: in fact it's
usually a short-lived, stack-allocated object, as in
 QTextMarkdownImporter(&doc, QTMI::DialectGitHub).import(input);
So it's less clumsy internally to require the document be provided to
the constructor: that way a QTextCursor can be constructed immediately
too, as part of the importer object rather than separately on the heap.

This is private API, unused outside qtbase.

Change-Id: I8041ceb33cb7e7608df55dc5a963292c585afb90
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2023-09-01 08:17:29 +02:00
Volker Hilsheimer
d027b0c816 Constrain QCoreApplication::requestPermission to compatible functors
The 6.5 versions of the overload not taking a context/receiver object
were constrained by requiring a functor to be free function or lambda.
207aae5560 removed that constraint, which
might be source incomaptible if wrapper functions in user code forward
the constraint using Expression SFINAE. Those wrappers would no longer
be removed from the overload set based on the same criteria as the
function they wrap.

We can't constrain the new functions based on the same predicate as
before, as after the simplification we have only one overload with, and
one without context object. But we can still remove overloads for
incompatible functors.

Add the respective scenario to the QPermission test as a compile-time
test.

Found during 6.6 header review.

Pick-to: 6.6
Change-Id: Id21391b4a6b78a29de2f8fa04374f4262e5fafa7
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-09-01 03:30:50 +02:00
Axel Spoerl
a7d7634f1b Implement QSignalBlocker::dismiss()
...to set m_o to nullptr and prevent an existing QSignalBlocker from
touching the QObject, which it was created for.
Add documentation and implement an autotest.

Change-Id: Ic18e80af5a57df1928f9d36aa0ab7ad79b6525fd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-08-31 22:11:51 +00:00
Axel Spoerl
38380de63c tst_qstatictext: Fix CMake condition
Private libraries were linked conditional to QT_FEATURE_private_tests in
the CMake file. qstatictext_p.h was included conditional to developer
build. A developer build fails, with test enabled and private tests
disabled.

=> Change the CMake condition to QT_FEATURE_developer_build, to resolve
mismatch between CMake and cpp file.

Pick-to: 6.6 6.5 6.2
Change-Id: I79213e7d3c38851b8b80cb8ab248d7bff750c227
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-08-31 22:11:51 +00:00
Axel Spoerl
41c8d215f2 tst_QSplitter: fix compiler warning
QLabel *l is declared uninitialized, assigned in a for loop. The last
object is deleted for testing purposes.
This leads to a false compiler warning about deleting a potentially
unintialized pointer.

=> initialize with nullptr to silence the warning.

Pick-to: 6.5 6.6
Change-Id: I1422b04fc1fdbfc7248de577884aabfb539f3f4b
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-09-01 00:11:51 +02:00
Axel Spoerl
70b57c943a tst_qsslkey: Fix CMake condition
Private libraries and WrapOpenSSL were linked conditional to
QT_FEATURE_private_tests in the CMake file.
qsslkey_p.h and open ssl symbols were included conditional to developer
build. A developer build fails, with test enabled and private tests
disabled.

=> Change the CMake condition to QT_FEATURE_developer_build, to resolve
mismatch between CMake and cpp file.

Pick-to: 6.6 6.5
Change-Id: I3ac93b02701e467a0b548c35d441d35a45c4568b
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-09-01 00:11:51 +02:00
Axel Spoerl
4f4a8e75ab QItemSelectionModelPrivate: use QObjectPrivate::connect
QItemSelectionModelPrivate::initModel() uses string based connections,
to connect/disconnet its QAbstractItemModel.
The QObject::destroyed signal is connected to modelDestroyed(), which
does not disconnect other signals.

QQuickTableView's selection model binds to its QAbstractItemModel.
The binding also reacts to QObject::destroyed
Eventually, QItemSelectionModel::setModel(nullptr) is called.
At this point, only a QOBject is left from the QAbstractItemModel.
That leads to warnings about disconnecting string based signals, which
belong to QAbstractItemModel.

This patch changes the connect syntax to the QObjectPrivate::connect
API. Instead of keeping a list of string based connections around, the
connections themselves are kept in a list member. Disconnecting happens
based on that list.
Connections are also disconnected in
QAbstractItemModelPrivate::modelDestroyed.

An auto test is added in tst_QItemSelectionModel.

Fixes: QTBUG-116056
Pick-to: 6.6 6.5 6.2
Change-Id: I57e5c0f0a574f154eb312a282003774dd0613dd6
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-09-01 00:11:51 +02:00
Thiago Macieira
763592b238 tst_selftests: add a way to run a subset of all subprograms
This functionality was lost when we switched to Catch2.

Change-Id: I2b24e1d3cad44897906efffd177fb4cff641546f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-08-31 06:26:25 +00:00
Thiago Macieira
f1ba2b9f44 tst_selftests: deduplicate the Unix/Linux conditions
Amends 118f2210c6. That commit added

 #ifdef Q_OS_UNIX
     if (test == "assert"
         || test == "crashes"
         || test == "failfetchtype"
         || test == "faildatatype")
     return; // Outputs "Received signal 6 (SIGABRT)"
 #endif

Which duplicated 4 out of the 5 tests in the block:

 #ifdef Q_OS_LINUX
    // QEMU outputs to stderr about uncaught signals
    if (QTestPrivate::isRunningArmOnX86() &&
        (test == "assert"
         || test == "crashes"
         || test == "faildatatype"
         || test == "failfetchtype"
         || test == "silent"
        ))
        return;
 #endif

But as Linux is Unix, we never got to that second block for those 4
tests.

Pick-to: 6.6
Change-Id: I2b24e1d3cad44897906efffd177fb4b5507d190a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-08-30 23:26:25 -07:00
Morten Sørvig
c802a9e987 wasm: rename JsString -> EcmaString
QString::fromJsString -> QString::fromEcmaString()
QString::toJsString() -> QString::toEcmaString()

For API naming compatibility with QByteArray::fromEcmaUin8Array()

Pick-to: 6.6
Change-Id: If6e2121e31e630d6728ed24e41d14b763f395aaa
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2023-08-30 23:02:03 +02:00
Tor Arne Vestbø
4ba7a76985 Allow QObjects to opt in to receiving ParentAboutToChange/ParentChange
QWidget already handles this, but it might be useful for non-Widget
object hierarchies as well, such as in Qt Quick.

The flag is opt in, and as QWidget already handles these events by
itself (without checking any flags), we assert that we don't end up
in this code path, instead of enabling it for QWidget. The latter
would mean refactoring the QWidget code, with possible regressions.

Docs and header comments have been updated to reflect that this
event is not widget specific. (This is an issue with other events
as well, that are documented to say "widget", since they came
from a time when there was only QWidget, but nowadays apply to
e.g. QWindow as well. That's something for another fix though).

Change-Id: Ib71962131d6011c17dcce8c01bd8adcdaa58d798
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-08-30 15:45:41 +02:00
Timur Pocheptsov
a323f05c5e tst_QSslSocket: don't use deprecated RSA api
OpenSSL 3.1.2 can be configured with no-deprecated option, in this
case test fails to build.

Pick-to: 6.6 6.5 6.2
Change-Id: Icaf457f55fb001b632922856dbe4bbb5bdba220e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-08-29 20:15:05 +02:00
Thiago Macieira
ac8fe3e645 QtNetworkSettings: narrow down hasIPv6 to specific OSes
It's currently conditional on two features used in QNetworkInterface.
The fact that QNetworkInterface misses those two features is probably
correlated to the failures observed on QNX, but is not the cause, so
this code was actually wrong and was possibly disabling the execution of
similar content on other OSes.

Therefore, this commit removes them and changes the conditional to
exclude the OS that is failing (QNX).

I find this situation unacceptable.  IPv6 support is mandatory for any
application after 2011-01-31, the date when IANA delegated its last IP
block, and definitely after 2019-11-25, when RIPE NCC ran completely
out. But since there's no SDK available for it, I'll grudgingly accept a
grandfathered exception because there's nothing I can do about it (I
tried to fix it; look at the change history of this patch set). I will
block any new OSes in that situation, though.

Task-number: QTBUG-116503
Change-Id: Ifa1111900d6945ea8e05fffd177ed6979c3e5916
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-08-29 07:20:51 -07:00
Thiago Macieira
fd924ab0b6 tst_QUdpSocket: move up the search for IPv6-capable interfaces
Let's do it in initTestCase(), where we're already searching for IPv6
addresses, instead of storing the information in a local static.

Pick-to: 6.6
Change-Id: Ifa1111900d6945ea8e05fffd177efb6a055aaa58
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-08-29 07:20:50 -07:00
Thiago Macieira
2e51fbf89a tst_QNetworkInterface: enable IPv6 detection for Windows
This was disabled in d0d1d74033, I guess
accidentally, by a too-wide conditional. The change the same commit
applied to QtNetworkSettings didn't make the same mistake.

I am also opportunistically updating the conditional to QT_CONFIG (I
missed this in 9d4579c1cd) and adding the
Linux-specific check, as the AF_NETLINK implementation does not rely on
getifaddrs() or if_nametoindex().

Drive-by fix indentation.

Pick-to: 6.6
Change-Id: Ifa1111900d6945ea8e05fffd177ef8fcb11b4e1e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-08-29 07:20:49 -07:00
Krzysztof Sommerfeld
44d274a29f Add 'thread_local' definition as it is not available in C mode for VxWorks
Task-number: QTBUG-115777
Change-Id: I42c54ac2a34817f3b0a9b687ee282b97123b78c9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-08-29 13:27:06 +00:00
Thiago Macieira
19673b6cf9 tst_qdnslookup: fix the location of the opcode in the header
We were reading the wrong byte with the wrong shift count.

 4.1.1. Header section format

 The header contains the following fields:

                                    1  1  1  1  1  1
      0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                      ID                       |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |QR|   Opcode  |AA|TC|RD|RA|   Z    |   RCODE   |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                    QDCOUNT                    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                    ANCOUNT                    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                    NSCOUNT                    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                    ARCOUNT                    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

This diagram is big-endian, so bit 0 is the MSB.

Change-Id: I964c2b1e6b834feb9710fffd177bb72110bb77e7
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-28 20:09:41 -07:00
Laszlo Agocs
80520c2f52 Enable QWidget::grab() with QRhiWidget in the widget tree
This involves reimplementing QWidgetPrivate::grabFramebuffer().
Widgets call this function whenever a texture-based widget is
encountered.

This implies however that we rename QRhiWidget's own, lightweight
grab function, grab(), because it kind of shadows QWidget's grab().
Switch back to grabFramebuffer() which is what QQuickWidget and
QOpenGLWidget both use.

Supporting QWidget::grab() is particularly important when grabbing
an ancestor of the QRhiWidget, because that has no alternative.
Right now, due to not reimplementing the QWidgetPrivate function,
the place of the QRhiWidget is left empty.

In addition, grabFramebuffer() is now const. This is consistent
with QQuickWidget, but not with QOpenGLWidget and QOpenGLWindow.

Change-Id: I646bd920dab7ba50415dd7ee6b63a209f5673e8f
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2023-08-28 21:14:28 +02:00
Mikolaj Boc
5c5c9dd830 Main thread-proxy localStorage oprations in native WASM QSettings
localStorage is unavailable on workers. Operations will now get proxied
to the main thread instead.
This - among other benefits - makes tst_QSettings::testThreadSafety
pass.

Task-number: QTBUG-115509
Change-Id: Iebbe5e9f9069948f8728e0a82628cc082b30de12
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-08-28 17:53:29 +02:00
Piotr Wierciński
c95555e9f7 CI: Enable tests under auto/wasm on Wasm platform
Change-Id: Ib017f59b06cc5a7df73ad9f9a0c036670d6458b0
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-08-28 14:10:02 +02:00
Thiago Macieira
a0550df6d9 tst_QFile: extend virtualFile() to test in unbuffered mode too
Change-Id: Ifbf974a4d10745b099b1fffd1777acb752350375
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-25 15:54:15 -07:00
Thiago Macieira
7ca82250e0 tst_QFile: update virtualFile() to check if readLine() reads all
We know that all lines from /proc/<PID>/maps end in a newline, so we
trim exactly that one byte, then we put it all back together with
.join('\n') to check if we've read the entire file.

Linux virtual files are usually served in 4 kB increments; tst_qfile's
maps file is about 16000 bytes for me, just short of the QIODevice buffer:

[pid 414315] read(5, "55c6afe04000-55c6afe11000 r--p 0"..., 16384) = 4049
[pid 414315] read(5, "7f215fd25000-7f215fd26000 r--p 0"..., 12335) = 4038
[pid 414315] read(5, "7f2160800000-7f21608c7000 r--p 0"..., 8297) = 4072
[pid 414315] read(5, "7f216119f000-7f21611a0000 rw-p 0"..., 4225) = 3994

It is not a coincidence that the reads are at line boundaries, though
it's not a guarantee from the kernel.

We appear to have accidentally fixed the QEMU emulation bug by reading
another process' /proc/<PID>/maps (hypothesis: QMU emulates the target
system in /proc/self, hiding itself in maps, but makes no translation
for other process map files.

Change-Id: Ifbf974a4d10745b099b1fffd1777ac919b12dc90
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-25 22:54:08 +00:00
Alexey Edelev
d02c3151b2 Disable android_deployment_settings test for non-standalone scenario
The test changes couple variables to emulate the user project
environment. These variables also affect the policy handling.
The test will build and work properly only if tests are built
standalone. So add this limitation.

Amends 2e340cea88

Pick-to: 6.6
Change-Id: I0cc49bf55bf7763e4c3ecdfa5333fb0453f06794
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-08-25 18:37:23 +02:00