Commit Graph

62593 Commits

Author SHA1 Message Date
Ahmad Samir
74422bbf02 QTimerInfoList: refactor unregisterTimers()
- Use removeIf(), easier to reason about than removing from the list
  during iteration
- Return true only if any timers were actually unregistered
- Assert in QObject::event() that if the list returned by
  eventDispatcher->registeredTimers() isn't empty, then
  eventDispatcher->unregisteredTimers() returns true

Change-Id: I739a3865b7524a7aab3ff0227e6a060ed98d6191
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-07-19 19:40:51 +03:00
Ahmad Samir
fa42350c8d QTimerInfoList: use std::upper_bound/rotate
Change-Id: I80899a8c652ac724b0efd82815dddc061fe9f5e8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-07-19 19:40:50 +03:00
Dennis Oberst
464461dea6 QString: make isEmpty(), length() and size() noexcept
They have no preconditions and cannot throw.

As a drive-by, merge the definition of isEmpty() into its declaration.

Pick-to: 6.6
Change-Id: Ifffa0d4cb2a285bb802d39d10a757be9c31cfae1
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-07-19 13:13:20 +00:00
Alexandru Croitor
0cae76c2af CMake: Specify correct \since version for android variable
The QT_ANDROID_DEPLOY_RELEASE variable was added in 6.5.1, not 6.5.2.

Amends 64db65ae90

Pick-to: 6.5 6.6
Fixes: QTBUG-115318
Task-number: QTBUG-112921
Task-number: QTBUG-108132
Task-number: COIN-882
Change-Id: I912fecfc918914709aa5cb9c42c67317f7d3dc89
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-07-19 14:16:55 +02:00
Alexey Edelev
f73249b94d Put arguments in correct order in syncqt parseVersion
Amends 4d4e74e1bcad47476b947b6e3781b046f9505f83

Pick-to: 6.6
Change-Id: Ie3a0147b414303c528b78c20f6502b83c5102344
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-07-19 14:16:55 +02:00
Mårten Nordheim
061ab84e98 QHostInfo: fix leaking slot object
We were not ref'ing or deref'ing the slot object in the various places
that owned it. So, if, in the end, the QHostInfoResult object didn't
call the slot we would leak the slot object.

Pick-to: 6.6 6.5 6.2 5.15
Fixes: QTBUG-115263
Change-Id: I45f43756c7589470045d97b59257ccfd85a325b7
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-07-19 14:16:55 +02:00
Alexey Edelev
1e3bf10786 Do not generate the deprecated 'QtSql/qsql.h'
Task-number: QTBUG-115029
Change-Id: I1fe496864ce25f20421ca78fbde3fe4eb4b9fc49
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2023-07-19 13:51:36 +02:00
Marc Mutz
dc7820a296 QMetaCallEvent::create: extract template-argument-independent code
Extract Method create_impl() with all the stuff that doesn't depend on
create()'s template arguments, which will reduce compile time and
amount of generated code.

Pick-to: 6.6
Change-Id: I9d8f59c168873ac3527b570ef6142079824061cf
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-07-19 11:38:02 +00:00
Marc Mutz
cec711092f Port SlotObjectGuard to SlotObjUniquePtr
Pick-to: 6.6 6.5
Change-Id: I81e64db7e1be9076494bee15bbca372ebffeb3e0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-07-19 13:38:02 +02:00
Marc Mutz
56651915e8 QFutureInterface: port to new SlotObjUniquePtr
... removing a ### comments to that effect.

Pick-to: 6.6
Change-Id: I635ca9593ec72a66d328ff6de61cd311c1b4e89f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-07-19 13:38:02 +02:00
Marc Mutz
c58074b42d QSlotObjectBase: add Deleter and typedef for a unique_ptr using it
Use it in QMetaCallEvent, to have some automatic test coverage. Other
code that might benefit has undergone changes since 5.15, so will be
ported one-by-one to avoid conflicts on cherry-picks.

Pick-to: 6.6 6.5
Change-Id: I566bab1803e3675f75a9fdf294a4b0f047d21c11
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-07-19 11:38:02 +00:00
Ivan Solovev
4601717378 Guard xmlstream header in a source-compatible way
Using QT_REQUIRE_CONFIG results in a static_assert if the xmlstream
feature is not available. This is a SiC change, as the user has
no reasonable ways to guard against it.
Fix it by using

 if QT_CONFIG(xmlstream)

instead.

This commit amends 7337474d04

Pick-to: 6.6
Change-Id: I0c55e4cff06157743c05a543a092f9be1eb67c2d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-07-19 11:56:52 +02:00
Jaishree Vyas
7c2ecfcf29 Doc: List of all Qt overviews which are now termed as explanation
The autogenerated list of overviews was adding the \group command which
included all the groups instead of overviews.
The idea here is to categorize the overviews later on once we have
the list of all overviews.

Task-number: QTBUG-114762
Pick-to: 6.5 6.6
Change-Id: I3cf53886be277abc86b5ec54d399cd6933fbe882
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2023-07-19 10:36:59 +02:00
Marc Mutz
69d767bec2 tst_QHostInfo: fix mem-leaks in threadSafetyAsynchronousAPI()
Allocate participating threads and objects on the stack, not the heap.

As a drive-by, port from QList to C arrays (never use a
dynamically-sized container for statically-sized data™).

Code predates the public history, all active branches are affected.

Pick-to: 6.6 6.5 6.2 5.15
Change-Id: If8def658c1c7b505074938d637e78ad2d1f9fd57
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-07-19 04:52:28 +00:00
Marc Mutz
7470794865 QMetaCallEvent::create(): re-order operations
... so that everything that requires argv is done first.

Also introduce a new variable, argc, for sizeof...(Args) + 1.

This will allow us to apply Extract Method to the tail end, which now
no longer depends on argv or Args.

As a drive-by, port from std::array to C arrays so we can use
automatic array size deduction: There's still no such thing as partial
CTAD (certainly not in C++17), so if we wanted std::array to deduce
the size, we'd also need to let it deduce the type; and we don't want
to add an ugly cast to the nullptr). C arrays, OTOH, can deduce the
size while fixing the type since K&R C.

Pick-to: 6.6
Change-Id: I5a694d4f4d41974eb4b1075ff030bbef902ed492
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-07-19 04:52:14 +00:00
Marc Mutz
65647d54b9 tst_QSortFilterProxyModel: fix mem-leaks II: sortStable()
Like in 9f8449a054, for
doubleProxySelectionSetSourceModel(), the sortStable() test also
leaked _everything_. Fix in the same way, by allocating model and view
on the stack intead of the heap.

With this patch, tst_QSortFilterProxyModel is now asan-, but not
ubsan-clean (and, because of
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110704, asan still
reports a leak in cp-demangle.c, which should be™ gone once we fix the
rest of QTBUG-99563).

Pick-to: 6.6 6.5 6.2 5.15
Task-number: QTBUG-115264
Change-Id: Ic0e833d7336435e324457f9d9667ee8573a7dafc
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-07-19 04:51:26 +00:00
Yuhang Zhao
b3930b03cd Windows QPA: fix mail launch in case parameter is wrong
Done-with: Ilya Fedin <fedin-ilja2010@ya.ru>
Pick-to: 6.6 6.5
Change-Id: I7b24ed64533cdf26f3f3d7dba4b5e80490be269c
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Timothée Keller <timothee.keller@qt.io>
2023-07-19 04:43:06 +00:00
Mitch Curtis
14d10c632b Doc: explain how to create a QToolBar
Surprisingly, this wasn't mentioned in the detailed description at all.

Users would need to click on the link for the example in the "See also"
section and then read through it to find any mention of how tool bars
are created.

Pick-to: 6.2 6.5 6.6
Change-Id: I9db23b475009072f34defab38b6d6200a45f2f35
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-07-19 10:23:38 +08:00
Michael Weghorn
4f9c66131d a11y uia: Bridge QAccessibleSelectionInterface
Bridge QAccessibleSelectionInterface that was introduced
in commit 9d16d5e224 to
UIA's ISelectionProvider and ISelectionProvider2 interfaces
by extending the existing WindowsUiaSelectionProvider
to make use of the QAccessibleSelectionInterface.

Also make use of that interface to implement handling
for the ISelectionProviderItem interface methods when
an object has a parent that implements the
QAccessibleSelectionInterface.

Sample use from NVDA's Python console [1] with this
commit in place:

1) start NVDA
2) run the interview example (examples\widgets\itemviews\interview\interview.exe)
3) select "Item 1:0", "Item 2:0" and "Item 3:0" by left-clicking
   on "Item 1:0" in the left view, then shift+clicking on "Item 3:0".
4) press Numpad_insert+control+z to start the NVDA Python console and
   capture snapshot variables
5) query and use the interfaces using NVDA's Python console:

    >>> import UIAHandler
    >>> selectionpattern2 = focus.parent.UIAElement.GetCurrentPattern(10034).QueryInterface(UIAHandler.IUIAutomationSelectionPattern2)
    >>> selectionpattern2.CurrentFirstSelectedItem.CurrentName
    'Item 1:0'
    >>> selectionpattern2.CurrentLastSelectedItem.CurrentName
    'Item 3:0'
    >>> selectionpattern2.CurrentItemCount
    3
    >>> selectionitempattern = focus.UIAElement.GetCurrentPattern(10010).QueryInterface(UIAHandler.IUIAutomationSelectionItemPattern)
    >>> selectionitempattern.CurrentIsSelected
    1
    >>> selectionitempattern.RemoveFromSelection()
    0
    >>> selectionitempattern.CurrentIsSelected
    0
    >>> selectionpattern2.CurrentItemCount
    2
    >>> selectionitempattern.Select()
    0
    >>> selectionitempattern.CurrentIsSelected
    1

(Note that calling selectionitempattern.AddToSelection
in that example would also unselect all other currently
selected entries, because the underlying implementation
has a selection mode of QAbstractItemView::SingleSelection
set in QAccessibleTree::selectRow, which gets called
from QAccessibleTable::select via QAccessibleTableCell::selectCell.)

[1] https://www.nvaccess.org/files/nvda/documentation/developerGuide.html#PythonConsole

Change-Id: I7003bae5bbcfd5c685620bf710781165ed70f106
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2023-07-18 21:49:53 +01:00
Michael Weghorn
3bace699bf a11y uia: Support ISelectionProvider2
Support UIA's ISelectionProvider2 interface [1]
in addition to ISelectionProvider.

The ISelectionProvider2 interface inherits from the
ISelectionProvider interface.

A follow-up commit that will introduce bridging the
QAccessibleSelectionInterface, introduced in commit
9d16d5e224.

While at it, also reserve space for the amount
of children in the QList in QWindowsUiaSelectionProvider::GetSelection
before inserting them one by one, to avoid reallocations.

Sample use of the ISelectionProvider2 interface from NVDA's
Python console [2] with this commit in place:

1) start NVDA
2) run the gallery example (examples\widgets\gallery\gallery.exe)
3) click on the "Style" listbox at the top
4) press Numpad_insert+control+z to start the NVDA Python console and
   capture snapshot variables
5) query and use the interface using NVDA's Python console

    >>> import UIAHandler
    >>> iselection2 = focus.parent.UIAElement.GetCurrentPattern(10034).QueryInterface(UIAHandler.IUIAutomationSelectionPattern2)
    >>> iselection2.CurrentItemCount
    1
    >>> iselection2.CurrentFirstSelectedItem.CurrentName
    'windowsvista'
    >>> iselection2.CurrentLastSelectedItem.CurrentName
    'windowsvista'

[1] https://learn.microsoft.com/en-us/windows/win32/api/uiautomationcore/nn-uiautomationcore-iselectionprovider2
[2] https://www.nvaccess.org/files/nvda/documentation/developerGuide.html#PythonConsole

Change-Id: I43642e9e39b63c65da97af976cc322a8e5868170
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2023-07-18 22:49:53 +02:00
Mårten Nordheim
90af40ccd0 Handle authenticate challenge for Negotiate
Because we didn't handle Negotiate in the "Start" phase during
handleAuthenticateChallenge, we would not emit the auth signal before
our second attempt, assuming the server prompts us for one.

Emitting the authenticationRequired signal is needed for users
to be able to set the Service Principal Name (SPN) option.
Alternatively, username and password if not relying on Single sign-on.

Done-by: Emil Wipplinger <>
Pick-to: 6.6 6.5
Fixes: QTBUG-114559
Change-Id: I833c08dfeda36a6548c5ad6b8af4b8aa9d644c45
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-07-18 19:18:59 +02:00
Axel Spoerl
31da999542 QGenericUnixThemesDBusListener: Remove stray qDebug()
Remove a stray qDebug() statement, that was forgotten in the source.

Pick-to: 6.6 6.5
Change-Id: I5c413b4356f05570474fa2a0d6ad661785c818b0
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-07-18 14:37:53 +00:00
Ivan Solovev
32d44b612c QMutex: add missing <chrono> include
std::chrono is still used in the header.
Do not rely on transitive includes, instead include the header
explicitly.

Pick-to: 6.6
Change-Id: If9140499e5dccf0065a4826831d3b83813910318
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-07-18 15:53:07 +02:00
Ivan Solovev
7a33a08376 QSemaphore: add missing <chrono> include
std::chrono is still used in the header.
Do not rely on transitive includes, instead include the header
explicitly.

Pick-to: 6.6
Change-Id: I2cf5dc275c3272151efd655a4fa85936942c5708
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-07-18 15:53:07 +02:00
Edward Welbourne
d6dacfecb1 Fix warning in recently-added testlib snippet
Amends commit fa296ee1dc to implement
MyObject::startup(), mark it void (its return was ignored) and flag
its static wrapper as [[maybe_unused]] to calm a compiler warning.

As a drive-by, fix indentation of the class definition.

Change-Id: I3918bf8a4625a7e2b4e6d4e0cbfa68a337115865
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-07-18 15:28:07 +02:00
Kai Köhne
892448b6e0 Make Qt headers work with MSVC /W4
This requires explicitly marking constexpr if conditions to fix C4127
issues:

  qtbase/src/corelib/text/qstringbuilder.h(112):
  error C2220: the following warning is treated as an error
  qtbase/src/corelib/text/qstringbuilder.h(112):
  warning C4127: conditional expression is constant
  qtbase/src/corelib/text/qstringbuilder.h(112):
  note: consider using 'if constexpr' statement instead

Change-Id: I9787fb37099f811c52f93c94c9edb4da8aafdfe5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-07-18 14:48:19 +02:00
Marc Mutz
3bb488fb2a Use new QByteArray::assign() in QTlsBackendOpenSSL::dhParametersFromPem()
QBA::assign() re-uses existing unshared capacity(), if any, and is
therefore potentially more efficient than = QByteArray(.,.) (and never
slower).

Pick-to: 6.6
Task-number: QTBUG-106201
Change-Id: I2c45aa268c4c06396e9d7e0490666a13d8cfd532
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-07-18 12:14:09 +02:00
Marc Mutz
676087ef1f QSslDiffieHellmanParameters: fix mem-leak
Says ASAN:

    Direct leak of 524 byte(s) in 1 object(s) allocated from:
    #0 0x7f708f0a67cf in __interceptor_malloc ../../../../gcc/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x7f707d94bf9e in CRYPTO_malloc crypto/mem.c:196
    #2 0x7f707d7bd248 in asn1_item_flags_i2d crypto/asn1/tasn_enc.c:65
    #3 0x7f707d7bd1b7 in ASN1_item_i2d crypto/asn1/tasn_enc.c:45
    #4 0x7f707d85b7be in i2d_DHparams crypto/dh/dh_asn1.c:54
    #5 0x7f7075a82223 in q_i2d_DHparams(dh_st*, unsigned char**) qsslsocket_openssl_symbols.cpp:435
    #6 0x7f7075a82223 in QTlsBackendOpenSSL::dhParametersFromPem(QByteArray const&, QByteArray*) const qssldiffiehellmanparameters_openssl.cpp:139
    #7 0x7f708ca9b588 in QSslDiffieHellmanParametersPrivate::initFromPem(QByteArray const&) qssldiffiehellmanparameters.cpp:285
    #8 0x7f708ca9b588 in QSslDiffieHellmanParameters::fromEncoded(QByteArray const&, QSsl::EncodingFormat) qssldiffiehellmanparameters.cpp:94
    #9 0x55fd8a545ebe in tst_QSslDiffieHellmanParameters::constructionPEM() tst_qssldiffiehellmanparameters.cpp:98
    [...]

The pointer returned in the out-parameter of a i2d_DHparams() call is
supposed to be OPENSSL_free()ed by the user (this is not at all
obvious from the docs¹, but an SO answer² indicates that's how it
should be (as well as asan stopping from complaining with this
patch applied)).

¹ https://www.openssl.org/docs/man3.1/man3/i2d_DHparams.html
² https://stackoverflow.com/a/53563669.

Amends 2cf63c71eb.

[ChangeLog][QtNetwork][SSL] Fixed a memory leak in parsing of
PEM-encoded Diffie-Hellman parameters.

Pick-to: 6.6 6.5 6.2 5.15
Change-Id: I9ed4a26c4676db1c0d54a1945a4fb5014ce568cd
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-07-18 12:13:54 +02:00
Marc Mutz
51edc438dd tst_QAbstractItemModelTester: fix mem-leak
QThreeWidgetItems that have been removed from their parents (or the
widget) must be deleted manually. The treeWidgetModel() test forgot
that, driving asan nuts.

Code predates the beginning of the public history, so picking to all
active branches.

Pick-to: 6.6 6.5 6.2 5.15
Change-Id: I139549b0bd8baf4abfb90f926f6290119471046f
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-07-18 12:13:30 +02:00
Marc Mutz
bad3b8f78b tst_QNetworkDiskCache: fix mem-leak
A caller of Q(Abstract)NetworkDiskCache::data() is supposed to delete
the returned value, and this caller forgot.

Do it now; better late than never.

Amends feb1afc782.

Pick-to: 6.6 6.5 6.2 5.15
Change-Id: I1b27663df9ad49e0203172265d224fdb6ec06646
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-07-18 12:13:23 +02:00
Fabian Kosmale
90226018a9 Provide QStringConverter equivalent of QTextCodec::availableCodecs
A text editor commonly wants to display a list of codecs that are
supported. With the introduction of the ICU based QStringConverter, that
list is no longer statically known. So provide the necessary
functionality.

Fixes: QTBUG-109104
Change-Id: I9ecf59aa6bcc6fe65c8872cab84affafec4fa362
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-07-18 09:38:38 +03:00
Axel Spoerl
bc9ad7db6b tst_QXmlStream: Fix CMakeLists.txt
Remove non existing path from GLOB_RECURSE statement.

Pick-to: 6.6 6.5 6.2
Change-Id: Ie122bd062acf8cc26f2ddead808c101af4da9573
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2023-07-18 08:36:21 +02:00
Liang Qi
43c4d17e4d tests: blacklist tst_QGraphicsItem::itemUsesExtendedStyleOption() on Wayland
Task-number: QTBUG-115293
Pick-to: 6.6 6.5
Change-Id: I0a9251b5656a5d5a1048fa0cb1606df1c42dd85d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-07-18 08:25:41 +02:00
Marc Mutz
3a166fa45d SlotObjectGuard: mark ctor nodiscard
QUIP: 19
Pick-to: 6.6
Change-Id: Idaf8cda12fe2ca97a763d78ff4c8cd7304d178e5
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-07-18 08:15:47 +02:00
Edward Welbourne
144e10eafb Treat simple spaces as equivalent in date-time format separators
The user might not be aware of, or able to see, the difference between
Unicode's assorted horizontal spacing characters, leading them to
expect their input to be accepted for a format despite differences in
spacing. So treat the various horizontal spacing (other than tab)
characters as equivalent when matching the separators in a date-time
format. Add a test-case that failed before this fix.

Fixes: QTBUG-114909
Pick-to: 6.6 6.5
Change-Id: I3e798d3e5b89adb8e86168ebd3954904b258d630
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2023-07-17 23:05:07 +02:00
Edward Welbourne
61b2a6f587 QDTP: Fix handling of no-digit numeric fields
A numeric field with no digits is Intermediate, since digits can be
typed into it. The testing for this was complicated by the fact that a
sign might be either a sign in the field or the start of a following
separator.

Break out the testing of separator matching at the start of a view.
This simplifies the existing checks for full separator match and we
can use it in the no-digit numeric field's handling to make the check
more robust (matching the whole separator, rather than only its first
character). It incidentally prepares the way for other changes.

Pick-to: 6.6 6.5
Task-number: QTBUG-114909
Change-Id: I5abfccbcae3cba0979b4723c400de038fe2bf324
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-07-17 23:05:04 +02:00
Li Yefeng
fbd259856d Fix wrong scan code values in key events obtained on Windows
The scan code (Windows) value depends on the extended-key flag
(KF_EXTENDED 0x0100) in the key message. This flag was kept in scan code
value, which is wrong. It is not part of scan code, and when it's on,
another byte 0xE0 should be prepended to scan code. See:
https://learn.microsoft.com/en-us/windows/win32/inputdev/about-keyboard-input#extended-key-flag

Change-Id: Iddcabb0aae92bb784883bddc9a34fe134d787b32
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2023-07-17 17:07:02 +00:00
Ivan Solovev
0b3c5816c6 Explicitly specify the alignment of QUuid::Id128Bytes union
... because otherwise the union can change its alignment based on
the presence of the data128 member.
For example, QtBluetooth explicitly #undef's __SIZEOF_INT128__ in
its removed_api.cpp, which leads to UB without this patch.

Found during API review

Pick-to: 6.6
Change-Id: Ia17122cc9f3d422530cf722ea528591fce7ab7ff
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-07-17 18:49:16 +02:00
Ivan Solovev
0393fa6bf2 QUuid: handle quint128 and Id128Bytes data in the same way
The QUuid(quint128) ctor was handing the incoming data differently
from the QUuid(Id128Bytes) ctor. Same was valid for the return
values of QUuid::toUint128() vs QUuid::toBytes().
The provided test didn't reveal it, because it was treating the same
128-bit input value as BE in one place, and as LE in another place.

This patch fixes the test, and updates the implementation of
QUuid(quint128) ctor and toUInt128() method to verify that the
updated test passes.

This commit amends 8566c2db85

Pick-to: 6.6
Change-Id: I24edb8ba0c8f7fd15062ba0b2a94ad387c3e98b6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-07-17 18:49:16 +02:00
Ivan Solovev
ef4e36aa3c QUuid: remove pointless inline keyword
constexpr functions are implicitly inline

Found during API review.

Pick-to: 6.6
Change-Id: I94daa0a67336fa99a1465115edb83e545580a78a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-07-17 18:49:16 +02:00
Mårten Nordheim
0b10808fb5 Network-chat example: update the screenshot
Change-Id: Ibdb9e242295766304c1c7a551d831fb796518496
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-07-17 18:49:16 +02:00
Mårten Nordheim
2a80adc2f6 Network-chat example: Use QHash for peers
We don't key it on IP address anymore so we can drop
the use of QMultiHash.
This also requires moving the connections for error and disconnected
to readyForUse so we don't remove an active connection when a second
connection attempt happens from the same peer process.
But since we still need to deallocate those connection attempts
if they error out or simply disconnect, we connect their signals to the
QObject::deleteLater slot. In some cases we might call deleteLater twice
but that's fine.

Change-Id: I48c27de1e51a52ef61cfb941a7a81b358ae9ce3f
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
2023-07-17 18:49:16 +02:00
Mårten Nordheim
226d06402b Network-chat: Fix remote peer making multiple connections
The system was just treating IP (and optionally port) as a unique
identifier, so if a peer had multiple possible paths to a client they
would connect multiple times.

This fixes that by generating using QUuid in each client.
We then use this during broadcast, replacing the username we
sent before (which was not used), and as part of the greeting.
The greeting now is more complex, since we need to send both
username and the ID.

Change-Id: I6c6c2ffd5198406aad48445a68dd6aab36de69c0
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-07-17 16:49:16 +00:00
Edward Welbourne
5651be517a XBEL stream example: use constructor initialization
The treeWidget member of MainWindow could be initialized before the
body of the constructor, enabling it to be a *const variable.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: If4a3b04729bc7fa5859ca88183eec376f6992455
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-07-17 14:50:51 +02:00
Kai Köhne
d4d600d411 Testlib: Make QTEST_ASSERT usable in constexpr functions
Commit 8ea27bb1c6 adapted the definition
of Q_ASSERT already.

Adopt the same logic for QTEST_ASSERT.

Pick-to: 6.5 6.6
Change-Id: I5a5d0f62df79b18635d3b426a439c35b25d739c2
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-07-17 08:33:40 +00:00
Piotr Wierciński
0493504f34 wasm: Render Qt::SubWindow borderless
Windows with Qt::SubWindow flag should not have platform decoration.

Fixes: QTBUG-115054
Pick-to: 6.5 6.6
Change-Id: I7111df6057a087080194c1d46e350df839bec437
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2023-07-17 10:33:36 +02:00
Axel Spoerl
959a8b3967 Adapt setBackingStore() overrides in QWasmWindow and QEglFSWindow
This is a follow up to a4ca9e8065,
adapting the backing store setters to become proper overrides of
the newly implemented QPlatformWindow::setBackingStore();

Pick-to: 6.6
Change-Id: Id4f5ff8650ca4e4d3cab1d71d27041c6129bf4ea
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-07-16 20:28:06 +02:00
Marc Mutz
ecab68989e QCborValue: fix memleak on Array to Map coercion
When converting from an array to a map, we double the number of
elements, spread the old elements out to make one free slot of space
in front of each, and then place Integer values counting from 0 into
the free slots.

The old code contained a loop that would add a strong reference to the
original elements that happen to be containers and thus are
ref-counted in the first place. But this additional strong reference
is not needed: In both cases, detached or in-place, the detach() call
that ensured unique ownership of 'map/dst' will have either directly
or indirectly updated the ref-counts of the elements correctly, and
the following loops just reshuffle the elements in the QList, they
don't create new copies (QtCbor::Elements doesn't by itself manipulate
container->ref, but even if it did, the copy would have increased, and
the assignment of the Integers would have decreased, the ref-count
again). Adding the strong ref without a user then caused the container
members to be leaked.

Fix by removing the loop.

[ChangeLog][QtCore][QCborValue] Fixed a memory leak when an array was
coerced into a map.

Amends ccea344640.

Not picking to 6.4 as it's closed at this time.

Fixes: QTBUG-115249
Pick-to: 6.6 6.5
Change-Id: I369c372e91c3f0cfe3c65f9b0ea8507d08fdaf48
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-07-15 16:02:04 +00:00
Marc Mutz
8cb542c2d4 tst_QTcpSocket: fix mem-leak
earlyConstructedSockets is a QObject, but had no parent and was never
deleted, leaking all the data is holds.

Fix by giving it a parent.

The code predates the begin of the public history.

Pick-to: 6.6 6.5 6.2 5.15
Change-Id: Ibc5688afd6111e84f591c37e39b6bb618d76c47a
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-07-15 15:06:58 +02:00
Marc Mutz
9f8449a054 tst_QSortFilterProxyModel: fix mem-leaks
tst_QSortFilterProxyModel::doubleProxySelectionSetSourceModel() leaked
_everything_, driving asan nuts.

Allocate objects on the stack instead; now it's asan-clean.

Pick-to: 6.6 6.5 6.2 5.15
Change-Id: I721e797e02b1daec9e2b5e3d4ef612a42b2e3492
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-07-15 15:06:55 +02:00