diff options
author | Armin Le Grand (Collabora) <Armin.Le.Grand@me.com> | 2025-01-09 11:51:33 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2025-01-10 19:38:37 +0100 |
commit | 9304f13db61dc101ff1c121277c344a472c2951a (patch) | |
tree | 837bf672c5e529964a7e29ea97cbce7a142ea405 /icon-themes/sifr/cmd/lc_templatemanager.png | |
parent | 77e536c61a20cbf77207dbf599a88bd21e8ecc27 (diff) |
ItemType is useful and faster than RTTI. Until now it was
implemented by a 16-bit member in the base class, plus
(potentially) all constructors having to hand a value
in at item construction type (of type SfxItemType) to
get that member set correctly.
This works, but there is no reliable way to guarantee
coverage, and there have already been cases with missing
SfxItemType - these fallback to '0' and thus all Items
with ItemType() == 0 are assumed equal and might be
static_cast'ed to the wrong classes. Note that I
identified *35* Items that had no correct ItemType
set/implemented actually. It also uses 16-bit per
incarnated Item at runtime.
I thought and realized now a more systematic approach
to do that with a pure virtual function at the Item
itself. That can also be secured by a clang compiler
plugin in the future to keep it working. It uses one
virtual function per derived class, no longer space
in incarnated Items. Also the constructors will get
more simple again.
But the main aspect is security - we cannot afford
Items potentially being held as equal if they are not.
Unfortunately C++ does not offer something like a
'strict pure virtual function' that would force to
be overloaded in every derivation, but the used
methotology and adding a clang test is reasonably
safe.
Have now done the cleanup of previous method.
Change-Id: I04768285f1e9b73d64b0bb87df401944b5d35678
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180017
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'icon-themes/sifr/cmd/lc_templatemanager.png')
0 files changed, 0 insertions, 0 deletions