qt5base-lts/tests/auto
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
..
bic/data Add binary compatibility file built against 6.5.0 2023-04-19 15:40:36 +00:00
cmake CMake: Fix config condition evaluator 2023-09-21 21:46:46 +02:00
concurrent tst_QtConcurrentMedian: compile with QT_NO_FOREACH 2023-08-19 16:28:20 +03:00
corelib QWeakPointer: fix the converting constructor from rvalues 2023-09-25 21:50:07 +02:00
dbus QDBusMarshall test: avoid an atomic assignment 2023-09-14 18:39:24 +02:00
gui Support loading variable fonts as application fonts in Freetype 2023-09-20 21:37:50 +02:00
guiapplauncher Move Weather Anchor Layout example to manual tests 2023-03-02 05:55:57 +01:00
network Update public suffix list 2023-09-20 22:33:18 +02:00
opengl tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00
other Silence compiler warning 2023-09-22 20:40:36 +02:00
printsupport Dialogs: clean up native dialogs when object gets destroyed 2023-09-06 23:12:33 +02:00
shared Support loading variable fonts as application fonts in Freetype 2023-09-20 21:37:50 +02:00
sql tst_qvfssql: Don't use appless main 2023-08-11 15:45:36 +02:00
testlib tst_QAbstractItemModelTester: fix unittest 2023-09-08 19:17:36 +03:00
tools tst_qmakelib: compile with QT_NO_FOREACH 2023-08-19 19:17:17 +03:00
wasm CMake: Make qtbase tests standalone projects 2023-07-05 15:09:32 +02:00
widgets QAbstractItemDelegate: Update spinbox editor value before committing 2023-09-25 15:12:05 +02:00
xml CMake: Make qtbase tests standalone projects 2023-07-05 15:09:32 +02:00
CMakeLists.txt CI: Enable some tests under corelib/thread for Wasm platform 2023-09-14 11:58:48 +02:00
network-settings.h QtNetworkSettings: narrow down hasIPv6 to specific OSes 2023-08-29 07:20:51 -07:00