2D: Optimize piemodelmapper
QPieModelMapperPrivate::initializePieFromModel() clears the series and
refills it from the model. That deleted every QPieSlice, together with
its per-slice styling, and left any pointers held by user code or QML
dangling. It was reached more often than necessary:
- modelReset was connected straight to it, bypassing m_modelSignalsBlock.
A model that resets from insertRows() or removeRows() therefore rebuilt
the whole series on every series edit the mapper wrote back to it.
Route it through onModelReset(), which honors the block flag like the
other model slots.
- Every property setter reinitialized and emitted its changed signal
even when the value was unchanged. Return early in that case, also for
setModel() and setSeries() with the current pointer.
- The setters, model resets and the other-orientation structural changes
now go through syncSlices(), which reconciles in place. It removes
surplus slices from the tail, refreshes label and value of the
remaining ones and appends missing ones, so slice objects and their
styling are kept and nothing is emitted when nothing changed.
Also fix a few related problems in setModel() and setSeries():
- setSeries(nullptr) and setModel(nullptr) now detach instead of
leaving the mapper using a series or model it no longer listens to.
- The slices of a previous series were left connected to the mapper
and could write to the wrong model row. Disconnect them when the
series changes.
- Handlers for series edits and slice changes no longer dereference a
null model or series, and handleSeriesDestroyed() drops the slices
that are destroyed with the series.
[ChangeLog][Graphs2D] The QPieModelMapper doesn't reinitialize the model
every time something changes.
Pick-to: 6.12
Task-number: QTBUG-151153
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Change-Id: I7580c77dca7e268f3af74c91fd1f751172c1fa93
Reviewed-by: Sami Varanka <sami.varanka@qt.io>
Reviewed-by: Tomi Korpipaa <tomi.korpipaa@qt.io>
Reviewed-by: Owais Akhtar <owais.akhtar@qt.io>