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 4f2c96eaa8bfa4d8a6dfb92096e4e4030d0cdea7. 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 29017f1395b1bc52e60760fa58c92f6fa4ee4f60 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.8 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>
This directory contains autotests and benchmarks based on Qt Test. In order to run the autotests reliably, you need to configure a desktop to match the test environment that these tests are written for. Linux X11: * The user must be logged in to an active desktop; you can't run the autotests without a valid DISPLAY that allows X11 connections. * The tests are run against a KDE3 or KDE4 desktop. * Window manager uses "click to focus", and not "focus follows mouse". Many tests move the mouse cursor around and expect this to not affect focus and activation. * Disable "click to activate", i.e., when a window is opened, the window manager should automatically activate it (give it input focus) and not wait for the user to click the window.