diff options
| author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2025-03-27 21:36:38 +0100 |
|---|---|---|
| committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2025-07-21 17:40:25 +0000 |
| commit | adcbac38cec5a849af6f2ee43e59b4f905ff5142 (patch) | |
| tree | 7a05d5364872d280ca653d61d63b0fa542b80c0f /src/tools/moc/preprocessor.cpp | |
| parent | 16b9faaba4666d7a20e74eb164a5c0389cd57d76 (diff) | |
QPainterPath: remove implicit sharing
QPainterPath is not reentrant. Most of its const APIs will actually
*modify* the private object (e.g. `boundingRect`, `controlPointRect`);
in 6.10, a caching system has been introduced¹, so now even more
const APIs will do so (e.g. `length`, `pointAtPercent`, etc.).
We've never advertised QPainterPath as reentrant, which means we're not
retracting any compatibility promise. (At the same time, the lack of
threading guarantees makes for poor usability -- from which thread it is
safe to use a QPainterPath? The GUI thread? Its creation thread?)
However, a non-reentrant implicitly shared class is a brutal API flaw,
since shallow copies of the same path will participate in data races,
making it impossible to reason on a program's correctness.
One can't even isolate their own instance by calling detach(), as that's
private (and forgetting to do so sounds extremely likely).
This commit removes the implicit sharing, and therefore makes
QPainterPath reentrant as a side-effect. I have no intention of studying
QPainterPath internals and making it reentrant while keeping it
implictly shared; it certainly sounds against the future evolution of
the class, since as I've just said, more non-reentrant APIs have just
been added.
This brings up the problem of what to use as the type of QPainterPath's
d-pointer: so far it was a QESDP. I would've moved it to a
std::unique_ptr, but that would bring the "inline move constructor needs
the destructor definition" issue that is solved by
QT_DECLARE_QESDP_SPECIALIZATION_DTOR, which we don't have for
unique_ptr. Therefore it needs to be a raw pointer...
¹ see 90247966a799a11fd17d5e55d00379a34b1cdf1f.
[ChangeLog][QtGui][QPainterPath] QPainterPath is no longer implicitly
shared. This is a necessary change to support various caching
optimizations. On the other hand, QPainterPath is now fully reentrant
(before, it was not thread-safe in the general case).
Pick-to: 6.10
Change-Id: Iaabc93e2c33839ef8872bbd2cd73d3d861a3c8e7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/tools/moc/preprocessor.cpp')
0 files changed, 0 insertions, 0 deletions
