qt5base-lts/tests/auto/corelib/tools
Giuseppe D'Angelo 89b6ad3ab5 QWeakPointer: fix the converting constructor from rvalues
When constructing a QWeakPointer<T> from a rvalue QWeakPointer<X>,
even if X* is convertible to T*, actually doing the conversion
requires access to the pointee's vtable in case of virtual inheritance.

For instance:

  class Base { virtual ~Base(); };
  class Derived : public virtual Base {};

Now given a `Derived *ptr`, then a conversion of `ptr` to `Base *` is
implicit (it's a public base), but the compiler needs to dereference
`ptr` to find out where the Base sub-object is.

This access to the pointee requires protection, because by the time we
attempt the cast the pointee may have already been destroyed, or it's
being destroyed by another thread. Do that by going through a shared
pointer. (This matches the existing code for the converting assignment.)

This requires changing the private assign() method, used by QPointer, to
avoid going through a converting move assignment/construction, because
one can't upgrade a QWeakPointer tracking a QObject to a QSharedPointer.
Given it's the caller's responsibility to guard the lifetime of the
pointee passed into assign(), I can simply build a QWeakPointer<T> and
use ordinary (i.e. non-converting) move assignment instead.

Change-Id: I7743b334d479de7cefa6999395a33df06814c8f1
Pick-to: 6.5 6.6
Fixes: QTBUG-117483
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-25 21:50:07 +02:00
..
collections Mark all of Qt as free of Q_FOREACH, except where it isn't 2023-08-19 05:19:42 +00:00
containerapisymmetry CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qalgorithms CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qarraydata QArrayData: make calculateBlockSize() account for the extra null element 2023-09-03 17:43:24 -07:00
qatomicscopedvaluerollback QAtomicScopedValueRollback: fix CTAD for Q(Basic)AtomicPointer 2023-07-12 10:29:44 +02:00
qbitarray CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qcache CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qcommandlineparser QCommandLineParser: Warn invalid value calls 2023-09-21 22:05:06 +02:00
qcontiguouscache CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qcryptographichash CMake: remove check for cxx11_future 2023-08-02 12:36:18 -07:00
qduplicatetracker CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qeasingcurve tests/auto/: port Q_FOREACH to ranged-for, local const containers 2023-08-19 16:29:25 +03:00
qexplicitlyshareddatapointer tst_QExplicitlySharedDataPointer: Remove stray comment 2023-07-25 12:31:04 +02:00
qflatmap CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qfreelist tst_QFreeList: build with QT_NO_FOREACH 2023-08-19 16:29:54 +03:00
qhash CMake: remove check for cxx11_future 2023-08-02 12:36:18 -07:00
qhashfunctions Fix qHash(qfloat16) to match Qt 6.4 behavior 2023-09-12 21:12:50 +00:00
qhashseed CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qline CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qlist QArrayDataPointer: remove Q_CHECK_PTR in assign(it, it) again 2023-09-07 15:05:05 +02:00
qmacautoreleasepool CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qmakearray CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qmap CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qmargins CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qmessageauthenticationcode CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qoffsetstringarray CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qpair CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qpoint CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qpointf CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qqueue CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qrect CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qringbuffer CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qscopedpointer CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qscopedvaluerollback CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qscopeguard tst_QScopeGuard: test if and how guard in optional<> works 2023-07-10 19:47:08 +00:00
qset CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qsharedpointer QWeakPointer: fix the converting constructor from rvalues 2023-09-25 21:50:07 +02:00
qsize CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qsizef CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qspan Long live QSpan! 2023-07-21 17:00:05 +00:00
qstl CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qtaggedpointer CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qtimeline CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qvarlengtharray CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qversionnumber CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
CMakeLists.txt Long live QSpan! 2023-07-21 17:00:05 +00:00