Details
-
Epic
-
Resolution: Unresolved
-
P2: Important
-
None
-
None
-
QSharedPointer
-
100
-
b96b672b2 (dev), 1e3ec1ba2 (dev), b31dfaddd (dev), 3693dd74f (dev)
Description
QSharedPointer has several problems. We can either fix them, or phase it slowly out, possibly via a middle step where QSharedPointer becomes a tiny wrapper around shared_ptr, going forward, the way we did in 6.0 with QMap and QPair.
The main problems are:
- a QSP copy up's both strong and weak ref-counts, for a 2x atomic ops load compared to shared_ptr, which only modifies the weak ref-count when the strong one falls to zero. This yields a precise 2x slowdown of QSP vs. shared_ptr (cf. ninja tst_bench_shared_ptr_benchmark)
- the unfortunate special mode for QObject payloads, which, among other things, makes it impossible to put a QObject held in QSharedPointer into a QPointer ([[citation needed]])
- QSP, unlike std::shared_ptr is not exception-safe
- lack of mainenance. shared_ptr has support for arrays and atomic<shared_ptr<>> in C++20, and it's probably not possible for QSharedPointer to do the latter unless it is shared_ptr.
- Since Qt 6, the QSharedPointer test suite is no longer complete (negative tests were never ported to cmake (QTBUG-93093))
This won't be as easy as wrapping the definition into an #ifndef QT_NO_SHARED_POINTER and setting the macro for more and more code until we can define it for all Qt modules and deprecate QSharedPointer.
The issues in this epic describe some (eventually, all) of the challenges.
Attachments
Issue Links
- covers
-
QTBUG-93093 The tests for QSharedPointer are disabled
- Reported
- relates to
-
QTBUG-127417 Add rvalue references of QSharedPointer cast operators
- Reported
Gerrit Reviews
For Gerrit Dashboard: QTBUG-109570 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
451700,13 | shiboken6: Port from QSharedPointer to std::shared_ptr | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
451852,3 | PySide6: Port from QSharedPointer to std::shared_ptr | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
452427,2 | Fix build without --unity | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
495291,6 | tst_QWizard: port from QSharedPointer to std::shared_ptr | dev | qt/qtbase | Status: MERGED | +2 | 0 |