qt6-bb10/tests/auto/corelib
Marc Mutz eb10876c7d Unbreak QSet::intersect()
The selection of which set to iterate over and which one to remove
from based on their relative size violates the function's
documentation, which clearly states that items are removed from *this,
and not from `other`, so the result must never contain any elements
from `other`.

Amends 4f2c96eaa8. Instead of reverting
to the gruesome old code with the forced detach-just-to-remove copies,
distinguish four cases:

- if the two sets are shallow copies of each other, then their
  intersection is *this

- otherwise, if either set is empty, clear() *this. This is required
  for one of the tests that 29017f1395
  added to succeed.

- otherwise, if *this is detached, perform the operation in-place,
  using removeIf()

- otherwise, create a new set and move-assign to *this to avoid
  detaching just to remove something again. In this case, we can
  continue to iterate over the smaller set, but we need to keep
  picking elements from LHS into the result.

[ChangeLog][QtCore][QSet] Fixed a regression (introduced for Qt 5.2)
in intersect() that caused equivalent elements of `*this` to be
overwritten by elements of `other` if `other.size()` was larger than
`this->size()`.

Not picking to 5.15, as users will have likely adjusted their code to
the buggy behavior, and because removeIf() isn't available there.

Pick-to: 6.5
Fixes: QTBUG-132536
Task-number: QTBUG-106179
Change-Id: Idfa17c3b3589c4eacec27259fc01df6aeaa6c45f
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 162015e9c6f469951d9212ef655cff16dcace071)
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit eb13efc4a606cdb0c6f785a6319c489ad53626f3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-02-05 15:57:55 +00:00
..
animation Change license for tests files 2024-02-04 09:56:42 +01:00
global QNumeric: add a private qUnsignedAbs 2025-01-29 13:33:32 +00:00
io tst_QProcess: remove duplicate DisableCrashLogger variable 2025-01-22 02:25:26 +00:00
ipc Add REUSE.toml files 2024-11-07 08:38:49 +01:00
itemmodels QConcatenateTablesProxyModel: react to row and column moves 2024-09-13 17:44:05 +00:00
kernel tst_Q*Application: add tests for unusual qApp creations and exits 2025-01-20 13:31:34 -08:00
mimetypes Add REUSE.toml files 2024-11-07 08:38:49 +01:00
platform Android: fix tst_android::testFullScreenDimensions() 2024-12-04 15:34:32 +00:00
plugin tst_QUuid: fix -Wreturn-type in make_minimal(QUuid::Version) 2025-01-25 14:21:25 +00:00
serialization QTextStream: fix UB calls to qAbs() with minimal arguments 2025-01-29 18:51:30 +00:00
text Include more pruned likely-equivalent entries in QLocale::uiLanguages 2025-01-28 15:49:49 +01:00
thread Fix QtFuture::when{All,Any}() overload resolution 2025-01-02 19:19:36 +00:00
time Update CLDR to v46 2025-01-14 11:15:42 +01:00
tools Unbreak QSet::intersect() 2025-02-05 15:57:55 +00:00
CMakeLists.txt tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00